Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp268171pxb; Sat, 10 Apr 2021 02:10:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIJIVuHbud05XphcAu9uTUWoripmIGfTXkaD93BZIZNDSYF2759kKa+1ZTQAL7XQICZenn X-Received: by 2002:a17:902:7203:b029:e6:a8b1:8d37 with SMTP id ba3-20020a1709027203b02900e6a8b18d37mr16724630plb.44.1618045829756; Sat, 10 Apr 2021 02:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618045829; cv=none; d=google.com; s=arc-20160816; b=JeoJF6+mEwaev5LjkzkhAWGsDitEt3TutT2c/56evwqWc1YJncvNodhyTxtUMaQ4ig SC8ceWNkb4CNGiYOh91wuHIbER2/WjZLsAKKoAawvs7yAbq8Ab22hhVy+53mp2zD26Ez Vi2LBmR8iobwsTL+fJ0007GB7fL2JhhrTv1vqiL6OEDctgi6rEiZZ56EhenQrsx/o4a2 9OQmQWrnb7utbcXKXireYyWZ1XskUnN1JAzdTCkzNd0AomE3yMMt/klhXHHYNnI1AEYi U47P9uoxPNobEF2zYHnqosYaOMUJAyx+TaQ1bK3xnc2w3NqxtT/hUCWqeBaSGoSalXoX TstQ== 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:dkim-signature; bh=p8aPX/yhyDURpzd9he2oFVc3UD257yU7cZPkDvSNwmA=; b=T921tVpfSVjCq3I8QxnRYV8xy/rpQfXKkXQN5NuhDjfZzMA4/a1E/xrTPoHvooOeBy DuJeIgh3KEYGbfR8BrUUHF2w44us4EsKhHsGiP08JN2sX+nA+iV1Z7zl7gXLuptC30Z2 NI8bff73Bv6ap8Pa1OCaw1h3egEg7BPWCNjA3A480w0+o6/3YgsevvlgMBUvxeQYDTqk IrrbBMuumDXv1CZTTCtB5vNWPp2btukB++QmqAZmnGITiO1uuwBYiTP/ejx1aNvUnWFN qXflk2df1sHlu0cdi7b1jq+9nz4DtbXcWIW7UStSym4dZYuKdIf1QnGagP6YAlnL9ifX QOuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=j8zUr5y1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b24si5683980pgw.41.2021.04.10.02.10.13; Sat, 10 Apr 2021 02:10:29 -0700 (PDT) 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; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=j8zUr5y1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229591AbhDJJJz (ORCPT + 99 others); Sat, 10 Apr 2021 05:09:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbhDJJJz (ORCPT ); Sat, 10 Apr 2021 05:09:55 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFF52C061762 for ; Sat, 10 Apr 2021 02:09:40 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5-20020a05600c0245b029011a8273f85eso4165464wmj.1 for ; Sat, 10 Apr 2021 02:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p8aPX/yhyDURpzd9he2oFVc3UD257yU7cZPkDvSNwmA=; b=j8zUr5y1aGMOckYxnzgWhcFZvHUB26DkBP3lqp4GNu50qv1KWM/VV+68cxPaQgL5Je Ju8UEj1Dnxb7sMT+qdfe1RgzE3k3mgb53UPIE5wutbGvwaJf5IiLh70HeZuuLOUWqKPh bRvnMalO6C+CfsyYJm9+ZxkC0G9A7YGlY0vdOPz31DNLVbBFmzjjxUQ4yH2cD1vwtrUz BpGm8tkC50O9w4bBSzzvJj+t1PryGF1Wew3hJ+ttv4uuA+jIHQVbccRpwRMKQOUHbvW4 zcx/iaxMPZ9Tlqt/wKG7V/X1FGIoBh3oX54O8iV/pgt2P5ttwEexvjncFmUDLTlUUQqb L7wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p8aPX/yhyDURpzd9he2oFVc3UD257yU7cZPkDvSNwmA=; b=nIMfTOB8NrcL4c52yc+GoMarmjT9oMWdswXQdN6W0y0RqVAIne6mtlT0pSsLoZpG19 sFbcTckJihhTGmuLmKl++8MnofQZ7jIGIvjfBQGbB3yneKhGjYMADGvsclOfZNSWBtRw i2t7ePOewdcMsQlMPXHTb6VOOVHKafZvCbr5ddexIC6IIquP60MKdExWU9YvN0jxkL/P ReAvn7A+TQGOzTJTs9zYzkTqwtMrL2caKzUnvPdm5SxRgrEJq6VNulxxNJz0vimKnNR/ 5SPUde1VlomsqjKx3jsI5JK22/UpiWlXlMkYwAOwsf2ub9dUO3C09kXFp1zrFe2TsO6V PMgQ== X-Gm-Message-State: AOAM533Gsd1VncTOkVWbirU3CpXK6q71K9PrpuYP/nJK25x9nVNrn8zD Vv37nmdpHi6jeP3MFE4DnY4ciw== X-Received: by 2002:a1c:a502:: with SMTP id o2mr12057387wme.16.1618045779784; Sat, 10 Apr 2021 02:09:39 -0700 (PDT) Received: from debian-brgl.home (lfbn-nic-1-149-6.w2-15.abo.wanadoo.fr. [2.15.231.6]) by smtp.gmail.com with ESMTPSA id h63sm6986094wmh.13.2021.04.10.02.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Apr 2021 02:09:39 -0700 (PDT) From: Bartosz Golaszewski To: Greg Kroah-Hartman Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko , stable@vger.kernel.org, Marek Vasut , Roman Guskov , Bartosz Golaszewski Subject: [PATCH stable] gpiolib: Read "gpio-line-names" from a firmware node Date: Sat, 10 Apr 2021 11:09:19 +0200 Message-Id: <20210410090919.3157-1-brgl@bgdev.pl> 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 From: Andy Shevchenko 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") Cc: stable@vger.kernel.org Reported-by: Marek Vasut Reported-by: Roman Guskov Signed-off-by: Andy Shevchenko Tested-by: Marek Vasut Reviewed-by: Marek Vasut Signed-off-by: Bartosz Golaszewski --- Hi Greg, This patch somehow got lost and never made its way into stable. Could you please apply it? Thanks, Bartosz 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 4253837f870b..7ec0822c0505 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