mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/3] driver: Call remove function only when available
Date: Tue, 17 Mar 2015 07:25:53 +0100	[thread overview]
Message-ID: <1426573554-14478-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1426573554-14478-1-git-send-email-s.hauer@pengutronix.de>

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>
---
 arch/efi/efi/efi-device.c | 3 ++-
 drivers/base/platform.c   | 3 ++-
 drivers/i2c/i2c.c         | 3 ++-
 drivers/pci/bus.c         | 3 ++-
 drivers/spi/spi.c         | 3 ++-
 drivers/w1/w1.c           | 3 ++-
 6 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/efi/efi/efi-device.c b/arch/efi/efi/efi-device.c
index 788bb71..7db8e48 100644
--- a/arch/efi/efi/efi-device.c
+++ b/arch/efi/efi/efi-device.c
@@ -328,7 +328,8 @@ static void efi_bus_remove(struct device_d *dev)
 	struct efi_driver *efidrv = to_efi_driver(dev->driver);
 	struct efi_device *efidev = to_efi_device(dev);
 
-	return efidrv->remove(efidev);
+	if (efidrv->remove)
+		efidrv->remove(efidev);
 }
 
 struct bus_type efi_bus = {
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index e053ec7..85bdfb0 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 9873957..7a6bde0 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 866ab08..d6c5496 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 8bddd98..ba23cf7 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 bbef470..ff57386 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= {
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2015-03-17  6:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-17  6:25 [PATCH 1/3] driver: fix device remove order Sascha Hauer
2015-03-17  6:25 ` Sascha Hauer [this message]
2015-03-17  6:25 ` [PATCH 3/3] driver: Call bus->remove instead of driver->remove Sascha Hauer
2015-05-02 16:50   ` Regression on next (Re: [PATCH 3/3] driver: Call bus->remove instead of driver->remove) Ezequiel Garcia
2015-05-04  6:29     ` Sascha Hauer
2015-05-05 11:44       ` Ezequiel Garcia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426573554-14478-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox