[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YbI0t2D5ute46Ty2@smile.fi.intel.com>
Date: Thu, 9 Dec 2021 18:54:15 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Bjorn Helgaas <helgaas@...nel.org>
Cc: Greg KH <gregkh@...uxfoundation.org>,
Lee Jones <lee.jones@...aro.org>,
Leon Romanovsky <leon@...nel.org>,
"David E. Box" <david.e.box@...ux.intel.com>, hdegoede@...hat.com,
bhelgaas@...gle.com, srinivas.pandruvada@...el.com,
shuah@...nel.org, mgross@...ux.intel.com,
linux-kernel@...r.kernel.org, platform-driver-x86@...r.kernel.org,
linux-kselftest@...r.kernel.org, linux-pci@...r.kernel.org,
"Rafael J. Wysocki" <rjw@...ysocki.net>
Subject: Re: [V2 2/6] driver core: auxiliary bus: Add driver data helpers
On Thu, Dec 09, 2021 at 10:32:45AM -0600, Bjorn Helgaas wrote:
> [+cc Rafael, since I used generic PM as an example]
> On Wed, Dec 08, 2021 at 09:47:56AM +0100, Greg KH wrote:
...
Okay, more bikeshedding :-)
> In the very common situation of PCI drivers that use generic power
> management, authors *do* have to use both (example from [1]):
>
> ioh_gpio_probe(struct pci_dev *pdev) # pci_driver.probe()
> pci_set_drvdata(pdev, chip);
>
> ioh_gpio_remove(struct pci_dev *pdev) # pci_driver.remove()
> struct ioh_gpio *chip = pci_get_drvdata(pdev);
>
> ioh_gpio_suspend(struct device *dev) # pci_driver.driver.pm.suspend()
> struct ioh_gpio *chip = dev_get_drvdata(dev); <--
>
> The pci_driver methods receive a struct pci_dev and use the
> pci_get_drvdata() wrapper.
>
> The generic power management methods receive a struct device and use
> the underlying dev_get_drvdata().
>
> It's kind of ugly that readers have to know that pci_get_drvdata()
> gives you the same thing as dev_get_drvdata().
>
> I guess the generic PM methods could do something like:
>
> pci_get_drvdata(to_pci_dev(dev));
>
> but that seems a little bit circuitous. It's slightly wordier, but I
> might prefer to just use this everywhere and skip the pci_* wrappers:
>
> dev_get_drvdata(&pdev->dev);
Strictly speaking the
<$BUS)_get_drvdata(<$CONTAINER>) != dev_get_drvdata(dev)
it's completely up to the container handling code what to do.
In 99% (or 100%?) cases it's equal, but it's not obliged to be so.
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpio/gpio-ml-ioh.c?id=v5.15#n505
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists