summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-03-16 12:59:34 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-03-17 07:24:50 +0100
commite0899dfa3b15886d35280199e2dbd2d7810bf8b5 (patch)
tree195573943ed1cfdec389330e08049de9d271ed45 /drivers
parent0f3366ba853dafc6c2005771bcd1a97769f764dd (diff)
downloadbarebox-e0899dfa3b15886d35280199e2dbd2d7810bf8b5.tar.gz
barebox-e0899dfa3b15886d35280199e2dbd2d7810bf8b5.tar.xz
driver: Call remove function only when available
The bus implementations currently call the drivers remove hook unconditionally, but this hook is seldomly populated. Only call it when it's actually populated. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/platform.c3
-rw-r--r--drivers/i2c/i2c.c3
-rw-r--r--drivers/pci/bus.c3
-rw-r--r--drivers/spi/spi.c3
-rw-r--r--drivers/w1/w1.c3
5 files changed, 10 insertions, 5 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index e053ec7bbc..85bdfb0149 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -29,7 +29,8 @@ static int platform_probe(struct device_d *dev)
static void platform_remove(struct device_d *dev)
{
- dev->driver->remove(dev);
+ if (dev->driver->remove)
+ dev->driver->remove(dev);
}
int platform_driver_register(struct driver_d *drv)
diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 9873957015..7a6bde0f67 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -472,7 +472,8 @@ static int i2c_probe(struct device_d *dev)
static void i2c_remove(struct device_d *dev)
{
- dev->driver->remove(dev);
+ if (dev->driver->remove)
+ dev->driver->remove(dev);
}
struct bus_type i2c_bus = {
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 866ab08067..d6c5496ad7 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -51,7 +51,8 @@ static void pci_remove(struct device_d *dev)
struct pci_dev *pdev = to_pci_dev(dev);
struct pci_driver *pdrv = to_pci_driver(dev->driver);
- pdrv->remove(pdev);
+ if (pdrv->remove)
+ pdrv->remove(pdev);
}
struct bus_type pci_bus = {
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 8bddd98cf0..ba23cf7b93 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -311,7 +311,8 @@ static int spi_probe(struct device_d *dev)
static void spi_remove(struct device_d *dev)
{
- dev->driver->remove(dev);
+ if (dev->driver->remove)
+ dev->driver->remove(dev);
}
struct bus_type spi_bus = {
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index bbef470ba7..ff573860ea 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -392,7 +392,8 @@ static void w1_bus_remove(struct device_d *_dev)
struct w1_driver *drv = to_w1_driver(_dev->driver);
struct w1_device *dev = to_w1_device(_dev);
- return drv->remove(dev);
+ if (drv->remove)
+ drv->remove(dev);
}
struct bus_type w1_bustype= {