All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Devyn Liu <liudingyuan@huawei.com>,
	Benjamin Tissoires <bentiss@kernel.org>
Cc: linus.walleij@linaro.org, brgl@bgdev.pl, f.fangjian@huawei.com,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	mika.westerberg@linux.intel.com, linux-acpi@vger.kernel.org,
	jonathan.cameron@huawei.com, yangyicong@huawei.com,
	yisen.zhuang@huawei.com, kong.kongxinwei@hisilicon.com
Subject: Re: [PATCH] gpiolib: acpi: Fix failed in acpi_gpiochip_find() by adding parent node match
Date: Mon, 13 May 2024 12:25:50 +0300	[thread overview]
Message-ID: <ZkHcniqCiLPEPN9o@smile.fi.intel.com> (raw)
In-Reply-To: <20240513075901.2030293-1-liudingyuan@huawei.com>

On Mon, May 13, 2024 at 03:59:01PM +0800, Devyn Liu wrote:
> Previous patch modified the standard used by acpi_gpiochip_find()
> to match device nodes. Using the device node set in gc->gpiodev->d-
> ev instead of gc->parent.
> 
> However, there is a situation in gpio-dwapb where the GPIO device
> driver will set gc->fwnode for each port corresponding to a child
> node under a GPIO device, so gc->gpiodev->dev will be assigned the
> value of each child node in gpiochip_add_data().
> 
> gpio-dwapb.c:
> 128,31 static int dwapb_gpio_add_port(struct dwapb_gpio *gpio,
> 			       struct dwapb_port_property *pp,
> 			       unsigned int offs);
> port->gc.fwnode = pp->fwnode;
> 
> 693,39 static int dwapb_gpio_probe;
> err = dwapb_gpio_add_port(gpio, &pdata->properties[i], i);
> 
> When other drivers request GPIO pin resources through the GPIO device
> node provided by ACPI (corresponding to the parent node), the change
> of the matching object to gc->gpiodev->dev in acpi_gpiochip_find()
> only allows finding the value of each port (child node), resulting
> in a failed request.
> 
> Reapply the condition of using gc->parent for match in acpi_gpio-
> chip_find() in the code can compatible with the problem of gpio-dwapb,
> and will not affect the two cases mentioned in the patch:
> 1. There is no setting for gc->fwnode.
> 2. The case that depends on using gc->fwnode for match.

Thanks for the report, analysis, and patch.

...

>  static int acpi_gpiochip_find(struct gpio_chip *gc, const void *data)
>  {
> -	return device_match_acpi_handle(&gc->gpiodev->dev, data);
> +	return device_match_acpi_handle(&gc->gpiodev->dev, data) ||
> +		(gc->parent && device_match_acpi_handle(gc->parent, data));
>  }

I'm wondering if the below approach will work for all:

static int acpi_gpiochip_find(struct gpio_chip *gc, const void *data)
{
	struct device *dev = acpi_get_first_physical_node(ACPI_COMPANION(&gc->gpiodev->dev));

	return device_match_acpi_handle(dev, data);
}

Cc'ing to Benjamin for testing and commenting.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-05-13  9:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13  7:59 [PATCH] gpiolib: acpi: Fix failed in acpi_gpiochip_find() by adding parent node match Devyn Liu
2024-05-13  9:25 ` Andy Shevchenko [this message]
2024-05-13 15:43   ` Benjamin Tissoires
2024-05-20  4:37 ` Mika Westerberg
2024-05-21 15:47   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZkHcniqCiLPEPN9o@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bentiss@kernel.org \
    --cc=brgl@bgdev.pl \
    --cc=f.fangjian@huawei.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=kong.kongxinwei@hisilicon.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liudingyuan@huawei.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=yangyicong@huawei.com \
    --cc=yisen.zhuang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.