Skip to content

Commit

Permalink
bus: Make remove callback return void
Browse files Browse the repository at this point in the history
The driver core ignores the return value of this callback because there
is only little it can do when a device disappears.

This is the final bit of a long lasting cleanup quest where several
buses were converted to also return void from their remove callback.
Additionally some resource leaks were fixed that were caused by drivers
returning an error code in the expectation that the driver won't go
away.

With struct bus_type::remove returning void it's prevented that newly
implemented buses return an ignored error code and so don't anticipate
wrong expectations for driver authors.

Reviewed-by: Tom Rix <[email protected]> (For fpga)
Reviewed-by: Mathieu Poirier <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]> (For drivers/s390 and drivers/vfio)
Acked-by: Russell King (Oracle) <[email protected]> (For ARM, Amba and related parts)
Acked-by: Mark Brown <[email protected]>
Acked-by: Chen-Yu Tsai <[email protected]> (for sunxi-rsb)
Acked-by: Pali Rohár <[email protected]>
Acked-by: Mauro Carvalho Chehab <[email protected]> (for media)
Acked-by: Hans de Goede <[email protected]> (For drivers/platform)
Acked-by: Alexandre Belloni <[email protected]>
Acked-By: Vinod Koul <[email protected]>
Acked-by: Juergen Gross <[email protected]> (For xen)
Acked-by: Lee Jones <[email protected]> (For mfd)
Acked-by: Johannes Thumshirn <[email protected]> (For mcb)
Acked-by: Johan Hovold <[email protected]>
Acked-by: Srinivas Kandagatla <[email protected]> (For slimbus)
Acked-by: Kirti Wankhede <[email protected]> (For vfio)
Acked-by: Maximilian Luz <[email protected]>
Acked-by: Heikki Krogerus <[email protected]> (For ulpi and typec)
Acked-by: Samuel Iglesias Gonsálvez <[email protected]> (For ipack)
Acked-by: Geoff Levand <[email protected]> (For ps3)
Acked-by: Yehezkel Bernat <[email protected]> (For thunderbolt)
Acked-by: Alexander Shishkin <[email protected]> (For intel_th)
Acked-by: Dominik Brodowski <[email protected]> (For pcmcia)
Acked-by: Rafael J. Wysocki <[email protected]> (For ACPI)
Acked-by: Bjorn Andersson <[email protected]> (rpmsg and apr)
Acked-by: Srinivas Pandruvada <[email protected]> (For intel-ish-hid)
Acked-by: Dan Williams <[email protected]> (For CXL, DAX, and NVDIMM)
Acked-by: William Breathitt Gray <[email protected]> (For isa)
Acked-by: Stefan Richter <[email protected]> (For firewire)
Acked-by: Benjamin Tissoires <[email protected]> (For hid)
Acked-by: Thorsten Scherer <[email protected]> (For siox)
Acked-by: Sven Van Asbroeck <[email protected]> (For anybuss)
Acked-by: Ulf Hansson <[email protected]> (For MMC)
Acked-by: Wolfram Sang <[email protected]> # for I2C
Acked-by: Sudeep Holla <[email protected]>
Acked-by: Geert Uytterhoeven <[email protected]>
Acked-by: Dmitry Torokhov <[email protected]>
Acked-by: Finn Thain <[email protected]>
Signed-off-by: Uwe Kleine-König <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Uwe Kleine-König authored and gregkh committed Jul 21, 2021
1 parent 15f83bb commit fc7a620
Show file tree
Hide file tree
Showing 86 changed files with 93 additions and 243 deletions.
3 changes: 1 addition & 2 deletions arch/arm/common/locomo.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,14 +834,13 @@ static int locomo_bus_probe(struct device *dev)
return ret;
}

static int locomo_bus_remove(struct device *dev)
static void locomo_bus_remove(struct device *dev)
{
struct locomo_dev *ldev = LOCOMO_DEV(dev);
struct locomo_driver *drv = LOCOMO_DRV(dev->driver);

if (drv->remove)
drv->remove(ldev);
return 0;
}

struct bus_type locomo_bus_type = {
Expand Down
4 changes: 1 addition & 3 deletions arch/arm/common/sa1111.c
Original file line number Diff line number Diff line change
Expand Up @@ -1364,15 +1364,13 @@ static int sa1111_bus_probe(struct device *dev)
return ret;
}

