From patchwork Thu Oct 19 17:34:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 155665 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp548548vqb; Thu, 19 Oct 2023 10:36:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuGRutcY4BTQRvHQGFiuF/ojAKGl8vK9b37UB0LO1sHdW5Gq30z5dsdxsJ5ZIPpb4tpjQQ X-Received: by 2002:a05:6a21:7803:b0:17b:4b61:a8f7 with SMTP id be3-20020a056a21780300b0017b4b61a8f7mr3102940pzc.9.1697737001069; Thu, 19 Oct 2023 10:36:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697737001; cv=none; d=google.com; s=arc-20160816; b=WCBqbDpprQqs3ThcDZoqJEZU3Zt9Do29KAxvKT1wME9kBtcVbX7S66TjoUMKhGOESm VP+27iakRFxPoYQ8XeW5iZ5hNHJWCtyyPHuAFs1aEcK7LZryXY9Sh5PoRkCqmRvG9xp0 O/Je8d41tjJfjXkOdfVKhsnJH1ExN14cDbrsHnz208M8WiIXOG8SNNfeoIf3ZWGaXk8d P9ZdWxosf9lpNgrlZFXWvz0KdHN7QaxtLUoicMm0Bq/8gJlG8aadKNYU+m8fP4HErvbt GbYQXDELeHP7Ho5QslinFynLfTbBqEvJR3zij+/UaC6Go8mKNR/OFo9ZQsdcrEJ/7xqn 9weA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YMKoKR9mpYuWm1Ue6hyW2OnCpv7WG9T5uvYX281UTIk=; fh=7/omDlK7dosONq5l8CePi/uH/LZ0eAviv1Treoi9wLU=; b=DJMKlpEBtUc/rwZu/CDTJIQnPMLnbMTD5Qs8ky6h6H2KfcWyir5gZ/9y0u7h+mpWRa +SJMMuoysYAuvQPWHh7j6W74gOX2RaSaZX3ASf3XTpsOPkXhcwaNVqWGbqkxqJ3RY28D 5rFvvK4JF3/oRhcyT+56R7aiyL+zTPhuzyyT3gMV4l9CmKwYy9AlD8oWhdKKDFhaRHXU DmaZON0W1Jp1V/z1F/719vivD9/FZIqVJh+lZxzC/FANquo7D6Be8g7/ff2cylH9wdwl fzSMEsCMdg92mVa9jw+i5uBqZGbcf+ZTQAxlQ0veBZXS0iWe1NGvh2nkNo9E2a9opUnn C2xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Oc8uynhB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id v10-20020a63610a000000b005acf91427cfsi40232pgb.628.2023.10.19.10.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 10:36:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Oc8uynhB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8F83D8070DAF; Thu, 19 Oct 2023 10:35:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346344AbjJSRfP (ORCPT + 26 others); Thu, 19 Oct 2023 13:35:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235499AbjJSRfJ (ORCPT ); Thu, 19 Oct 2023 13:35:09 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 619A7138; Thu, 19 Oct 2023 10:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697736906; x=1729272906; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OK+wrv+DMOQXPBESi5xHEfknrZptJg8C/cIK0m+tQ50=; b=Oc8uynhBrgzTo2ujIVSkfTn6dxW8SwfreV1tEfMYV7p0WXwm1QR6/bl8 lFIzSo9bBeM+K8Cz7dDJ7eScjN1rdclmkqjF5ToNQV7zLpeH1xOjdkKRO 2m4Ayhml04s2j2qpBRdd6BWE+I/XC1uxspe0F45SVEjlbLi/ZK4pbCv2y 1dCaHwvalGBNWtSPOIs588KJIJVff5ZZ2uiZGvMYhH3CAgTCL53gpdIx6 wmKyVX/R7O0v4AetmQoT6hYQ8CViftb+VvW4pilX2N8k0uVZGNegvmUj/ XX8BE7w72RlbtDnWC4fKsZrHdku0qMrFS3iAyVI+c4GDEPI9JTYxi7jHr w==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="389184246" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="389184246" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:35:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="760723566" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="760723566" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 19 Oct 2023 10:35:02 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 47B19F4; Thu, 19 Oct 2023 20:35:01 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Dmitry Torokhov , Bartosz Golaszewski , Linus Walleij , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mika Westerberg , Bartosz Golaszewski , Hans de Goede , Ferry Toth Subject: [PATCH v1 1/3] gpiolib: acpi: Add missing memset(0) to acpi_get_gpiod_from_data() Date: Thu, 19 Oct 2023 20:34:55 +0300 Message-Id: <20231019173457.2445119-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231019173457.2445119-1-andriy.shevchenko@linux.intel.com> References: <20231019173457.2445119-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 10:35:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780206273706603833 X-GMAIL-MSGID: 1780206273706603833 When refactoring the acpi_get_gpiod_from_data() the change missed cleaning up the variable on stack. Add missing memset(). Reported-by: Ferry Toth Fixes: 16ba046e86e9 ("gpiolib: acpi: teach acpi_find_gpio() to handle data-only nodes") Signed-off-by: Andy Shevchenko Reviewed-by: Dmitry Torokhov --- drivers/gpio/gpiolib-acpi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index fbda452fb4d6..51e41676de0b 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -951,6 +951,7 @@ static struct gpio_desc *acpi_get_gpiod_from_data(struct fwnode_handle *fwnode, if (!propname) return ERR_PTR(-EINVAL); + memset(&lookup, 0, sizeof(lookup)); lookup.index = index; ret = acpi_gpio_property_lookup(fwnode, propname, index, &lookup); From patchwork Thu Oct 19 17:34:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 155667 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp548693vqb; Thu, 19 Oct 2023 10:36:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJXXQYyOgmn3a1KEQo+nmz2IppSads64HqHqMNtZEGUiRQ5tqpho6DbD1Hp6ondZ8VB5tX X-Received: by 2002:a17:90b:3b8c:b0:27d:3e90:9ee1 with SMTP id pc12-20020a17090b3b8c00b0027d3e909ee1mr2934446pjb.23.1697737016488; Thu, 19 Oct 2023 10:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697737016; cv=none; d=google.com; s=arc-20160816; b=R6GZaZg/LTn5TdVOANn/OTVYE68Yh+gx6elWHrBR0b2mT9MvNFuXXCxH5W5iFNBUn0 wrjxUnO0dn8hgOvI9TJdT3LzpsQRkaCXb6JUTJf0LITe9y+aU6aGor9lTvDT9aHvClCs XDSiNZcVlDAecxiu+yY3lX/sIdeSDKnoPwRaYhQlHyJYVq4oq+RlMEQSPpA/fssRnOet kgK1WHsbx89sC4VxltYOxm7iYMtmiTK7WI+LYuU/+aweokRd9Onx2G0t6EhBGsJknHDl Rzp/pldyFNld71BpqYn7/Cuvx36x0IP4kEsA6fhOiAf/ReVmsb+70NQTOt0+fJCSAzLy Sczw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3NzcUY8pTwLR9IwwY1cRozHqB3MkirGPlUcMUMxfc/k=; fh=7/omDlK7dosONq5l8CePi/uH/LZ0eAviv1Treoi9wLU=; b=Ylbb5MEU01dfwYqruehcDZM2LRvwPIno6as6/OJSGkWvHgUVoIMxSf7uHp3tNU3cZP msn5lr7yQJ2qEu5IWM3AD9PVERdy1VpyvE3y/rM1ojZ+US+fD2GO4hPIEdRANLI98DD/ 1emoUoHC5/D8bCQhhOBvsc16owv5oGQfzW3Aog+GFQ4eUN0U9towq7dqY9l9Kqo/Xkx3 4rcIYoVuqLcSioPH+a06NClp89lbKxDw75lTMoptDyHl7J9CVB0J6khOOS6YqwzgkYvo mAiMi8t9b0wLzVi+/8hgDnIcucjFm8P/f5nwpI6HxKyZ92HHtU8mcQB0++9O9fyN4eWf J/Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MB0AKiCm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id c12-20020a17090a8d0c00b002748c1bbd79si2705956pjo.6.2023.10.19.10.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 10:36:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MB0AKiCm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 585FB80A9E1F; Thu, 19 Oct 2023 10:36:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346399AbjJSRfW (ORCPT + 26 others); Thu, 19 Oct 2023 13:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235503AbjJSRfK (ORCPT ); Thu, 19 Oct 2023 13:35:10 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40DD6182; Thu, 19 Oct 2023 10:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697736907; x=1729272907; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2FyMFKyMhc+AxK+IILlJGCje9zC4QbnuYvc9XHRShSo=; b=MB0AKiCmhXhObWG61YcNyT2SprE6H/SDAaK9LcDGPkEOWSlI/TSTHRag 98O0Uj/W37Eg3x7p4Mnguie5fn1Njqs5AWnvGctqwmIZC3YKeEzVTfH9Q I0RTzAh+ouDqNEtPG2xYA1N0/vN+a8wiKxkLeDo2nhASnUkFNbOZd3qX4 6AsOx6ArpbO65iYJY2uqLUvdPBFuo6HR78IE6zJjBUI0t9xlogEZemsbx I7yS0HbOciXvtqk+5PrZmJuENG4pRlMUUsgBqAYt6c3bz0sOWou2b4dM4 NWddzNzpAp/zhZ0qpOEEcFDLhqB+1J60Qn3QLF2sQhIRecwMcPJKcmDyj A==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="389184255" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="389184255" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:35:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="760723567" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="760723567" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 19 Oct 2023 10:35:02 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5BC259CE; Thu, 19 Oct 2023 20:35:01 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Dmitry Torokhov , Bartosz Golaszewski , Linus Walleij , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mika Westerberg , Bartosz Golaszewski , Hans de Goede , Ferry Toth Subject: [PATCH v1 2/3] gpiolib: Fix debug messaging in gpiod_find_and_request() Date: Thu, 19 Oct 2023 20:34:56 +0300 Message-Id: <20231019173457.2445119-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231019173457.2445119-1-andriy.shevchenko@linux.intel.com> References: <20231019173457.2445119-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 19 Oct 2023 10:36:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780206290099847317 X-GMAIL-MSGID: 1780206290099847317 When consolidating GPIO lookups in ACPI code, the debug messaging had been broken and hence lost a bit of sense. Restore debug messaging in gpiod_find_and_request() when configuring the GPIO line via gpiod_configure_flags(). Reported-by: Ferry Toth Fixes: 8eb1f71e7acc ("gpiolib: consolidate GPIO lookups") Signed-off-by: Andy Shevchenko Acked-by: Linus Walleij --- drivers/gpio/gpiolib-acpi.c | 9 ++++----- drivers/gpio/gpiolib-acpi.h | 13 +++++++------ drivers/gpio/gpiolib-of.c | 13 +++++++------ drivers/gpio/gpiolib-of.h | 8 ++++---- drivers/gpio/gpiolib-swnode.c | 4 ++-- drivers/gpio/gpiolib-swnode.h | 1 + drivers/gpio/gpiolib.c | 21 ++++++++++++++------- 7 files changed, 39 insertions(+), 30 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 51e41676de0b..a2899b2a58bd 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -973,24 +973,23 @@ static bool acpi_can_fallback_to_crs(struct acpi_device *adev, } struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, - const char *con_id, - unsigned int idx, + const char *con_id, unsigned int idx, + char *propname, size_t propsize, enum gpiod_flags *dflags, unsigned long *lookupflags) { struct acpi_device *adev = to_acpi_device_node(fwnode); struct acpi_gpio_info info; struct gpio_desc *desc; - char propname[32]; int i; /* Try first from _DSD */ for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { if (con_id) { - snprintf(propname, sizeof(propname), "%s-%s", + snprintf(propname, propsize, "%s-%s", con_id, gpio_suffixes[i]); } else { - snprintf(propname, sizeof(propname), "%s", + snprintf(propname, propsize, "%s", gpio_suffixes[i]); } diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h index 0fcd7e14d7f9..b5f0de249765 100644 --- a/drivers/gpio/gpiolib-acpi.h +++ b/drivers/gpio/gpiolib-acpi.h @@ -28,8 +28,8 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip); void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, - const char *con_id, - unsigned int idx, + const char *con_id, unsigned int idx, + char *propname, size_t propsize, enum gpiod_flags *dflags, unsigned long *lookupflags); @@ -44,10 +44,11 @@ acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { } static inline void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { } -static inline struct gpio_desc * -acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, - unsigned int idx, enum gpiod_flags *dflags, - unsigned long *lookupflags) +static inline struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, + const char *con_id, unsigned int idx, + char *propname, size_t propsize, + enum gpiod_flags *dflags, + unsigned long *lookupflags) { return ERR_PTR(-ENOENT); } diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 531faabead0f..017ee5cbfb60 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -621,10 +621,11 @@ static const of_find_gpio_quirk of_find_gpio_quirks[] = { NULL }; -struct gpio_desc *of_find_gpio(struct device_node *np, const char *con_id, - unsigned int idx, unsigned long *flags) +struct gpio_desc *of_find_gpio(struct device_node *np, + const char *con_id, unsigned int idx, + char *propname, size_t propsize, + unsigned long *flags) { - char prop_name[32]; /* 32 is max size of property name */ enum of_gpio_flags of_flags; const of_find_gpio_quirk *q; struct gpio_desc *desc; @@ -633,13 +634,13 @@ struct gpio_desc *of_find_gpio(struct device_node *np, const char *con_id, /* Try GPIO property "foo-gpios" and "foo-gpio" */ for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { if (con_id) - snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id, + snprintf(propname, propsize, "%s-%s", con_id, gpio_suffixes[i]); else - snprintf(prop_name, sizeof(prop_name), "%s", + snprintf(propname, propsize, "%s", gpio_suffixes[i]); - desc = of_get_named_gpiod_flags(np, prop_name, idx, &of_flags); + desc = of_get_named_gpiod_flags(np, propname, idx, &of_flags); if (!gpiod_not_found(desc)) break; diff --git a/drivers/gpio/gpiolib-of.h b/drivers/gpio/gpiolib-of.h index 6b3a5347c5d9..c2517e7913ee 100644 --- a/drivers/gpio/gpiolib-of.h +++ b/drivers/gpio/gpiolib-of.h @@ -16,16 +16,16 @@ struct gpio_device; #ifdef CONFIG_OF_GPIO struct gpio_desc *of_find_gpio(struct device_node *np, - const char *con_id, - unsigned int idx, + const char *con_id, unsigned int idx, + char *propname, size_t propsize, unsigned long *lookupflags); int of_gpiochip_add(struct gpio_chip *gc); void of_gpiochip_remove(struct gpio_chip *gc); int of_gpio_get_count(struct device *dev, const char *con_id); #else static inline struct gpio_desc *of_find_gpio(struct device_node *np, - const char *con_id, - unsigned int idx, + const char *con_id, unsigned int idx, + char *propname, size_t propsize, unsigned long *lookupflags) { return ERR_PTR(-ENOENT); diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c index b5a6eaf3729b..12c94f620f6b 100644 --- a/drivers/gpio/gpiolib-swnode.c +++ b/drivers/gpio/gpiolib-swnode.c @@ -51,20 +51,20 @@ static struct gpio_chip *swnode_get_chip(struct fwnode_handle *fwnode) struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int idx, + char *propname, size_t propsize, unsigned long *flags) { const struct software_node *swnode; struct fwnode_reference_args args; struct gpio_chip *chip; struct gpio_desc *desc; - char propname[32]; /* 32 is max size of property name */ int error; swnode = to_software_node(fwnode); if (!swnode) return ERR_PTR(-EINVAL); - swnode_format_propname(con_id, propname, sizeof(propname)); + swnode_format_propname(con_id, propname, propsize); /* * We expect all swnode-described GPIOs have GPIO number and diff --git a/drivers/gpio/gpiolib-swnode.h b/drivers/gpio/gpiolib-swnode.h index af849e56f6bc..b75fbb1fa7a6 100644 --- a/drivers/gpio/gpiolib-swnode.h +++ b/drivers/gpio/gpiolib-swnode.h @@ -8,6 +8,7 @@ struct gpio_desc; struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int idx, + char *propname, size_t propsize, unsigned long *flags); int swnode_gpio_count(const struct fwnode_handle *fwnode, const char *con_id); diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 40a0022ea719..beac3031246e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3938,8 +3938,8 @@ static int platform_gpio_count(struct device *dev, const char *con_id) static struct gpio_desc *gpiod_find_by_fwnode(struct fwnode_handle *fwnode, struct device *consumer, - const char *con_id, - unsigned int idx, + const char *con_id, unsigned int idx, + char *propname, size_t propsize, enum gpiod_flags *flags, unsigned long *lookupflags) { @@ -3948,15 +3948,18 @@ static struct gpio_desc *gpiod_find_by_fwnode(struct fwnode_handle *fwnode, if (is_of_node(fwnode)) { dev_dbg(consumer, "using DT '%pfw' for '%s' GPIO lookup\n", fwnode, con_id); - desc = of_find_gpio(to_of_node(fwnode), con_id, idx, lookupflags); + desc = of_find_gpio(to_of_node(fwnode), con_id, idx, propname, propsize, + lookupflags); } else if (is_acpi_node(fwnode)) { dev_dbg(consumer, "using ACPI '%pfw' for '%s' GPIO lookup\n", fwnode, con_id); - desc = acpi_find_gpio(fwnode, con_id, idx, flags, lookupflags); + desc = acpi_find_gpio(fwnode, con_id, idx, propname, propsize, + flags, lookupflags); } else if (is_software_node(fwnode)) { dev_dbg(consumer, "using swnode '%pfw' for '%s' GPIO lookup\n", fwnode, con_id); - desc = swnode_find_gpio(fwnode, con_id, idx, lookupflags); + desc = swnode_find_gpio(fwnode, con_id, idx, propname, propsize, + lookupflags); } return desc; @@ -3970,11 +3973,15 @@ static struct gpio_desc *gpiod_find_and_request(struct device *consumer, const char *label, bool platform_lookup_allowed) { + char propname[32] = ""; /* 32 is max size of property name */ + const char *funcname = con_id ?: propname; unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT; struct gpio_desc *desc; int ret; - desc = gpiod_find_by_fwnode(fwnode, consumer, con_id, idx, &flags, &lookupflags); + desc = gpiod_find_by_fwnode(fwnode, consumer, con_id, idx, + propname, sizeof(propname), + &flags, &lookupflags); if (gpiod_not_found(desc) && platform_lookup_allowed) { /* * Either we are not using DT or ACPI, or their lookup did not @@ -4012,7 +4019,7 @@ static struct gpio_desc *gpiod_find_and_request(struct device *consumer, return desc; } - ret = gpiod_configure_flags(desc, con_id, lookupflags, flags); + ret = gpiod_configure_flags(desc, funcname, lookupflags, flags); if (ret < 0) { dev_dbg(consumer, "setup of GPIO %s failed\n", con_id); gpiod_put(desc); From patchwork Thu Oct 19 17:34:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 155666 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp548691vqb; Thu, 19 Oct 2023 10:36:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGDpIRVDANeyNEnrXxspdw9s0aKiI/pCJkg1YbQk0qyGkjGGj5jPSpR8cvG2AlgzWRcnW/ X-Received: by 2002:a17:902:d2d1:b0:1ca:8252:a91 with SMTP id n17-20020a170902d2d100b001ca82520a91mr3334111plc.41.1697737016327; Thu, 19 Oct 2023 10:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697737016; cv=none; d=google.com; s=arc-20160816; b=GLCU+dUofN6mucuz45lu4g8fIkNDLGS77HDh6g/2+P1dDtl7ESJ59QHwKi1ObJjYyC vfAfkmy1pqHxCiFw4eMePla0L/KLx+pMsfZrKhsCfapbBAvQeEqBttsvgYRdoX71PD3P R4GMLDmbgOgXH+e6TO5K5C4f+H9loCGw6Q1qPkCYstQks3gC0E0PIJAOKTCrW2PC3blG Rab0dYZNOq0Z445mRUmGXWwbGQy08nZ+izsbDSZUHk1CR/o+4Ad3rugDmHtQjJ//+5XG 9X99CwJaHGiuiSf+2e7howmkeBoIu7uLx9SHV1TpIyU5da/hHXTAWz3EAmrne2GBHKf3 e0gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XfbBmhRgEIz+gNMz158x/DbKNfDqJFUnwB0B8yf5S4c=; fh=7/omDlK7dosONq5l8CePi/uH/LZ0eAviv1Treoi9wLU=; b=fi2IodlVBPdQs5KYDhSHccranloyWCdEHudN+joOljbpH9vut6/vyQar3yn5K5qm9x 2qKmbYd7rV1p5lF6SfWVzOF9WWuIWeeQdPih4L14kNDS9Xmfx0NjOf7xV1R76SX+x1Cf L0T23jyFyGPiRla0um2+gItgkAw3NMy35ndH+TViIm2wCccMlBw7fRhc0RUN8/n55YVG ALHhcftyxQ10ETVhmCAkmudBpmvjnfRMIHSnjqxiDOTUKELNajseatlF+yLPGo/c+ku5 e2jDJCxkrenhXOsdSQxAgvfFJcb4JJuBeR6y4cjlo+bc9kNuJCgDdCzIVWmgDh7kP/d1 eSHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FK3dayYJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id s17-20020a170902a51100b001bdd35033ebsi2370960plq.361.2023.10.19.10.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 10:36:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FK3dayYJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 2307880A53D4; Thu, 19 Oct 2023 10:35:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346359AbjJSRfT (ORCPT + 26 others); Thu, 19 Oct 2023 13:35:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235501AbjJSRfJ (ORCPT ); Thu, 19 Oct 2023 13:35:09 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79398187; Thu, 19 Oct 2023 10:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697736907; x=1729272907; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3LQFQSjAmhdexmjB2MNVF4dNzHqUHaGq6iDWHa57HD8=; b=FK3dayYJ/IsW38/39Fd9b1lUfTJb1y5FN3c3veNQFrsbbzZnNcPO3lIB Hh7QAsKpaZzAXcIicrZpilpHj8/MGxx/DqkW6RwkzNsRaJ2TtFz2BuUYW iQFQyll3ocE5IgtUpPWGufM+wricACyO7B9q12u4UJ7f5pWwCjasucqJa DNwxIGvMAsh35gMUZEYWZmWIDTatqRQLNOMs5HMITsYLwIflpldD22zVB sb1GLXl62h181Sr9Nqj+on1AgosvX9/FlQn2j7jf/E6s5QtxlF+Jh+o5W AJRyyp4khZGsExmnDX7xg+pK5oTGD1Q5xUBvAl/cV1qU/tygjedgB/dJt g==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="389184265" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="389184265" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:35:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="760723569" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="760723569" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 19 Oct 2023 10:35:02 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 676D9A46; Thu, 19 Oct 2023 20:35:01 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Dmitry Torokhov , Bartosz Golaszewski , Linus Walleij , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mika Westerberg , Bartosz Golaszewski , Hans de Goede , Ferry Toth Subject: [PATCH v1 3/3] gpiolib: Make debug messages in gpiod_find_by_fwnode() less confusing Date: Thu, 19 Oct 2023 20:34:57 +0300 Message-Id: <20231019173457.2445119-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231019173457.2445119-1-andriy.shevchenko@linux.intel.com> References: <20231019173457.2445119-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 19 Oct 2023 10:35:38 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780206289244646330 X-GMAIL-MSGID: 1780206289244646330 Currently the extended debug messages have added confusion, but value when con_id is NULL, which is the case for, e.g., GPIO LEDs. Improve the messaging by using GPIO function name rather than con_id. This requires to split and move the second part after the respective calls. Reported-by: Ferry Toth Fixes: 8eb1f71e7acc ("gpiolib: consolidate GPIO lookups") Signed-off-by: Andy Shevchenko Acked-by: Linus Walleij --- drivers/gpio/gpiolib.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index beac3031246e..2cc275fb62b6 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3946,18 +3946,15 @@ static struct gpio_desc *gpiod_find_by_fwnode(struct fwnode_handle *fwnode, 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 GPIO lookup\n", fwnode); desc = of_find_gpio(to_of_node(fwnode), con_id, idx, propname, propsize, 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 GPIO lookup\n", fwnode); desc = acpi_find_gpio(fwnode, con_id, idx, propname, propsize, 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 GPIO lookup\n", fwnode); desc = swnode_find_gpio(fwnode, con_id, idx, propname, propsize, lookupflags); } @@ -3993,10 +3990,12 @@ static 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 descriptor for '%s' found\n", funcname); return desc; } + dev_dbg(consumer, "Found GPIO descriptor for '%s'\n", funcname); + /* * If a connection label was passed use that, else attempt to use * the device name as label @@ -4015,13 +4014,13 @@ static 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); + "nonexclusive access to GPIO for %s\n", funcname); return desc; } ret = gpiod_configure_flags(desc, funcname, lookupflags, flags); if (ret < 0) { - dev_dbg(consumer, "setup of GPIO %s failed\n", con_id); + dev_dbg(consumer, "setup of GPIO %s failed\n", funcname); gpiod_put(desc); return ERR_PTR(ret); }