Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1424217pxb; Sun, 7 Mar 2021 18:44:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJx71T7KUhJVPxnzysmrF0EuF8liDNJrObn/SmAGGeCWqIV7nHIIbohctSUtkM62fusUeIBd X-Received: by 2002:a05:6402:b48:: with SMTP id bx8mr20679888edb.162.1615171460270; Sun, 07 Mar 2021 18:44:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615171460; cv=none; d=google.com; s=arc-20160816; b=L/etUntVjM5X7kFpwDqYuNIwlZyySl/zRt2udqirsJ12jKMDfvR5OiXUx/e+swtcU4 EDkCqJNu1GG6Bukjg25ROsLcOiLlPENUfXSz5Ztd6HEFGQzjoZSy/m0BiPgcklIIV0iQ StrOY+fJZxsPqVp8gzJrOpVHNPK1Ii3/XCyj85DNuBNzo60SO26PR+95UPZipB5USTr2 kWxZhV6YqdB/XDX+I259ba1k7A3E2xxG4HSac8FTWJeT0kAMa4gyoC1XNV4Bcs+1R4Eb 2l5ATLWhjeWvar+x5rHsawY6BJSAYCoAO1Ez4f0jmsJkPjEaZHs7G/eDokVDECF38kzA 25uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dqYPDrvULCWuDLLiROQSM7KZ6r9QBZIFlqyHz32fU3Q=; b=HNU4Hy9ZEUDFmw6NzznkcWswnUfipYtrYHXrWpV3KNP5iqFzCxGqV01X1FpK/CHS/x BKv9UtAbe9XnMtIu89wW2Bgokc2Ud6l+NjMlev9al218eGJjUZ2UhPlvQF/m6WVWtnAJ neMaHZ7Zu9lLGVAA+E6shzKOXducFEo8M5VCPzxN8jOLJ5RdvIb/gC7MEDD6zfIoIvt/ Dz+vDvvqmTXSgbXOFuuahCSoJQHXJbh+IGE15ifVCzudiN3GBrRa2PSxKA0Eu+LtD4n/ R9My+bXhWIAxKD8B5zj38IowPfakzIcymL4EWXXEinDdgfl1GbbVE3Q3XN/XKKkr8pKz tC+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="VD2/Om/q"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w21si5856815ejb.465.2021.03.07.18.43.58; Sun, 07 Mar 2021 18:44:20 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="VD2/Om/q"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232377AbhCGQPY (ORCPT + 99 others); Sun, 7 Mar 2021 11:15:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232383AbhCGQPH (ORCPT ); Sun, 7 Mar 2021 11:15:07 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A4E8C06174A; Sun, 7 Mar 2021 08:15:06 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id s7so3703930plg.5; Sun, 07 Mar 2021 08:15:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dqYPDrvULCWuDLLiROQSM7KZ6r9QBZIFlqyHz32fU3Q=; b=VD2/Om/q53mjKBnvfyCtORYsezDqpSVjzNabmtzRkNe0gCEW8lyX/fSXPzQwhu0vvV djyL/kOUiw/K7J7WttKTNgbx/qwEcYMg5tIqto8+ucHRaXkU3W0Q9Ciwo3am/lxGibHv HXEYTNk41JsGhCH2kB6FcTxfOazrfXz4Z5P49cXanMkm0og8eDK9X+by1Am93iRvkIaI 8M/ScwpW+tW40aX+1ecQy38tF14mDnUssrLq4eowwfg1YH5c4MZSUV3Sg3z0Ltqnnf5m VSBqTdvgaB0ItX8blJfzvRUukz8sJj8VWvJxIezjtIIaHtD3K9CovJttMMHO3QIV9iFP 11VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dqYPDrvULCWuDLLiROQSM7KZ6r9QBZIFlqyHz32fU3Q=; b=aVqUf/abcTTkCsCUzrxCBU+kV+/3CmGpnDCXy9cc1UF9ualtDiRXhpjkVjD10oH2MG SwoZb2YZ6nU1i+P4uEvIxn+xEqI3iEmuIBASr0wZeY68dlzVMw7g5wxJm/wz4XjwXwew WWYSLltxx0KyED6JHqN2h4g51UZnKS8X+hpTyJSzprL/fdJ9Jh2T7RhdpB6MNGtBdBF/ ubGUk+OfW5PAVvFw8il8S+oqlWogVlaX41kwGQEJm5JPQ3X5jECm5rbNkr2cY7MHYttq Lmwsa47q/syjlBah87SJvXVYgDE/+SBYDbOQ0TJiT7RuVHXfKt4ezuBkYV1zh0xdQiYm gtZA== X-Gm-Message-State: AOAM533amk5L9J/67jlv2BuQUMITmw5Tm0pweLOmzr/VXVCa3RKm82c4 yZCOX9WifoDtBrs3cJ0ZM8QoWjtj3djpMjklsdg= X-Received: by 2002:a17:90a:4586:: with SMTP id v6mr19645953pjg.129.1615133705330; Sun, 07 Mar 2021 08:15:05 -0800 (PST) MIME-Version: 1.0 References: <20210305120240.42830-1-andriy.shevchenko@linux.intel.com> In-Reply-To: From: Andy Shevchenko Date: Sun, 7 Mar 2021 18:14:49 +0200 Message-ID: Subject: Re: [PATCH v1 1/1] gpiolib: Read "gpio-line-names" from a firmware node To: Bartosz Golaszewski Cc: Andy Shevchenko , linux-gpio , LKML , Linus Walleij , Marek Vasut , Roman Guskov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 7, 2021 at 4:22 PM Bartosz Golaszewski wrote: > > On Fri, Mar 5, 2021 at 1:02 PM Andy Shevchenko > wrote: > > > > 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 > > > > Did you run the OF unit tests on this? The check for the parent dev > was added after a bug was reported that was only triggered in unit > tests. Parent is not used anymore. But I can run unittests next week (or if you know that they are failing now, can you please show the failure?). -- With Best Regards, Andy Shevchenko