static int sa1111_bus_remove(struct device *dev)
static void sa1111_bus_remove(struct device *dev)
{
struct sa1111_dev *sadev = to_sa1111_device(dev);
struct sa1111_driver *drv = SA1111_DRV(dev->driver);

if (drv->remove)
drv->remove(sadev);

return 0;
}

struct bus_type sa1111_bus_type = {
Expand Down
4 changes: 1 addition & 3 deletions arch/arm/mach-rpc/ecard.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ static int ecard_drv_probe(struct device *dev)
return ret;
}

static int ecard_drv_remove(struct device *dev)
static void ecard_drv_remove(struct device *dev)
{
struct expansion_card *ec = ECARD_DEV(dev);
struct ecard_driver *drv = ECARD_DRV(dev->driver);
Expand All @@ -1067,8 +1067,6 @@ static int ecard_drv_remove(struct device *dev)
ec->ops = &ecard_default_ops;
barrier();
ec->irq_data = NULL;

return 0;
}

/*
Expand Down
3 changes: 1 addition & 2 deletions arch/mips/sgi-ip22/ip22-gio.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,13 @@ static int gio_device_probe(struct device *dev)
return error;
}

static int gio_device_remove(struct device *dev)
static void gio_device_remove(struct device *dev)
{
struct gio_device *gio_dev = to_gio_device(dev);
struct gio_driver *drv = to_gio_driver(dev->driver);

if (dev->driver && drv->remove)
drv->remove(gio_dev);
return 0;
}

static void gio_device_shutdown(struct device *dev)
Expand Down
5 changes: 2 additions & 3 deletions arch/parisc/kernel/drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,13 @@ static int parisc_driver_probe(struct device *dev)
return rc;
}

static int __exit parisc_driver_remove(struct device *dev)
static void __exit parisc_driver_remove(struct device *dev)
{
struct parisc_device *pa_dev = to_parisc_device(dev);
struct parisc_driver *pa_drv = to_parisc_driver(dev->driver);

if (pa_drv->remove)
pa_drv->remove(pa_dev);

return 0;
}


Expand Down
3 changes: 1 addition & 2 deletions arch/powerpc/platforms/ps3/system-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ static int ps3_system_bus_probe(struct device *_dev)
return result;
}

static int ps3_system_bus_remove(struct device *_dev)
static void ps3_system_bus_remove(struct device *_dev)
{
struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
struct ps3_system_bus_driver *drv;
Expand All @@ -399,7 +399,6 @@ static int ps3_system_bus_remove(struct device *_dev)
__func__, __LINE__, drv->core.name);

pr_debug(" <- %s:%d: %s\n", __func__, __LINE__, dev_name(&dev->core));
return 0;
}

static void ps3_system_bus_shutdown(struct device *_dev)
Expand Down
3 changes: 1 addition & 2 deletions arch/powerpc/platforms/pseries/ibmebus.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,13 @@ static int ibmebus_bus_device_probe(struct device *dev)
return error;
}

static int ibmebus_bus_device_remove(struct device *dev)
static void ibmebus_bus_device_remove(struct device *dev)
{
struct platform_device *of_dev = to_platform_device(dev);
struct platform_driver *drv = to_platform_driver(dev->driver);

if (dev->driver && drv->remove)
drv->remove(of_dev);
return 0;
}

static void ibmebus_bus_device_shutdown(struct device *dev)
Expand Down
3 changes: 1 addition & 2 deletions arch/powerpc/platforms/pseries/vio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ static int vio_bus_probe(struct device *dev)
}

/* convert from struct device to struct vio_dev and pass to driver. */
static int vio_bus_remove(struct device *dev)
static void vio_bus_remove(struct device *dev)
{
struct vio_dev *viodev = to_vio_dev(dev);
struct vio_driver *viodrv = to_vio_driver(dev->driver);
Expand All @@ -1276,7 +1276,6 @@ static int vio_bus_remove(struct device *dev)
vio_cmo_bus_remove(viodev);

put_device(devptr);
return 0;
}

