summaryrefslogtreecommitdiff
path: root/datapath/dp_sysfs_dp.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2009-08-05 13:45:13 -0700
committerBen Pfaff <blp@nicira.com>2009-08-06 16:57:06 -0700
commit3de35df914e39692470a5d4546cb1fae2d93a316 (patch)
tree9d11e565a201752828b7c1e23fb7ae5ca80edfa5 /datapath/dp_sysfs_dp.c
parent2ba9026e2fc114fa50ae923312340e9f08a1f513 (diff)
downloadopenvswitch-3de35df914e39692470a5d4546cb1fae2d93a316.tar.gz
datapath: Prepare to extend lifetime of kobjects.
The following commit will move the initialization of the datapath and net_bridge_port kobjects earlier and the destruction later, without changing when those kobjects are attached to sysfs. To do so, the initialization of kobjects and attaching to sysfs has to be done as separate steps. That's already the case for net_bridge_port kobjects, and this commit makes it so for datapath kobjects too. This commit also simplifies some code, since the split API exists both before and after 2.6.25, but the combined functions changed names. Also, in dp_sysfs_add_if() call kobject_init() after initializing the kset member, since kobject_init() expects that. This makes no actual difference in this case since the kobj is obtained from kzalloc(), but it still seems better.
Diffstat (limited to 'datapath/dp_sysfs_dp.c')
-rw-r--r--datapath/dp_sysfs_dp.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/datapath/dp_sysfs_dp.c b/datapath/dp_sysfs_dp.c
index 714a4b2ef..5764a3a35 100644
--- a/datapath/dp_sysfs_dp.c
+++ b/datapath/dp_sysfs_dp.c
@@ -487,26 +487,19 @@ int dp_sysfs_add_dp(struct datapath *dp)
}
/* Create /sys/class/net/<devname>/bridge directory. */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
kobject_set_name(&dp->ifobj, SYSFS_BRIDGE_PORT_SUBDIR); /* "bridge" */
dp->ifobj.ktype = NULL;
dp->ifobj.kset = NULL;
dp->ifobj.parent = kobj;
+ kboject_init(&dp->ifobj);
- err = kobject_register(&dp->ifobj);
+ err = kobject_add(&dp->ifobj);
if (err) {
pr_info("%s: can't add kobject (directory) %s/%s\n",
__FUNCTION__, dp_name(dp), dp->ifobj.name);
goto out2;
}
-#else
- br->ifobj = kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR, kobj);
- if (!br->ifobj) {
- pr_info("%s: can't add kobject (directory) %s/%s\n",
- __func__, dp_name(dp), SYSFS_BRIDGE_PORT_SUBDIR);
- goto out2;
- }
-#endif
+ kobject_uevent(&dp->ifobj, KOBJ_ADD);
return 0;
out2:
@@ -519,11 +512,8 @@ int dp_sysfs_del_dp(struct datapath *dp)
{
struct kobject *kobj = to_kobj(dp->ports[ODPP_LOCAL]->dev);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
- kobject_unregister(&dp->ifobj);
-#else
- kobject_put(dp->ifobj);
-#endif
+ kobject_del(&dp->ifobj);
+ kobject_put(&dp->ifobj);
sysfs_remove_group(kobj, &bridge_group);
return 0;