Message ID | 20220618112311.14661-1-u.kleine-koenig@pengutronix.de (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
Series | [1/2] ACPI: Drop redundant check in acpi_device_remove() | expand |
On Sat, Jun 18, 2022 at 1:23 PM Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: > > A bus remove callback is only ever called by the device core with a > bound driver. So there is no need to check if the driver is non-NULL. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- > drivers/acpi/bus.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c > index 86fa61a21826..67a3f8cf42f9 100644 > --- a/drivers/acpi/bus.c > +++ b/drivers/acpi/bus.c > @@ -1062,12 +1062,11 @@ static void acpi_device_remove(struct device *dev) > struct acpi_device *acpi_dev = to_acpi_device(dev); > struct acpi_driver *acpi_drv = acpi_dev->driver; > > - if (acpi_drv) { > - if (acpi_drv->ops.notify) > - acpi_device_remove_notify_handler(acpi_dev); > - if (acpi_drv->ops.remove) > - acpi_drv->ops.remove(acpi_dev); > - } > + if (acpi_drv->ops.notify) > + acpi_device_remove_notify_handler(acpi_dev); > + if (acpi_drv->ops.remove) > + acpi_drv->ops.remove(acpi_dev); > + > acpi_dev->driver = NULL; > acpi_dev->driver_data = NULL; > > > base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56 > -- Applied (with minor modifications) as 5.20 material along with the [2/2]. Thanks!
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 86fa61a21826..67a3f8cf42f9 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1062,12 +1062,11 @@ static void acpi_device_remove(struct device *dev) struct acpi_device *acpi_dev = to_acpi_device(dev); struct acpi_driver *acpi_drv = acpi_dev->driver; - if (acpi_drv) { - if (acpi_drv->ops.notify) - acpi_device_remove_notify_handler(acpi_dev); - if (acpi_drv->ops.remove) - acpi_drv->ops.remove(acpi_dev); - } + if (acpi_drv->ops.notify) + acpi_device_remove_notify_handler(acpi_dev); + if (acpi_drv->ops.remove) + acpi_drv->ops.remove(acpi_dev); + acpi_dev->driver = NULL; acpi_dev->driver_data = NULL;
A bus remove callback is only ever called by the device core with a bound driver. So there is no need to check if the driver is non-NULL. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/acpi/bus.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56