Re: [PATCH 5/7] PCI/PM: Make power management op coding style consistent

From: Dan Carpenter
Date: Wed Oct 16 2019 - 09:52:53 EST


On Mon, Oct 14, 2019 at 06:00:14PM -0500, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
>
> Some of the power management ops use this style:
>
> struct device_driver *drv = dev->driver;
> if (drv && drv->pm && drv->pm->prepare(dev))
> drv->pm->prepare(dev);
>
> while others use this:
>
> const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;

I like this patch a lot, especially the direct returns. But it
occurs to me that in the future this conditional would look better as

const struct dev_pm_ops *pm = driver_to_pm(dev->driver);

or something.

regards,
dan carpenter