Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1956906pxb; Fri, 5 Mar 2021 04:05:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgz2oYQuWRkjDxzWzNWsEfdrN00yLmRlJmxAZVR0ARjKh0Gv6WM5YRXFJOk4mqvR6bD0uR X-Received: by 2002:a17:906:8904:: with SMTP id fr4mr2014417ejc.136.1614945941436; Fri, 05 Mar 2021 04:05:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614945941; cv=none; d=google.com; s=arc-20160816; b=Y8tCNb/FJ9ZcsaKS6ZfpOosRSF8OBgGNgrMP+8QYSl+Er7gMF5kWSih3+M4YRlgdYp rnd7XeESffCFA8xBqS4AVpP6I2Rl1jXr/jlmpOM0lgpVC49n9yWtegwxMcdae4zDNI6d AepmOtbMHOkYgCkkXgm4RrenoyzVDVMpE2O0BdK72OhZp39xPe620hYSA4sG9XKnC/P+ euVmraPrNUBH8TaluV4HMyle8daWA37ekBq8uNOqkntT2uh3kv2Yvl9OD0Ta/PFbmuWU f2d6NVuDSH06IDAP5raAuoH2Yi3NSvCHapjIlG6o2EuMoFYiFYVnZKCKR+SDwLc8HIJx IryQ== 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 :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=RdWG9FoBZnrqpwkyCYmrrZVYbegoHywNjVwVtQK8fcs=; b=ltOlxVsoAwpneWjrDGZZy0OzOsXK+JzHLgpotIMqOa2TJdHfDlQFt+TUw1ZiyKpgOo rAjXvA8TglPsy42fI/uCErepdhewWnRC/6T+KtgbCJEzsbKGKXU2NGRkEf3po6liaE/6 w11dqANeueEVFAEB+bBfKfQVjbncu2MMcvcpu3gYijXkSM3879lfarMiD5c7L6Z6ON4L TPeRKaAwWz1gwdEnIcEcUvBTtlr8dcC4uqa/NmqUUHtBYEYIHaIF7KxbeNXIezmUPj75 zajPiTIBQbdeYethV+2iJh5eJAmDND+fVLLui3gXVGIWD6tKSHaYvSnBlt28oMYO9lL0 NQaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k26si1342096eds.534.2021.03.05.04.05.15; Fri, 05 Mar 2021 04:05:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbhCEMC5 (ORCPT + 99 others); Fri, 5 Mar 2021 07:02:57 -0500 Received: from mga12.intel.com ([192.55.52.136]:5542 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229701AbhCEMCx (ORCPT ); Fri, 5 Mar 2021 07:02:53 -0500 IronPort-SDR: duwtj94eeJuFKFt/R9JFqDjyovZ8rigtPPn9Cn/Jg+yWReTw/Qf+v79NFMRh86/JYcSV4dLv46 +z0+nyDL7RMA== X-IronPort-AV: E=McAfee;i="6000,8403,9913"; a="166898672" X-IronPort-AV: E=Sophos;i="5.81,224,1610438400"; d="scan'208";a="166898672" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2021 04:02:46 -0800 IronPort-SDR: OP/+SnY89MZvIbzgqkHxJy+nfFR1XESAGGXtefEMy26fr58yyn9UWSKvJMdBdsd/ymbAzNXoE3 xbuy9eRzpE/A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,224,1610438400"; d="scan'208";a="401656796" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 05 Mar 2021 04:02:44 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 117CB192; Fri, 5 Mar 2021 14:02:43 +0200 (EET) From: Andy Shevchenko To: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Marek Vasut , Roman Guskov Subject: [PATCH v1 1/1] gpiolib: Read "gpio-line-names" from a firmware node Date: Fri, 5 Mar 2021 14:02:40 +0200 Message-Id: <20210305120240.42830-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On STM32MP1, the GPIO banks are subnodes of pin-controller@50002000, see arch/arm/boot/dts/stm32mp151.dtsi. The driver for pin-controller@50002000 is in drivers/pinctrl/stm32/pinctrl-stm32.c and iterates over all of its DT subnodes when registering each GPIO bank gpiochip. Each gpiochip has: - gpio_chip.parent = dev, where dev is the device node of the pin controller - gpio_chip.of_node = np, which is the OF node of the GPIO bank Therefore, dev_fwnode(chip->parent) != of_fwnode_handle(chip.of_node), i.e. pin-controller@50002000 != pin-controller@50002000/gpio@5000*000. The original code behaved correctly, as it extracted the "gpio-line-names" from of_fwnode_handle(chip.of_node) = pin-controller@50002000/gpio@5000*000. To achieve the same behaviour, read property from the firmware node. Fixes: 7cba1a4d5e162 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties") Reported-by: Marek Vasut Reported-by: Roman Guskov Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 3bc25a9c4cd6..ba88011cc79d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -367,22 +367,18 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc) * * Looks for device property "gpio-line-names" and if it exists assigns * GPIO line names for the chip. The memory allocated for the assigned - * names belong to the underlying software node and should not be released + * names belong to the underlying firmware node and should not be released * by the caller. */ static int devprop_gpiochip_set_names(struct gpio_chip *chip) { struct gpio_device *gdev = chip->gpiodev; - struct device *dev = chip->parent; + struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev); const char **names; int ret, i; int count; - /* GPIO chip may not have a parent device whose properties we inspect. */ - if (!dev) - return 0; - - count = device_property_string_array_count(dev, "gpio-line-names"); + count = fwnode_property_string_array_count(fwnode, "gpio-line-names"); if (count < 0) return 0; @@ -396,7 +392,7 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip) if (!names) return -ENOMEM; - ret = device_property_read_string_array(dev, "gpio-line-names", + ret = fwnode_property_read_string_array(fwnode, "gpio-line-names", names, count); if (ret < 0) { dev_warn(&gdev->dev, "failed to read GPIO line names\n"); -- 2.30.1