static void vio_bus_shutdown(struct device *dev)
Expand Down
4 changes: 1 addition & 3 deletions arch/sparc/kernel/vio.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static int vio_device_probe(struct device *dev)
return drv->probe(vdev, id);
}

static int vio_device_remove(struct device *dev)
static void vio_device_remove(struct device *dev)
{
struct vio_dev *vdev = to_vio_dev(dev);
struct vio_driver *drv = to_vio_driver(dev->driver);
Expand All @@ -107,8 +107,6 @@ static int vio_device_remove(struct device *dev)

drv->remove(vdev);
}

return 0;
}

static ssize_t devspec_show(struct device *dev,
Expand Down
3 changes: 1 addition & 2 deletions drivers/acpi/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ static int acpi_device_probe(struct device *dev)
return 0;
}

static int acpi_device_remove(struct device *dev)
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;
Expand All @@ -1034,7 +1034,6 @@ static int acpi_device_remove(struct device *dev)
acpi_dev->driver_data = NULL;

put_device(dev);
return 0;
}

struct bus_type acpi_bus_type = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/amba/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ static int amba_probe(struct device *dev)
return ret;
}

static int amba_remove(struct device *dev)
static void amba_remove(struct device *dev)
{
struct amba_device *pcdev = to_amba_device(dev);
struct amba_driver *drv = to_amba_driver(dev->driver);
Expand All @@ -236,8 +236,6 @@ static int amba_remove(struct device *dev)

amba_put_disable_pclk(pcdev);
dev_pm_domain_detach(dev, true);

return 0;
}

static void amba_shutdown(struct device *dev)
Expand Down
4 changes: 1 addition & 3 deletions drivers/base/auxiliary.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,14 @@ static int auxiliary_bus_probe(struct device *dev)
return ret;
}

static int auxiliary_bus_remove(struct device *dev)
static void auxiliary_bus_remove(struct device *dev)
{
struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
struct auxiliary_device *auxdev = to_auxiliary_dev(dev);

if (auxdrv->remove)
auxdrv->remove(auxdev);
dev_pm_domain_detach(dev, true);

return 0;
}

static void auxiliary_bus_shutdown(struct device *dev)
Expand Down
4 changes: 1 addition & 3 deletions drivers/base/isa.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,12 @@ static int isa_bus_probe(struct device *dev)
return 0;
}

static int isa_bus_remove(struct device *dev)
static void isa_bus_remove(struct device *dev)
{
struct isa_driver *isa_driver = dev->platform_data;

if (isa_driver && isa_driver->remove)
isa_driver->remove(dev, to_isa_dev(dev)->id);

return 0;
}

static void isa_bus_shutdown(struct device *dev)
Expand Down
4 changes: 1 addition & 3 deletions drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ static int platform_probe(struct device *_dev)
return ret;
}

static int platform_remove(struct device *_dev)
static void platform_remove(struct device *_dev)
{
struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev);
Expand All @@ -1450,8 +1450,6 @@ static int platform_remove(struct device *_dev)
dev_warn(_dev, "remove callback returned a non-zero value. This will be ignored.\n");
}
dev_pm_domain_detach(_dev, true);

return 0;
}

static void platform_shutdown(struct device *_dev)
Expand Down
6 changes: 2 additions & 4 deletions drivers/bcma/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static DEFINE_MUTEX(bcma_buses_mutex);

static int bcma_bus_match(struct device *dev, struct device_driver *drv);
static int bcma_device_probe(struct device *dev);
static int bcma_device_remove(struct device *dev);
static void bcma_device_remove(struct device *dev);
static int bcma_device_uevent(struct device *dev, struct kobj_uevent_env *env);

static ssize_t manuf_show(struct device *dev, struct device_attribute *attr, char *buf)
Expand Down Expand Up @@ -614,7 +614,7 @@ static int bcma_device_probe(struct device *dev)
return err;
}

static int bcma_device_remove(struct device *dev)
static void bcma_device_remove(struct device *dev)
{
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
struct bcma_driver *adrv = container_of(dev->driver, struct bcma_driver,
Expand All @@ -623,8 +623,6 @@ static int bcma_device_remove(struct device *dev)
if (adrv->remove)
adrv->remove(core);
put_device(dev);

return 0;
}

static int bcma_device_uevent(struct device *dev, struct kobj_uevent_env *env)
Expand Down
4 changes: 1 addition & 3 deletions drivers/bus/sunxi-rsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,11 @@ static int sunxi_rsb_device_probe(struct device *dev)
return drv->probe(rdev);
}

