aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/edac_pci_sysfs.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-12-17 14:54:39 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 23:40:28 -0500
commitb2ed215a3338b8b16187be8d136153054118a41e (patch)
tree0abccda52f2c8356f35c857bcf2abbe7661b6e2d /drivers/edac/edac_pci_sysfs.c
parent038c5b3e412b0b751cb4b1507506bad3c7ffefae (diff)
Kobject: change drivers/edac to use kobject_init_and_add
Stop using kobject_register, as this way we can control the sending of the uevent properly, after everything is properly initialized. Acked-by: Doug Thompson <dougthompson@xmission.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/edac/edac_pci_sysfs.c')
-rw-r--r--drivers/edac/edac_pci_sysfs.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index 69f5dddabddf..834eaa9d6148 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -162,14 +162,6 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
162 162
163 debugf0("%s()\n", __func__); 163 debugf0("%s()\n", __func__);
164 164
165 /* Set the parent and the instance's ktype */
166 pci->kobj.parent = &edac_pci_top_main_kobj;
167 pci->kobj.ktype = &ktype_pci_instance;
168
169 err = kobject_set_name(&pci->kobj, "pci%d", idx);
170 if (err)
171 return err;
172
173 /* First bump the ref count on the top main kobj, which will 165 /* First bump the ref count on the top main kobj, which will
174 * track the number of PCI instances we have, and thus nest 166 * track the number of PCI instances we have, and thus nest
175 * properly on keeping the module loaded 167 * properly on keeping the module loaded
@@ -181,7 +173,8 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
181 } 173 }
182 174
183 /* And now register this new kobject under the main kobj */ 175 /* And now register this new kobject under the main kobj */
184 err = kobject_register(&pci->kobj); 176 err = kobject_init_and_add(&pci->kobj, &ktype_pci_instance,
177 &edac_pci_top_main_kobj, "pci%d", idx);
185 if (err != 0) { 178 if (err != 0) {
186 debugf2("%s() failed to register instance pci%d\n", 179 debugf2("%s() failed to register instance pci%d\n",
187 __func__, idx); 180 __func__, idx);
@@ -189,6 +182,7 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
189 goto error_out; 182 goto error_out;
190 } 183 }
191 184
185 kobject_uevent(&pci->kobj, KOBJ_ADD);
192 debugf1("%s() Register instance 'pci%d' kobject\n", __func__, idx); 186 debugf1("%s() Register instance 'pci%d' kobject\n", __func__, idx);
193 187
194 return 0; 188 return 0;
@@ -364,14 +358,6 @@ int edac_pci_main_kobj_setup(void)
364 goto decrement_count_fail; 358 goto decrement_count_fail;
365 } 359 }
366 360
367 /* Need the kobject hook ups, and name setting */
368 edac_pci_top_main_kobj.ktype = &ktype_edac_pci_main_kobj;
369 edac_pci_top_main_kobj.parent = &edac_class->kset.kobj;
370
371 err = kobject_set_name(&edac_pci_top_main_kobj, "pci");
372 if (err)
373 goto decrement_count_fail;
374
375 /* Bump the reference count on this module to ensure the 361 /* Bump the reference count on this module to ensure the
376 * modules isn't unloaded until we deconstruct the top 362 * modules isn't unloaded until we deconstruct the top
377 * level main kobj for EDAC PCI 363 * level main kobj for EDAC PCI
@@ -383,23 +369,24 @@ int edac_pci_main_kobj_setup(void)
383 } 369 }
384 370
385 /* Instanstiate the pci object */ 371 /* Instanstiate the pci object */
386 /* FIXME: maybe new sysdev_create_subdir() */ 372 err = kobject_init_and_add(&edac_pci_top_main_kobj, &ktype_edac_pci_main_kobj,
387 err = kobject_register(&edac_pci_top_main_kobj); 373 &edac_class->kset.kobj, "pci");
388 if (err) { 374 if (err) {
389 debugf1("Failed to register '.../edac/pci'\n"); 375 debugf1("Failed to register '.../edac/pci'\n");
390 goto kobject_register_fail; 376 goto kobject_init_and_add_fail;
391 } 377 }
392 378
393 /* At this point, to 'release' the top level kobject 379 /* At this point, to 'release' the top level kobject
394 * for EDAC PCI, then edac_pci_main_kobj_teardown() 380 * for EDAC PCI, then edac_pci_main_kobj_teardown()
395 * must be used, for resources to be cleaned up properly 381 * must be used, for resources to be cleaned up properly
396 */ 382 */
383 kobject_uevent(&edac_pci_top_main_kobj, KOBJ_ADD);
397 debugf1("Registered '.../edac/pci' kobject\n"); 384 debugf1("Registered '.../edac/pci' kobject\n");
398 385
399 return 0; 386 return 0;
400 387
401 /* Error unwind statck */ 388 /* Error unwind statck */
402kobject_register_fail: 389kobject_init_and_add_fail:
403 module_put(THIS_MODULE); 390 module_put(THIS_MODULE);
404 391
405decrement_count_fail: 392decrement_count_fail: