On Tue, Jun 23, 2020 at 9:01 PM Vasily Averin <vvs@xxxxxxxxxxxxx> wrote: > > On 6/23/20 7:29 PM, Rafael J. Wysocki wrote: > > On Tuesday, June 23, 2020 1:17:43 AM CEST Vasily Averin wrote: > >> v2: followed to rafael@'s proposal > >> Fixes: edf5bf34d408 ("ACPI / dock: Use callback pointers from devices' ACPI hotplug contexts") > >> Signed-off-by: Vasily Averin <vvs@xxxxxxxxxxxxx> > > Thanks for following my suggestion, but it occurred to me that it could still be > > done in a better way. > > > > So instead of the above I'd prefer to apply the following change (added PCI and Bjorn > > for visibility): > > Thank you, > however could you please tell me what do you think about following variant? > > drivers/pci/hotplug/acpiphp_glue.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c > index b4c92cee13f8..5875c3654b52 100644 > --- a/drivers/pci/hotplug/acpiphp_glue.c > +++ b/drivers/pci/hotplug/acpiphp_glue.c > @@ -119,16 +119,17 @@ static inline void put_bridge(struct acpiphp_bridge *bridge) > > static struct acpiphp_context *acpiphp_grab_context(struct acpi_device *adev) > { > - struct acpiphp_context *context; > + struct acpiphp_context *c, *context = NULL; > > acpi_lock_hp_context(); > - context = acpiphp_get_context(adev); > - if (!context || context->func.parent->is_going_away) { > - acpi_unlock_hp_context(); > - return NULL; > + c = acpiphp_get_context(adev); > + if (c) { > + if (c->func.parent->is_going_away == false) { > + get_bridge(c->func.parent); > + context = c; > + } > + acpiphp_put_context(c); > } > - get_bridge(context->func.parent); > - acpiphp_put_context(context); > acpi_unlock_hp_context(); > return context; > } There are reasons to do it the way I want: - The indentation level is minimum. - The real purpose of this function is to get a parent bridge reference, so that needs to be the central piece of it rather than the checks for exceptional cases. - The second local var is not necessary. Thanks!