static int sunxi_rsb_device_remove(struct device *dev)
static void sunxi_rsb_device_remove(struct device *dev)
{
const struct sunxi_rsb_driver *drv = to_sunxi_rsb_driver(dev->driver);

drv->remove(to_sunxi_rsb_device(dev));

return 0;
}

static struct bus_type sunxi_rsb_bus = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/cxl/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,13 +1034,12 @@ static int cxl_bus_probe(struct device *dev)
return to_cxl_drv(dev->driver)->probe(dev);
}

static int cxl_bus_remove(struct device *dev)
static void cxl_bus_remove(struct device *dev)
{
struct cxl_driver *cxl_drv = to_cxl_drv(dev->driver);

if (cxl_drv->remove)
cxl_drv->remove(dev);
return 0;
}

struct bus_type cxl_bus_type = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/dax/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,13 @@ static int dax_bus_probe(struct device *dev)
return 0;
}

static int dax_bus_remove(struct device *dev)
static void dax_bus_remove(struct device *dev)
{
struct dax_device_driver *dax_drv = to_dax_drv(dev->driver);
struct dev_dax *dev_dax = to_dev_dax(dev);

if (dax_drv->remove)
dax_drv->remove(dev_dax);

return 0;
}

static struct bus_type dax_bus_type = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/dma/idxd/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static void disable_wq(struct idxd_wq *wq)
dev_info(dev, "wq %s disabled\n", dev_name(&wq->conf_dev));
}

static int idxd_config_bus_remove(struct device *dev)
static void idxd_config_bus_remove(struct device *dev)
{
int rc;

Expand Down Expand Up @@ -305,8 +305,6 @@ static int idxd_config_bus_remove(struct device *dev)
dev_info(dev, "Device %s disabled\n", dev_name(dev));

}

return 0;
}

static void idxd_config_bus_shutdown(struct device *dev)
Expand Down
4 changes: 1 addition & 3 deletions drivers/firewire/core-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,12 @@ static int fw_unit_probe(struct device *dev)
return driver->probe(fw_unit(dev), unit_match(dev, dev->driver));
}

static int fw_unit_remove(struct device *dev)
static void fw_unit_remove(struct device *dev)
{
struct fw_driver *driver =
container_of(dev->driver, struct fw_driver, driver);

driver->remove(fw_unit(dev));

return 0;
}

static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size)
Expand Down
4 changes: 1 addition & 3 deletions drivers/firmware/arm_scmi/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,13 @@ static int scmi_dev_probe(struct device *dev)
return scmi_drv->probe(scmi_dev);
}

static int scmi_dev_remove(struct device *dev)
static void scmi_dev_remove(struct device *dev)
{
struct scmi_driver *scmi_drv = to_scmi_driver(dev->driver);
struct scmi_device *scmi_dev = to_scmi_dev(dev);

if (scmi_drv->remove)
scmi_drv->remove(scmi_dev);

return 0;
}

static struct bus_type scmi_bus_type = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/firmware/google/coreboot_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ static int coreboot_bus_probe(struct device *dev)
return ret;
}

static int coreboot_bus_remove(struct device *dev)
static void coreboot_bus_remove(struct device *dev)
{
struct coreboot_device *device = CB_DEV(dev);
struct coreboot_driver *driver = CB_DRV(dev->driver);

if (driver->remove)
driver->remove(device);

return 0;
}

static struct bus_type coreboot_bus_type = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/fpga/dfl.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,13 @@ static int dfl_bus_probe(struct device *dev)
return ddrv->probe(ddev);
}

static int dfl_bus_remove(struct device *dev)
static void dfl_bus_remove(struct device *dev)
{
struct dfl_driver *ddrv = to_dfl_drv(dev->driver);
struct dfl_device *ddev = to_dfl_dev(dev);

if (ddrv->remove)
ddrv->remove(ddev);

return 0;
}

static int dfl_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
Expand Down
Loading

0 comments on commit fc7a620

Please sign in to comment.