lkml.org 
[lkml]   [2014]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC v2 1/6] driver-core: generalize freeing driver private member
Date
From: "Luis R. Rodriguez" <mcgrof@suse.com>

This will be used later.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
drivers/base/bus.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 83e910a..a5f41e4 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -657,6 +657,15 @@ static ssize_t uevent_store(struct device_driver *drv, const char *buf,
}
static DRIVER_ATTR_WO(uevent);

+static void remove_driver_private(struct device_driver *drv)
+{
+ struct driver_private *priv = drv->p;
+
+ kobject_put(&priv->kobj);
+ kfree(priv);
+ drv->p = NULL;
+}
+
/**
* bus_add_driver - Add a driver to the bus.
* @drv: driver.
@@ -719,9 +728,7 @@ int bus_add_driver(struct device_driver *drv)
return 0;

out_unregister:
- kobject_put(&priv->kobj);
- kfree(drv->p);
- drv->p = NULL;
+ remove_driver_private(drv);
out_put_bus:
bus_put(bus);
return error;
--
2.0.3


\
 
 \ /
  Last update: 2014-09-05 09:01    [W:0.101 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site