aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMing Lei <tom.leiming@gmail.com>2009-03-01 08:10:49 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-03-24 19:38:26 -0400
commitf67f129e519fa87f8ebd236b6336fe43f31ee141 (patch)
treee2832f6d012044f5d05c6130416832235c7d2730
parent4995f8ef9d3aac72745e12419d7fbaa8d01b1d81 (diff)
Driver core: implement uevent suppress in kobject
This patch implements uevent suppress in kobject and removes it from struct device, based on the following ideas: 1,Uevent sending should be one attribute of kobject, so suppressing it in kobject layer is more natural than in device layer. By this way, we can do it for other objects embedded with kobject. 2,It may save several bytes for each instance of struct device.(On my omap3(32bit ARM) based box, can save 8bytes per device object) This patch also introduces dev_set|get_uevent_suppress() helpers to set and query uevent_suppress attribute in case to help kobject as private part of struct device in future. [This version is against the latest driver-core patch set of Greg,please ignore the last version.] Signed-off-by: Ming Lei <tom.leiming@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/acpi/dock.c2
-rw-r--r--drivers/base/core.c2
-rw-r--r--drivers/base/firmware_class.c4
-rw-r--r--drivers/i2c/i2c-core.c2
-rw-r--r--drivers/s390/cio/chsc_sch.c4
-rw-r--r--drivers/s390/cio/css.c4
-rw-r--r--drivers/s390/cio/device.c4
-rw-r--r--fs/partitions/check.c10
-rw-r--r--include/linux/device.h11
-rw-r--r--include/linux/kobject.h1
-rw-r--r--lib/kobject_uevent.c7
11 files changed, 33 insertions, 18 deletions
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 35094f230b1e..7af7db1ba8c4 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -977,7 +977,7 @@ static int dock_add(acpi_handle handle)
977 sizeof(struct dock_station *)); 977 sizeof(struct dock_station *));
978 978
979 /* we want the dock device to send uevents */ 979 /* we want the dock device to send uevents */
980 dock_device->dev.uevent_suppress = 0; 980 dev_set_uevent_suppress(&dock_device->dev, 0);
981 981
982 if (is_dock(handle)) 982 if (is_dock(handle))
983 dock_station->flags |= DOCK_IS_DOCK; 983 dock_station->flags |= DOCK_IS_DOCK;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index a90f56f64d6f..95c67ffd71da 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -136,8 +136,6 @@ static int dev_uevent_filter(struct kset *kset, struct kobject *kobj)
136 136
137 if (ktype == &device_ktype) { 137 if (ktype == &device_ktype) {
138 struct device *dev = to_dev(kobj); 138 struct device *dev = to_dev(kobj);
139 if (dev->uevent_suppress)
140 return 0;
141 if (dev->bus) 139 if (dev->bus)
142 return 1; 140 return 1;
143 if (dev->class) 141 if (dev->class)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 44699d9dd85c..d3a59c688fe4 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -319,7 +319,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
319 f_dev->parent = device; 319 f_dev->parent = device;
320 f_dev->class = &firmware_class; 320 f_dev->class = &firmware_class;
321 dev_set_drvdata(f_dev, fw_priv); 321 dev_set_drvdata(f_dev, fw_priv);
322 f_dev->uevent_suppress = 1; 322 dev_set_uevent_suppress(f_dev, 1);
323 retval = device_register(f_dev); 323 retval = device_register(f_dev);
324 if (retval) { 324 if (retval) {
325 dev_err(device, "%s: device_register failed\n", __func__); 325 dev_err(device, "%s: device_register failed\n", __func__);
@@ -366,7 +366,7 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p,
366 } 366 }
367 367
368 if (uevent) 368 if (uevent)
369 f_dev->uevent_suppress = 0; 369 dev_set_uevent_suppress(f_dev, 0);
370 *dev_p = f_dev; 370 *dev_p = f_dev;
371 goto out; 371 goto out;
372 372
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index e7d984866de0..fbb9030b68a5 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -841,7 +841,7 @@ int i2c_attach_client(struct i2c_client *client)
841 841
842 if (client->driver && !is_newstyle_driver(client->driver)) { 842 if (client->driver && !is_newstyle_driver(client->driver)) {
843 client->dev.release = i2c_client_release; 843 client->dev.release = i2c_client_release;
844 client->dev.uevent_suppress = 1; 844 dev_set_uevent_suppress(&client->dev, 1);
845 } else 845 } else
846 client->dev.release = i2c_client_dev_release; 846 client->dev.release = i2c_client_dev_release;
847 847
diff --git a/drivers/s390/cio/chsc_sch.c b/drivers/s390/cio/chsc_sch.c
index 0a2f2edafc03..93eca1731b81 100644
--- a/drivers/s390/cio/chsc_sch.c
+++ b/drivers/s390/cio/chsc_sch.c
@@ -84,8 +84,8 @@ static int chsc_subchannel_probe(struct subchannel *sch)
84 kfree(private); 84 kfree(private);
85 } else { 85 } else {
86 sch->private = private; 86 sch->private = private;
87 if (sch->dev.uevent_suppress) { 87 if (dev_get_uevent_suppress(&sch->dev)) {
88 sch->dev.uevent_suppress = 0; 88 dev_set_uevent_suppress(&sch->dev, 0);
89 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 89 kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
90 } 90 }
91 } 91 }
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 8019288bc6de..427d11d88069 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -272,7 +272,7 @@ static int css_register_subchannel(struct subchannel *sch)
272 * the subchannel driver can decide itself when it wants to inform 272 * the subchannel driver can decide itself when it wants to inform
273 * userspace of its existence. 273 * userspace of its existence.
274 */ 274 */
275 sch->dev.uevent_suppress = 1; 275 dev_set_uevent_suppress(&sch->dev, 1);
276 css_update_ssd_info(sch); 276 css_update_ssd_info(sch);
277 /* make it known to the system */ 277 /* make it known to the system */
278 ret = css_sch_device_register(sch); 278 ret = css_sch_device_register(sch);
@@ -287,7 +287,7 @@ static int css_register_subchannel(struct subchannel *sch)
287 * a fitting driver module may be loaded based on the 287 * a fitting driver module may be loaded based on the
288 * modalias. 288 * modalias.
289 */ 289 */
290 sch->dev.uevent_suppress = 0; 290 dev_set_uevent_suppress(&sch->dev, 0);
291 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 291 kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
292 } 292 }
293 return ret; 293 return ret;
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 23d5752349b5..611d2e001dd5 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -981,7 +981,7 @@ io_subchannel_register(struct work_struct *work)
981 * Now we know this subchannel will stay, we can throw 981 * Now we know this subchannel will stay, we can throw
982 * our delayed uevent. 982 * our delayed uevent.
983 */ 983 */
984 sch->dev.uevent_suppress = 0; 984 dev_set_uevent_suppress(&sch->dev, 0);
985 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 985 kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
986 /* make it known to the system */ 986 /* make it known to the system */
987 ret = ccw_device_register(cdev); 987 ret = ccw_device_register(cdev);
@@ -1243,7 +1243,7 @@ static int io_subchannel_probe(struct subchannel *sch)
1243 * the ccw_device and exit. This happens for all early 1243 * the ccw_device and exit. This happens for all early
1244 * devices, e.g. the console. 1244 * devices, e.g. the console.
1245 */ 1245 */
1246 sch->dev.uevent_suppress = 0; 1246 dev_set_uevent_suppress(&sch->dev, 0);
1247 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 1247 kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
1248 cdev->dev.groups = ccwdev_attr_groups; 1248 cdev->dev.groups = ccwdev_attr_groups;
1249 device_initialize(&cdev->dev); 1249 device_initialize(&cdev->dev);
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 6d720243f5f4..38e337d51ced 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -400,7 +400,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
400 pdev->devt = devt; 400 pdev->devt = devt;
401 401
402 /* delay uevent until 'holders' subdir is created */ 402 /* delay uevent until 'holders' subdir is created */
403 pdev->uevent_suppress = 1; 403 dev_set_uevent_suppress(pdev, 1);
404 err = device_add(pdev); 404 err = device_add(pdev);
405 if (err) 405 if (err)
406 goto out_put; 406 goto out_put;
@@ -410,7 +410,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
410 if (!p->holder_dir) 410 if (!p->holder_dir)
411 goto out_del; 411 goto out_del;
412 412
413 pdev->uevent_suppress = 0; 413 dev_set_uevent_suppress(pdev, 0);
414 if (flags & ADDPART_FLAG_WHOLEDISK) { 414 if (flags & ADDPART_FLAG_WHOLEDISK) {
415 err = device_create_file(pdev, &dev_attr_whole_disk); 415 err = device_create_file(pdev, &dev_attr_whole_disk);
416 if (err) 416 if (err)
@@ -422,7 +422,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
422 rcu_assign_pointer(ptbl->part[partno], p); 422 rcu_assign_pointer(ptbl->part[partno], p);
423 423
424 /* suppress uevent if the disk supresses it */ 424 /* suppress uevent if the disk supresses it */
425 if (!ddev->uevent_suppress) 425 if (!dev_get_uevent_suppress(pdev))
426 kobject_uevent(&pdev->kobj, KOBJ_ADD); 426 kobject_uevent(&pdev->kobj, KOBJ_ADD);
427 427
428 return p; 428 return p;
@@ -455,7 +455,7 @@ void register_disk(struct gendisk *disk)
455 dev_set_name(ddev, disk->disk_name); 455 dev_set_name(ddev, disk->disk_name);
456 456
457 /* delay uevents, until we scanned partition table */ 457 /* delay uevents, until we scanned partition table */
458 ddev->uevent_suppress = 1; 458 dev_set_uevent_suppress(ddev, 1);
459 459
460 if (device_add(ddev)) 460 if (device_add(ddev))
461 return; 461 return;
@@ -490,7 +490,7 @@ void register_disk(struct gendisk *disk)
490 490
491exit: 491exit:
492 /* announce disk after possible partitions are created */ 492 /* announce disk after possible partitions are created */
493 ddev->uevent_suppress = 0; 493 dev_set_uevent_suppress(ddev, 0);
494 kobject_uevent(&ddev->kobj, KOBJ_ADD); 494 kobject_uevent(&ddev->kobj, KOBJ_ADD);
495 495
496 /* announce possible partitions */ 496 /* announce possible partitions */
diff --git a/include/linux/device.h b/include/linux/device.h
index 4bea53fe8f4c..914c1016dd8f 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -373,7 +373,6 @@ struct device {
373 struct device_private *p; 373 struct device_private *p;
374 374
375 struct kobject kobj; 375 struct kobject kobj;
376 unsigned uevent_suppress:1;
377 const char *init_name; /* initial name of the device */ 376 const char *init_name; /* initial name of the device */
378 struct device_type *type; 377 struct device_type *type;
379 378
@@ -465,6 +464,16 @@ static inline void dev_set_drvdata(struct device *dev, void *data)
465 dev->driver_data = data; 464 dev->driver_data = data;
466} 465}
467 466
467static inline unsigned int dev_get_uevent_suppress(const struct device *dev)
468{
469 return dev->kobj.uevent_suppress;
470}
471
472static inline void dev_set_uevent_suppress(struct device *dev, int val)
473{
474 dev->kobj.uevent_suppress = val;
475}
476
468static inline int device_is_registered(struct device *dev) 477static inline int device_is_registered(struct device *dev)
469{ 478{
470 return dev->kobj.state_in_sysfs; 479 return dev->kobj.state_in_sysfs;
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index c9c214d7bba2..58ae8e00fcdd 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -68,6 +68,7 @@ struct kobject {
68 unsigned int state_in_sysfs:1; 68 unsigned int state_in_sysfs:1;
69 unsigned int state_add_uevent_sent:1; 69 unsigned int state_add_uevent_sent:1;
70 unsigned int state_remove_uevent_sent:1; 70 unsigned int state_remove_uevent_sent:1;
71 unsigned int uevent_suppress:1;
71}; 72};
72 73
73extern int kobject_set_name(struct kobject *kobj, const char *name, ...) 74extern int kobject_set_name(struct kobject *kobj, const char *name, ...)
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 318328ddbd1c..b2181cc8e4d8 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -118,6 +118,13 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
118 kset = top_kobj->kset; 118 kset = top_kobj->kset;
119 uevent_ops = kset->uevent_ops; 119 uevent_ops = kset->uevent_ops;
120 120
121 /* skip the event, if uevent_suppress is set*/
122 if (kobj->uevent_suppress) {
123 pr_debug("kobject: '%s' (%p): %s: uevent_suppress "
124 "caused the event to drop!\n",
125 kobject_name(kobj), kobj, __func__);
126 return 0;
127 }
121 /* skip the event, if the filter returns zero. */ 128 /* skip the event, if the filter returns zero. */
122 if (uevent_ops && uevent_ops->filter) 129 if (uevent_ops && uevent_ops->filter)
123 if (!uevent_ops->filter(kset, kobj)) { 130 if (!uevent_ops->filter(kset, kobj)) {