Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1652454lqt; Wed, 20 Mar 2024 09:59:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUyFFJ2cYu+C/d0kcXSHPMVu3fbXP92XWNAvw3q7VF8qBIX1iJ5Shv433h7w22TK0tQg1UyUxWmCc0EsVOQ/ydvFPfy7/+coV3IwsrsyA== X-Google-Smtp-Source: AGHT+IEscUGsBMG+xYEuXkez97pitKNGqCjpWvlSVypXYGCPv1ZLRneGbmE6S9JRpwm+MSOspFlK X-Received: by 2002:ac8:7f4e:0:b0:42e:b3a8:f239 with SMTP id g14-20020ac87f4e000000b0042eb3a8f239mr2762384qtk.41.1710953984458; Wed, 20 Mar 2024 09:59:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710953984; cv=pass; d=google.com; s=arc-20160816; b=noQGhyTz1M1IA16f1eyjdGQafG1y7O5WoMgx/kvaPSQwdgyq5+1FJOTOmraUbfb3ee aBUMyDCs9SKoAbkqi0tkYYSrQ8z54SLYQazagJlm/ur45oY/MDBY5Cnu6Ao01hty2Gio SpOkpV2JaPbwcK3VT1xJ2hKNTgTov1Mrtnv+7WPScEd/PZorYQEn8tpCHDxIhThoXNWr aWyZa/2lyu36M9EYL9Khyjch5PtTEu+JbhNfiKeR/32lZzzfzHeULyy7lNP711kHUFMk OXtE8UkcJnrZ/DqqwsMst1oVXo+hsUoDkz03ZIsgQmp1T0dfAGD1nM6c5VV/w6gmNSsn 2x4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=jNTMySW8ko+xWR8W3ipokJd+Jp8Gjx0jRCwCIAGcu1I=; fh=63cPSNOnQW8ZtpQ6JeUDoFlGWCTjVcOPn2xQ/+7UX1A=; b=AhuRxlT3NMYkB49AvQMY3yv1a3YI3cLs4REdPt92zDrlYBKUMcUYa0vDuF/c3E7JIQ U3wK7EboZ10+FKnf8xxq/rCmGVDZQd7KvxzDbDCnw9s7bxi3JnETaio2KA/osLnvXS7j j0qcTVq1zLfGgL2g5PgTOiMWcNJLjDgg/72M9Zv+G43rjapyy+yb9Ls2vmrIFXyOsgFh ibjlsqM0Zl/VFciJql8hmKKncu4EbhjTwGco9aOi3Wtw+GcRpArnbxyFByQjf0VE6SmQ Px4tOQhcbdVcJ606Mj/vrHiGmJiYq3zrnFbaXmvLSGYeRWdBHQfG2LNJzg4pby71CyIi 48zg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FE5rrJUs; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-109197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109197-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u18-20020a05622a199200b00430eea8ed0fsi3225456qtc.793.2024.03.20.09.59.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 09:59:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FE5rrJUs; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-109197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109197-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E5E301C20BC1 for ; Wed, 20 Mar 2024 16:59:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D28F69E05; Wed, 20 Mar 2024 16:59:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FE5rrJUs" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 513FF10FA; Wed, 20 Mar 2024 16:59:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710953978; cv=none; b=r41G60QDTUf+eGIf06aIX0G5oaLJj3uozgvkwdUIXVPlkkfLKCywdWtP/zNWKtGKKU0C3zCE2V83WjNvUBT+yYA/5DWR5zoNuPrfvASPs/LpC5v4B7r1MxvlHF8zcHM5Rz4gc/BhYmZgFOAU9XNb5TgtT4FVkhrEOQhLY1pemoA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710953978; c=relaxed/simple; bh=s0/aLoxKix13bsWvxqVqF3isscoD1oqKeSGeoPdxMM8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=T1Y7cnLBBkCY5LJK7pMhjdgVWLXUwOs1C6w/+cqXI8gHRqsbm40fbyfrQsSHhyBRranFmCssjXoN7coq0ECQh8g7uFmsZh7M21XyH82hOJ4enZmj1AOVJnDSb7Um3paPNpxTeowyBm4NeGAN8QlLsgpLzO1flam/T1irqFxtgKg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FE5rrJUs; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710953976; x=1742489976; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=s0/aLoxKix13bsWvxqVqF3isscoD1oqKeSGeoPdxMM8=; b=FE5rrJUsfFsTyR0Wrc901MqAI/Gl6Y0dakmJQWE20wDmgHLmRp3Le5qn qa2okC2c8gZgf65wpbvyrKz8boN4EUtfu34yMIxJJd3Hmo3HV6I4S09et LeqFWP3ZU1ajkapB3rTdkNmuh4GnMMMT//CxuDEuy3eSlGJY41rsywRYk kjssQcnW/i5UDMDC8Q+b5Oh3g2rklOvhsFYj3I1qXfpF/QNNYNq9TPcs2 Ar2E9q+LAuM0VP4zZZ9hPJHSF6FKcOACqwBic5hZumCRfFnlEirUR/Nxq Qv/t5eDNvYnBppBzCB3TC1v9Ms8cia3NtqlSR3CSXc/Jvw8cvJoUOES1y A==; X-IronPort-AV: E=McAfee;i="6600,9927,11019"; a="6016995" X-IronPort-AV: E=Sophos;i="6.07,140,1708416000"; d="scan'208";a="6016995" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2024 09:59:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11019"; a="937063900" X-IronPort-AV: E=Sophos;i="6.07,140,1708416000"; d="scan'208";a="937063900" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 20 Mar 2024 09:59:33 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5204330D; Wed, 20 Mar 2024 18:59:32 +0200 (EET) From: Andy Shevchenko To: Bartosz Golaszewski , Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Bartosz Golaszewski , Stephen Boyd , Andy Shevchenko , Ferry Toth , Dmitry Torokhov Subject: [PATCH v2 1/1] gpiolib: Fix debug messaging in gpiod_find_and_request() Date: Wed, 20 Mar 2024 18:58:47 +0200 Message-ID: <20240320165930.1182653-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When consolidating GPIO lookups in ACPI code, the debug messaging had been reworked that the user may see [ 13.401147] (NULL device *): using ACPI '\_SB.LEDS.led-0' for '(null)' GPIO lookup [ 13.401378] gpio gpiochip0: Persistence not supported for GPIO 40 [ 13.401402] gpio-40 (?): no flags found for (null) instead of [ 14.182962] gpio gpiochip0: Persistence not supported for GPIO 40 [ 14.182994] gpio-40 (?): no flags found for gpios The '(null)' parts are less informative and likely scare the users. Replace them by '(default)' which can point out to the default connection IDs, such as 'gpios'. While at it, amend other places where con_id is used in the messages. Reported-by: Ferry Toth Fixes: 8eb1f71e7acc ("gpiolib: consolidate GPIO lookups") Suggested-by: Dmitry Torokhov Signed-off-by: Andy Shevchenko --- v2: completele reworked solution of 20231019173457.2445119-1-andriy.shevchenko@linux.intel.com drivers/gpio/gpiolib.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e2e583b40207..7d26e5de0b44 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2401,6 +2401,11 @@ char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset) } EXPORT_SYMBOL_GPL(gpiochip_dup_line_label); +static inline const char *function_name_or_default(const char *con_id) +{ + return con_id ?: "(default)"; +} + /** * gpiochip_request_own_desc - Allow GPIO chip to request its own descriptor * @gc: GPIO chip @@ -2429,10 +2434,11 @@ struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *gc, enum gpiod_flags dflags) { struct gpio_desc *desc = gpiochip_get_desc(gc, hwnum); + const char *name = function_name_or_default(label); int ret; if (IS_ERR(desc)) { - chip_err(gc, "failed to get GPIO descriptor\n"); + chip_err(gc, "failed to get GPIO %s descriptor\n", name); return desc; } @@ -2442,8 +2448,8 @@ struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *gc, ret = gpiod_configure_flags(desc, label, lflags, dflags); if (ret) { - chip_err(gc, "setup of own GPIO %s failed\n", label); gpiod_free_commit(desc); + chip_err(gc, "setup of own GPIO %s failed\n", name); return ERR_PTR(ret); } @@ -4157,19 +4163,17 @@ static struct gpio_desc *gpiod_find_by_fwnode(struct fwnode_handle *fwnode, enum gpiod_flags *flags, unsigned long *lookupflags) { + const char *name = function_name_or_default(con_id); struct gpio_desc *desc = ERR_PTR(-ENOENT); if (is_of_node(fwnode)) { - dev_dbg(consumer, "using DT '%pfw' for '%s' GPIO lookup\n", - fwnode, con_id); + dev_dbg(consumer, "using DT '%pfw' for '%s' GPIO lookup\n", fwnode, name); desc = of_find_gpio(to_of_node(fwnode), con_id, idx, lookupflags); } else if (is_acpi_node(fwnode)) { - dev_dbg(consumer, "using ACPI '%pfw' for '%s' GPIO lookup\n", - fwnode, con_id); + dev_dbg(consumer, "using ACPI '%pfw' for '%s' GPIO lookup\n", fwnode, name); desc = acpi_find_gpio(fwnode, con_id, idx, flags, lookupflags); } else if (is_software_node(fwnode)) { - dev_dbg(consumer, "using swnode '%pfw' for '%s' GPIO lookup\n", - fwnode, con_id); + dev_dbg(consumer, "using swnode '%pfw' for '%s' GPIO lookup\n", fwnode, name); desc = swnode_find_gpio(fwnode, con_id, idx, lookupflags); } @@ -4185,6 +4189,7 @@ struct gpio_desc *gpiod_find_and_request(struct device *consumer, bool platform_lookup_allowed) { unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT; + const char *name = function_name_or_default(con_id); /* * scoped_guard() is implemented as a for loop, meaning static * analyzers will complain about these two not being initialized. @@ -4207,8 +4212,7 @@ struct gpio_desc *gpiod_find_and_request(struct device *consumer, } if (IS_ERR(desc)) { - dev_dbg(consumer, "No GPIO consumer %s found\n", - con_id); + dev_dbg(consumer, "No GPIO consumer %s found\n", name); return desc; } @@ -4230,15 +4234,14 @@ struct gpio_desc *gpiod_find_and_request(struct device *consumer, * * FIXME: Make this more sane and safe. */ - dev_info(consumer, - "nonexclusive access to GPIO for %s\n", con_id); + dev_info(consumer, "nonexclusive access to GPIO for %s\n", name); return desc; } ret = gpiod_configure_flags(desc, con_id, lookupflags, flags); if (ret < 0) { - dev_dbg(consumer, "setup of GPIO %s failed\n", con_id); gpiod_put(desc); + dev_dbg(consumer, "setup of GPIO %s failed\n", name); return ERR_PTR(ret); } @@ -4354,6 +4357,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_optional); int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id, unsigned long lflags, enum gpiod_flags dflags) { + const char *name = function_name_or_default(con_id); int ret; if (lflags & GPIO_ACTIVE_LOW) @@ -4397,7 +4401,7 @@ int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id, /* No particular flag request, return here... */ if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) { - gpiod_dbg(desc, "no flags found for %s\n", con_id); + gpiod_dbg(desc, "no flags found for GPIO %s\n", name); return 0; } -- 2.43.0.rc1.1.gbec44491f096