diff mbox series

[2/8] ACPI: PM: Use the new device_to_pm() helper to access struct dev_pm_ops

Message ID 20200525182608.1823735-3-kw@linux.com (mailing list archive)
State Not Applicable, archived
Delegated to: Bjorn Helgaas
Headers show
Series Add helper for accessing Power Management callbacs | expand

Commit Message

Krzysztof Wilczyński May 25, 2020, 6:26 p.m. UTC
Use the new device_to_pm() helper to access Power Management callbacs
(struct dev_pm_ops) for a particular device (struct device_driver).

No functional change intended.

Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
---
 drivers/acpi/device_pm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Rafael J. Wysocki May 26, 2020, 8:37 a.m. UTC | #1
On Mon, May 25, 2020 at 8:26 PM Krzysztof Wilczyński <kw@linux.com> wrote:
>
> Use the new device_to_pm() helper to access Power Management callbacs
> (struct dev_pm_ops) for a particular device (struct device_driver).
>
> No functional change intended.
>
> Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
> ---
>  drivers/acpi/device_pm.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
> index 5832bc10aca8..b98a32c48fbe 100644
> --- a/drivers/acpi/device_pm.c
> +++ b/drivers/acpi/device_pm.c
> @@ -1022,9 +1022,10 @@ static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev)
>  int acpi_subsys_prepare(struct device *dev)
>  {
>         struct acpi_device *adev = ACPI_COMPANION(dev);
> +       const struct dev_pm_ops *pm = driver_to_pm(dev->driver);

I don't really see a reason for this change.

What's wrong with the check below?

>
> -       if (dev->driver && dev->driver->pm && dev->driver->pm->prepare) {
> -               int ret = dev->driver->pm->prepare(dev);
> +       if (pm && pm->prepare) {
> +               int ret = pm->prepare(dev);
>
>                 if (ret < 0)
>                         return ret;
> --
> 2.26.2
>
Pavel Machek May 26, 2020, 9:45 a.m. UTC | #2
On Tue 2020-05-26 10:37:36, Rafael J. Wysocki wrote:
> On Mon, May 25, 2020 at 8:26 PM Krzysztof Wilczyński <kw@linux.com> wrote:
> >
> > Use the new device_to_pm() helper to access Power Management callbacs
> > (struct dev_pm_ops) for a particular device (struct device_driver).
> >
> > No functional change intended.
> >
> > Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
> > ---
> >  drivers/acpi/device_pm.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
> > index 5832bc10aca8..b98a32c48fbe 100644
> > --- a/drivers/acpi/device_pm.c
> > +++ b/drivers/acpi/device_pm.c
> > @@ -1022,9 +1022,10 @@ static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev)
> >  int acpi_subsys_prepare(struct device *dev)
> >  {
> >         struct acpi_device *adev = ACPI_COMPANION(dev);
> > +       const struct dev_pm_ops *pm = driver_to_pm(dev->driver);
> 
> I don't really see a reason for this change.
> 
> What's wrong with the check below?

Duplicated code. Yes, compiler can sort it out, but... new version
looks better to me.

Best regards,
								pavel

> >
> > -       if (dev->driver && dev->driver->pm && dev->driver->pm->prepare) {
> > -               int ret = dev->driver->pm->prepare(dev);
> > +       if (pm && pm->prepare) {
> > +               int ret = pm->prepare(dev);
Rafael J. Wysocki May 26, 2020, 10:35 a.m. UTC | #3
On Tue, May 26, 2020 at 11:45 AM Pavel Machek <pavel@denx.de> wrote:
>
> On Tue 2020-05-26 10:37:36, Rafael J. Wysocki wrote:
> > On Mon, May 25, 2020 at 8:26 PM Krzysztof Wilczyński <kw@linux.com> wrote:
> > >
> > > Use the new device_to_pm() helper to access Power Management callbacs
> > > (struct dev_pm_ops) for a particular device (struct device_driver).
> > >
> > > No functional change intended.
> > >
> > > Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
> > > ---
> > >  drivers/acpi/device_pm.c | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
> > > index 5832bc10aca8..b98a32c48fbe 100644
> > > --- a/drivers/acpi/device_pm.c
> > > +++ b/drivers/acpi/device_pm.c
> > > @@ -1022,9 +1022,10 @@ static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev)
> > >  int acpi_subsys_prepare(struct device *dev)
> > >  {
> > >         struct acpi_device *adev = ACPI_COMPANION(dev);
> > > +       const struct dev_pm_ops *pm = driver_to_pm(dev->driver);
> >
> > I don't really see a reason for this change.
> >
> > What's wrong with the check below?
>
> Duplicated code. Yes, compiler can sort it out, but... new version
> looks better to me.

So the new code would not be duplicated?

Look at the other patches in the series then. :-)
diff mbox series

Patch

diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 5832bc10aca8..b98a32c48fbe 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -1022,9 +1022,10 @@  static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev)
 int acpi_subsys_prepare(struct device *dev)
 {
 	struct acpi_device *adev = ACPI_COMPANION(dev);
+	const struct dev_pm_ops *pm = driver_to_pm(dev->driver);
 
-	if (dev->driver && dev->driver->pm && dev->driver->pm->prepare) {
-		int ret = dev->driver->pm->prepare(dev);
+	if (pm && pm->prepare) {
+		int ret = pm->prepare(dev);
 
 		if (ret < 0)
 			return ret;