Re: [PATCH v1 2/7] ACPI: PM: Introduce acpi_device_init_power()

From: Rafael J. Wysocki (Intel)

Date: Tue Sep 01 2026 - 12:50:26 EST


On Tue, Sep 1, 2026 at 10:29 AM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Mon, Aug 31, 2026 at 06:25:52PM +0200, Rafael J. Wysocki wrote:
>
> > Two out of three callers of acpi_bus_init_power() need to clear
> > flags.power_manageable for the target device on errors, which
> > is somewhat cumbersome, so rename the function to
> > __acpi_device_init_power(), add a wrapper called
> > acpi_device_init_power() around it that will take care
> > of the flags.power_manageable clearing, and make the two
> > callers of acpi_bus_init_power() in question invoke that
> > wrapper.
> >
> > While at it, clean up the declaration of local variables
> > in __acpi_device_init_power().
>
> ...
>
> > {
> > - int state;
> > - int result;
> > + int result, state;
>
> Not sure if this change is required.

Nope, but I think that it's useful.

> > result = acpi_device_get_power(device, &state);
> > if (result)
>
> ...
>
> > +int acpi_device_init_power(struct acpi_device *device)
>
> Ah, here is a helper!

Yeah, I guess it's better to fold it into the first patch.

> > +{
> > + int ret;
>
> Elsewhere in the file it's called 'result'.

Yes, it is.

So I guess you're suggesting to also use that name here, which is fair enough.

> > +
> > + ret = __acpi_device_init_power(device);
> > + if (ret)
> > + device->flags.power_manageable = 0;
> > +
> > + return ret;
> > +}