aboutsummaryrefslogtreecommitdiffstats
diff options
authorGreg KH <gregkh@t43.kroah.org>2007-12-06 17:37:57 -0800
committerGreg KH <gregkh@t43.kroah.org>2007-12-06 17:37:57 -0800
commit3a06612fafd3d888fa75407c7e277268da20ac68 (patch)
treed8285ab3b9e32270b96965bf6ca330dc44363929
parent7df893c386a942dcd33521e5f34bc6b8ea20908e (diff)
downloadpatches-3a06612fafd3d888fa75407c7e277268da20ac68.tar.gz
more kobject work in progress...
-rw-r--r--f2.patch95
-rw-r--r--k1.patch353
-rw-r--r--k2.patch71
-rw-r--r--series2
4 files changed, 503 insertions, 18 deletions
diff --git a/f2.patch b/f2.patch
index 660924f15b2c53..ab8140405c8e9c 100644
--- a/f2.patch
+++ b/f2.patch
@@ -1,18 +1,53 @@
---
- block/elevator.c | 8 ++------
- block/ll_rw_blk.c | 9 +++------
- drivers/base/class.c | 10 +++-------
- drivers/base/core.c | 6 ++----
- drivers/md/md.c | 13 ++++---------
- drivers/net/iseries_veth.c | 10 +++-------
- fs/char_dev.c | 6 ++----
- kernel/module.c | 14 ++++++--------
- kernel/params.c | 6 ++----
- kernel/user.c | 9 ++++-----
- mm/slub.c | 9 ++++-----
- net/bridge/br_if.c | 10 +++-------
- 12 files changed, 38 insertions(+), 72 deletions(-)
+ arch/cris/arch-v32/drivers/iop_fw_load.c | 11 +++++++++++
+ block/elevator.c | 8 ++------
+ block/ll_rw_blk.c | 9 +++------
+ drivers/base/class.c | 10 +++-------
+ drivers/base/core.c | 8 +++-----
+ drivers/md/md.c | 13 ++++---------
+ drivers/net/iseries_veth.c | 17 +++++------------
+ fs/char_dev.c | 6 ++----
+ kernel/module.c | 14 ++++++--------
+ kernel/params.c | 6 ++----
+ kernel/user.c | 9 ++++-----
+ mm/slub.c | 9 ++++-----
+ net/bridge/br_if.c | 10 +++-------
+ 13 files changed, 52 insertions(+), 78 deletions(-)
+--- a/arch/cris/arch-v32/drivers/iop_fw_load.c
++++ b/arch/cris/arch-v32/drivers/iop_fw_load.c
+@@ -20,6 +20,9 @@
+
+ #define IOP_TIMEOUT 100
+
++#error "This driver is broken with regard to its driver core usage."
++#error "Please contact <greg@kroah.com> for details on how to fix it properly."
++
+ static struct device iop_spu_device[2] = {
+ { .bus_id = "iop-spu0", },
+ { .bus_id = "iop-spu1", },
+@@ -192,6 +195,13 @@ int iop_start_mpu(unsigned int start_add
+
+ static int __init iop_fw_load_init(void)
+ {
++#if 0
++ /*
++ * static struct devices can not be added directly to sysfs by ignoring
++ * the driver model infrastructure. To fix this properly, please use
++ * the platform_bus to register these devices to be able to properly
++ * use the firmware infrastructure.
++ */
+ device_initialize(&iop_spu_device[0]);
+ kobject_set_name(&iop_spu_device[0].kobj, "iop-spu0");
+ kobject_add(&iop_spu_device[0].kobj);
+@@ -201,6 +211,7 @@ static int __init iop_fw_load_init(void)
+ device_initialize(&iop_mpu_device);
+ kobject_set_name(&iop_mpu_device.kobj, "iop-mpu");
+ kobject_add(&iop_mpu_device.kobj);
++#endif
+ return 0;
+ }
+
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -185,9 +185,7 @@ static elevator_t *elevator_alloc(struct
@@ -105,6 +140,15 @@
klist_init(&dev->klist_children, klist_children_get,
klist_children_put);
INIT_LIST_HEAD(&dev->dma_pools);
+@@ -778,7 +777,7 @@ static void device_remove_class_symlinks
+ * This is part 2 of device_register(), though may be called
+ * separately _iff_ device_initialize() has been called separately.
+ *
+- * This adds it to the kobject hierarchy via kobject_add(), adds it
++ * This adds it to the kobject hierarchy via kobject_add_ng(), adds it
+ * to the global and sibling lists for the device, then
+ * adds it to the other relevant subsystems of the driver model.
+ */
@@ -806,8 +805,7 @@ int device_add(struct device *dev)
goto Error;
@@ -150,17 +194,20 @@
rdev->saved_raid_disk = -1;
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
-@@ -844,8 +844,7 @@ static int veth_init_connection(u8 rlp)
+@@ -844,11 +844,7 @@ static int veth_init_connection(u8 rlp)
/* This gets us 1 reference, which is held on behalf of the driver
* infrastructure. It's released at module unload. */
- kobject_init(&cnx->kobject);
- cnx->kobject.ktype = &veth_lpar_connection_ktype;
+- rc = kobject_set_name(&cnx->kobject, "cnx%.2d", rlp);
+- if (rc != 0)
+- return rc;
+ kobject_init_ng(&cnx->kobject, &veth_lpar_connection_ktype);
- rc = kobject_set_name(&cnx->kobject, "cnx%.2d", rlp);
- if (rc != 0)
- return rc;
-@@ -1087,11 +1086,8 @@ static struct net_device * __init veth_p
+
+ msgs = kcalloc(VETH_NUMBUFFERS, sizeof(struct veth_msg), GFP_KERNEL);
+ if (! msgs) {
+@@ -1087,11 +1083,8 @@ static struct net_device * __init veth_p
return NULL;
}
@@ -174,6 +221,18 @@
veth_error("Failed adding port for %s to sysfs.\n", dev->name);
veth_info("%s attached to iSeries vlan %d (LPAR map = 0x%.4X)\n",
+@@ -1711,9 +1704,9 @@ static int __init veth_module_init(void)
+ continue;
+
+ kobj = &veth_cnx[i]->kobject;
+- kobj->parent = &veth_driver.driver.kobj;
+ /* If the add failes, complain but otherwise continue */
+- if (0 != kobject_add(kobj))
++ if (0 != kobject_add_ng(kobj, &veth_driver.driver.kobj,
++ "cnx%.2d", veth_cnx[i]->remote_lp))
+ veth_error("cnx %d: Failed adding to sysfs.\n", i);
+ }
+
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -510,9 +510,8 @@ struct cdev *cdev_alloc(void)
diff --git a/k1.patch b/k1.patch
new file mode 100644
index 00000000000000..9e056cf7f46bdc
--- /dev/null
+++ b/k1.patch
@@ -0,0 +1,353 @@
+---
+ drivers/edac/edac_device_sysfs.c | 39 ++++++++++++---------------------------
+ drivers/edac/edac_mc_sysfs.c | 28 +++++++++-------------------
+ drivers/infiniband/core/sysfs.c | 31 +++++++------------------------
+ fs/dlm/lockspace.c | 26 ++++----------------------
+ fs/gfs2/locking/dlm/sysfs.c | 13 +++----------
+ fs/gfs2/sys.c | 10 +++-------
+ include/rdma/ib_verbs.h | 2 +-
+ 7 files changed, 39 insertions(+), 110 deletions(-)
+
+--- a/drivers/edac/edac_device_sysfs.c
++++ b/drivers/edac/edac_device_sysfs.c
+@@ -246,16 +246,6 @@ int edac_device_register_sysfs_main_kobj
+
+ /* Init the devices's kobject */
+ memset(&edac_dev->kobj, 0, sizeof(struct kobject));
+- edac_dev->kobj.ktype = &ktype_device_ctrl;
+-
+- /* set this new device under the edac_class kobject */
+- edac_dev->kobj.parent = &edac_class->kset.kobj;
+-
+- /* generate sysfs "..../edac/<name>" */
+- debugf4("%s() set name of kobject to: %s\n", __func__, edac_dev->name);
+- err = kobject_set_name(&edac_dev->kobj, "%s", edac_dev->name);
+- if (err)
+- goto err_out;
+
+ /* Record which module 'owns' this control structure
+ * and bump the ref count of the module
+@@ -268,12 +258,15 @@ int edac_device_register_sysfs_main_kobj
+ }
+
+ /* register */
+- err = kobject_register(&edac_dev->kobj);
++ err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl,
++ &edac_class->kset.kobj,
++ "%s", edac_dev->name);
+ if (err) {
+ debugf1("%s()Failed to register '.../edac/%s'\n",
+ __func__, edac_dev->name);
+ goto err_kobj_reg;
+ }
++ kobject_uevent(&edac_dev->kobj, KOBJ_ADD);
+
+ /* At this point, to 'free' the control struct,
+ * edac_device_unregister_sysfs_main_kobj() must be used
+@@ -533,12 +526,6 @@ static int edac_device_create_block(stru
+
+ /* init this block's kobject */
+ memset(&block->kobj, 0, sizeof(struct kobject));
+- block->kobj.parent = &instance->kobj;
+- block->kobj.ktype = &ktype_block_ctrl;
+-
+- err = kobject_set_name(&block->kobj, "%s", block->name);
+- if (err)
+- return err;
+
+ /* bump the main kobject's reference count for this controller
+ * and this instance is dependant on the main
+@@ -550,7 +537,9 @@ static int edac_device_create_block(stru
+ }
+
+ /* Add this block's kobject */
+- err = kobject_register(&block->kobj);
++ err = kobject_init_and_add(&block->kobj, &ktype_block_ctrl,
++ &instance->kobj,
++ "%s", block->name);
+ if (err) {
+ debugf1("%s() Failed to register instance '%s'\n",
+ __func__, block->name);
+@@ -579,6 +568,7 @@ static int edac_device_create_block(stru
+ goto err_on_attrib;
+ }
+ }
++ kobject_uevent(&block->kobj, KOBJ_ADD);
+
+ return 0;
+
+@@ -637,15 +627,8 @@ static int edac_device_create_instance(s
+ /* Init the instance's kobject */
+ memset(&instance->kobj, 0, sizeof(struct kobject));
+
+- /* set this new device under the edac_device main kobject */
+- instance->kobj.parent = &edac_dev->kobj;
+- instance->kobj.ktype = &ktype_instance_ctrl;
+ instance->ctl = edac_dev;
+
+- err = kobject_set_name(&instance->kobj, "%s", instance->name);
+- if (err)
+- goto err_out;
+-
+ /* bump the main kobject's reference count for this controller
+ * and this instance is dependant on the main
+ */
+@@ -655,8 +638,9 @@ static int edac_device_create_instance(s
+ goto err_out;
+ }
+
+- /* Formally register this instance's kobject */
+- err = kobject_register(&instance->kobj);
++ /* Formally register this instance's kobject under the edac_device */
++ err = kobject_init_and_add(&instance->kobj, &ktype_instance_ctrl,
++ &edac_dev->kobj, "%s", instance->name);
+ if (err != 0) {
+ debugf2("%s() Failed to register instance '%s'\n",
+ __func__, instance->name);
+@@ -679,6 +663,7 @@ static int edac_device_create_instance(s
+ goto err_release_instance_kobj;
+ }
+ }
++ kobject_uevent(&instance->kobj, KOBJ_ADD);
+
+ debugf4("%s() Registered instance %d '%s' kobject\n",
+ __func__, idx, instance->name);
+--- a/drivers/edac/edac_mc_sysfs.c
++++ b/drivers/edac/edac_mc_sysfs.c
+@@ -380,13 +380,6 @@ static int edac_create_csrow_object(stru
+ /* generate ..../edac/mc/mc<id>/csrow<index> */
+ memset(&csrow->kobj, 0, sizeof(csrow->kobj));
+ csrow->mci = mci; /* include container up link */
+- csrow->kobj.parent = kobj_mci;
+- csrow->kobj.ktype = &ktype_csrow;
+-
+- /* name this instance of csrow<id> */
+- err = kobject_set_name(&csrow->kobj, "csrow%d", index);
+- if (err)
+- goto err_out;
+
+ /* bump the mci instance's kobject's ref count */
+ kobj = kobject_get(&mci->edac_mci_kobj);
+@@ -396,7 +389,8 @@ static int edac_create_csrow_object(stru
+ }
+
+ /* Instanstiate the csrow object */
+- err = kobject_register(&csrow->kobj);
++ err = kobject_init_and_add(&csrow->kobj, &ktype_csrow, kobj_mci,
++ "csrow%d", index);
+ if (err)
+ goto err_release_top_kobj;
+
+@@ -416,7 +410,7 @@ static int edac_create_csrow_object(stru
+ goto err_out;
+ }
+ }
+-
++ kobject_uevent(&csrow->kobj, KOBJ_ADD);
+ return 0;
+
+ /* error unwind stack */
+@@ -764,15 +758,6 @@ int edac_mc_register_sysfs_main_kobj(str
+ /* Init the mci's kobject */
+ memset(kobj_mci, 0, sizeof(*kobj_mci));
+
+- /* this instance become part of the mc_kset */
+- kobj_mci->kset = &mc_kset;
+- kobj_mci->ktype = &ktype_mci;
+-
+- /* set the name of the mc<id> object */
+- err = kobject_set_name(kobj_mci, "mc%d", mci->mc_idx);
+- if (err)
+- goto fail_out;
+-
+ /* Record which module 'owns' this control structure
+ * and bump the ref count of the module
+ */
+@@ -784,13 +769,18 @@ int edac_mc_register_sysfs_main_kobj(str
+ goto fail_out;
+ }
+
++ /* this instance become part of the mc_kset */
++ kobj_mci->kset = &mc_kset;
++
+ /* register the mc<id> kobject to the mc_kset */
+- err = kobject_register(kobj_mci);
++ err = kobject_init_and_add(kobj_mci, &ktype_mci, NULL,
++ "mc%d", mci->mc_idx);
+ if (err) {
+ debugf1("%s()Failed to register '.../edac/mc%d'\n",
+ __func__, mci->mc_idx);
+ goto kobj_reg_fail;
+ }
++ kobject_uevent(kobj_mci, KOBJ_ADD);
+
+ /* At this point, to 'free' the control struct,
+ * edac_mc_unregister_sysfs_main_kobj() must be used
+--- a/drivers/infiniband/core/sysfs.c
++++ b/drivers/infiniband/core/sysfs.c
+@@ -508,19 +508,10 @@ static int add_port(struct ib_device *de
+
+ p->ibdev = device;
+ p->port_num = port_num;
+- p->kobj.ktype = &port_type;
+
+- p->kobj.parent = kobject_get(&device->ports_parent);
+- if (!p->kobj.parent) {
+- ret = -EBUSY;
+- goto err;
+- }
+-
+- ret = kobject_set_name(&p->kobj, "%d", port_num);
+- if (ret)
+- goto err_put;
+-
+- ret = kobject_register(&p->kobj);
++ ret = kobject_init_and_add(&p->kobj, &port_type,
++ kobject_get(&device->ports_parent),
++ "%d", port_num);
+ if (ret)
+ goto err_put;
+
+@@ -549,6 +540,7 @@ static int add_port(struct ib_device *de
+
+ list_add_tail(&p->kobj.entry, &device->port_list);
+
++ kobject_uevent(&p->kobj, KOBJ_ADD);
+ return 0;
+
+ err_free_pkey:
+@@ -571,8 +563,6 @@ err_remove_pma:
+
+ err_put:
+ kobject_put(&device->ports_parent);
+-
+-err:
+ kfree(p);
+ return ret;
+ }
+@@ -694,16 +684,9 @@ int ib_device_register_sysfs(struct ib_d
+ goto err_unregister;
+ }
+
+- device->ports_parent.parent = kobject_get(&class_dev->kobj);
+- if (!device->ports_parent.parent) {
+- ret = -EBUSY;
+- goto err_unregister;
+- }
+- ret = kobject_set_name(&device->ports_parent, "ports");
+- if (ret)
+- goto err_put;
+- ret = kobject_register(&device->ports_parent);
+- if (ret)
++ device->ports_parent = kobject_create_and_add("ports",
++ kobject_get(&class_dev->kobj));
++ if (!device->ports_parent)
+ goto err_put;
+
+ if (device->node_type == RDMA_NODE_IB_SWITCH) {
+--- a/fs/dlm/lockspace.c
++++ b/fs/dlm/lockspace.c
+@@ -168,23 +168,6 @@ static struct kobj_type dlm_ktype = {
+
+ static struct kset *dlm_kset;
+
+-static int kobject_setup(struct dlm_ls *ls)
+-{
+- char lsname[DLM_LOCKSPACE_LEN];
+- int error;
+-
+- memset(lsname, 0, DLM_LOCKSPACE_LEN);
+- snprintf(lsname, DLM_LOCKSPACE_LEN, "%s", ls->ls_name);
+-
+- error = kobject_set_name(&ls->ls_kobj, "%s", lsname);
+- if (error)
+- return error;
+-
+- ls->ls_kobj.kset = dlm_kset;
+- ls->ls_kobj.ktype = &dlm_ktype;
+- return 0;
+-}
+-
+ static int do_uevent(struct dlm_ls *ls, int in)
+ {
+ int error;
+@@ -545,13 +528,12 @@ static int new_lockspace(char *name, int
+ goto out_delist;
+ }
+
+- error = kobject_setup(ls);
+- if (error)
+- goto out_stop;
+-
+- error = kobject_register(&ls->ls_kobj);
++ ls->ls_kobj.kset = dlm_kset;
++ error = kobject_init_and_add(&ls->ls_kobj, &dlm_ktype, NULL,
++ "%s", ls->ls_name);
+ if (error)
+ goto out_stop;
++ kobject_uevent(&ls->ls_kobj, KOBJ_ADD);
+
+ /* let kobject handle freeing of ls if there's an error */
+ do_unreg = 1;
+--- a/fs/gfs2/locking/dlm/sysfs.c
++++ b/fs/gfs2/locking/dlm/sysfs.c
+@@ -195,19 +195,12 @@ int gdlm_kobject_setup(struct gdlm_ls *l
+ {
+ int error;
+
+- error = kobject_set_name(&ls->kobj, "%s", "lock_module");
+- if (error) {
+- log_error("can't set kobj name %d", error);
+- return error;
+- }
+-
+ ls->kobj.kset = gdlm_kset;
+- ls->kobj.ktype = &gdlm_ktype;
+- ls->kobj.parent = fskobj;
+-
+- error = kobject_register(&ls->kobj);
++ error = kobject_init_and_add(&ls->kobj, &gdlm_ktype, fskobj,
++ "lock_module");
+ if (error)
+ log_error("can't register kobj %d", error);
++ kobject_uevent(&ls->kobj, KOBJ_ADD);
+
+ return error;
+ }
+--- a/fs/gfs2/sys.c
++++ b/fs/gfs2/sys.c
+@@ -494,13 +494,8 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp
+ int error;
+
+ sdp->sd_kobj.kset = gfs2_kset;
+- sdp->sd_kobj.ktype = &gfs2_ktype;
+-
+- error = kobject_set_name(&sdp->sd_kobj, "%s", sdp->sd_table_name);
+- if (error)
+- goto fail;
+-
+- error = kobject_register(&sdp->sd_kobj);
++ error = kobject_init_and_add(&sdp->sd_kobj, &gfs2_ktype, NULL,
++ "%s", sdp->sd_table_name);
+ if (error)
+ goto fail;
+
+@@ -520,6 +515,7 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp
+ if (error)
+ goto fail_args;
+
++ kobject_uevent(&sdp->sd_kobj, KOBJ_ADD);
+ return 0;
+
+ fail_args:
+--- a/include/rdma/ib_verbs.h
++++ b/include/rdma/ib_verbs.h
+@@ -1026,7 +1026,7 @@ struct ib_device {
+
+ struct module *owner;
+ struct class_device class_dev;
+- struct kobject ports_parent;
++ struct kobject *ports_parent;
+ struct list_head port_list;
+
+ enum {
diff --git a/k2.patch b/k2.patch
new file mode 100644
index 00000000000000..053d3c9f78fa99
--- /dev/null
+++ b/k2.patch
@@ -0,0 +1,71 @@
+---
+ net/bridge/br_if.c | 2 +-
+ net/bridge/br_private.h | 2 +-
+ net/bridge/br_sysfs_br.c | 14 ++++----------
+ net/bridge/br_sysfs_if.c | 2 +-
+ 4 files changed, 7 insertions(+), 13 deletions(-)
+
+--- a/net/bridge/br_if.c
++++ b/net/bridge/br_if.c
+@@ -133,7 +133,7 @@ static void del_nbp(struct net_bridge_po
+ struct net_bridge *br = p->br;
+ struct net_device *dev = p->dev;
+
+- sysfs_remove_link(&br->ifobj, dev->name);
++ sysfs_remove_link(br->ifobj, dev->name);
+
+ dev_set_promiscuity(dev, -1);
+
+--- a/net/bridge/br_private.h
++++ b/net/bridge/br_private.h
+@@ -124,7 +124,7 @@ struct net_bridge
+ struct timer_list tcn_timer;
+ struct timer_list topology_change_timer;
+ struct timer_list gc_timer;
+- struct kobject ifobj;
++ struct kobject *ifobj;
+ };
+
+ extern struct notifier_block br_device_notifier;
+--- a/net/bridge/br_sysfs_br.c
++++ b/net/bridge/br_sysfs_br.c
+@@ -426,16 +426,10 @@ int br_sysfs_addbr(struct net_device *de
+ goto out2;
+ }
+
+-
+- kobject_set_name(&br->ifobj, SYSFS_BRIDGE_PORT_SUBDIR);
+- br->ifobj.ktype = NULL;
+- br->ifobj.kset = NULL;
+- br->ifobj.parent = brobj;
+-
+- err = kobject_register(&br->ifobj);
+- if (err) {
++ br->ifobj = kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR, brobj);
++ if (!br->ifobj) {
+ pr_info("%s: can't add kobject (directory) %s/%s\n",
+- __FUNCTION__, dev->name, kobject_name(&br->ifobj));
++ __FUNCTION__, dev->name, SYSFS_BRIDGE_PORT_SUBDIR);
+ goto out3;
+ }
+ return 0;
+@@ -453,7 +447,7 @@ void br_sysfs_delbr(struct net_device *d
+ struct kobject *kobj = &dev->dev.kobj;
+ struct net_bridge *br = netdev_priv(dev);
+
+- kobject_unregister(&br->ifobj);
++ kobject_unregister(br->ifobj);
+ sysfs_remove_bin_file(kobj, &bridge_forward);
+ sysfs_remove_group(kobj, &bridge_group);
+ }
+--- a/net/bridge/br_sysfs_if.c
++++ b/net/bridge/br_sysfs_if.c
+@@ -229,7 +229,7 @@ int br_sysfs_addif(struct net_bridge_por
+ goto out2;
+ }
+
+- err= sysfs_create_link(&br->ifobj, &p->kobj, p->dev->name);
++ err= sysfs_create_link(br->ifobj, &p->kobj, p->dev->name);
+ out2:
+ return err;
+ }
diff --git a/series b/series
index 61aea2a3c746a3..d6c60b834dc167 100644
--- a/series
+++ b/series
@@ -232,3 +232,5 @@ driver/uio-fix-kobject-usage.patch
f2.patch
+k1.patch
+k2.patch