From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Ming Lei <tom.leiming@gmail.com>, Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 52/61] Driver core: implement uevent suppress in kobject
Date: Tue, 24 Mar 2009 17:26:56 -0700 [thread overview]
Message-ID: <1237940825-22904-52-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20090325001659.GA22461@kroah.com>
From: Ming Lei <tom.leiming@gmail.com>
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>
---
drivers/acpi/dock.c | 2 +-
drivers/base/core.c | 2 --
drivers/base/firmware_class.c | 4 ++--
drivers/i2c/i2c-core.c | 2 +-
drivers/s390/cio/chsc_sch.c | 4 ++--
drivers/s390/cio/css.c | 4 ++--
drivers/s390/cio/device.c | 4 ++--
fs/partitions/check.c | 10 +++++-----
include/linux/device.h | 11 ++++++++++-
include/linux/kobject.h | 1 +
lib/kobject_uevent.c | 7 +++++++
11 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 35094f2..7af7db1 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -977,7 +977,7 @@ static int dock_add(acpi_handle handle)
sizeof(struct dock_station *));
/* we want the dock device to send uevents */
- dock_device->dev.uevent_suppress = 0;
+ dev_set_uevent_suppress(&dock_device->dev, 0);
if (is_dock(handle))
dock_station->flags |= DOCK_IS_DOCK;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index a90f56f..95c67ff 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)
if (ktype == &device_ktype) {
struct device *dev = to_dev(kobj);
- if (dev->uevent_suppress)
- return 0;
if (dev->bus)
return 1;
if (dev->class)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 44699d9..d3a59c6 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,
f_dev->parent = device;
f_dev->class = &firmware_class;
dev_set_drvdata(f_dev, fw_priv);
- f_dev->uevent_suppress = 1;
+ dev_set_uevent_suppress(f_dev, 1);
retval = device_register(f_dev);
if (retval) {
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,
}
if (uevent)
- f_dev->uevent_suppress = 0;
+ dev_set_uevent_suppress(f_dev, 0);
*dev_p = f_dev;
goto out;
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index e7d9848..fbb9030 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)
if (client->driver && !is_newstyle_driver(client->driver)) {
client->dev.release = i2c_client_release;
- client->dev.uevent_suppress = 1;
+ dev_set_uevent_suppress(&client->dev, 1);
} else
client->dev.release = i2c_client_dev_release;
diff --git a/drivers/s390/cio/chsc_sch.c b/drivers/s390/cio/chsc_sch.c
index 0a2f2ed..93eca17 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)
kfree(private);
} else {
sch->private = private;
- if (sch->dev.uevent_suppress) {
- sch->dev.uevent_suppress = 0;
+ if (dev_get_uevent_suppress(&sch->dev)) {
+ dev_set_uevent_suppress(&sch->dev, 0);
kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
}
}
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 8019288..427d11d 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)
* the subchannel driver can decide itself when it wants to inform
* userspace of its existence.
*/
- sch->dev.uevent_suppress = 1;
+ dev_set_uevent_suppress(&sch->dev, 1);
css_update_ssd_info(sch);
/* make it known to the system */
ret = css_sch_device_register(sch);
@@ -287,7 +287,7 @@ static int css_register_subchannel(struct subchannel *sch)
* a fitting driver module may be loaded based on the
* modalias.
*/
- sch->dev.uevent_suppress = 0;
+ dev_set_uevent_suppress(&sch->dev, 0);
kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
}
return ret;
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 23d5752..611d2e0 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -981,7 +981,7 @@ io_subchannel_register(struct work_struct *work)
* Now we know this subchannel will stay, we can throw
* our delayed uevent.
*/
- sch->dev.uevent_suppress = 0;
+ dev_set_uevent_suppress(&sch->dev, 0);
kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
/* make it known to the system */
ret = ccw_device_register(cdev);
@@ -1243,7 +1243,7 @@ static int io_subchannel_probe(struct subchannel *sch)
* the ccw_device and exit. This happens for all early
* devices, e.g. the console.
*/
- sch->dev.uevent_suppress = 0;
+ dev_set_uevent_suppress(&sch->dev, 0);
kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
cdev->dev.groups = ccwdev_attr_groups;
device_initialize(&cdev->dev);
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 6d72024..38e337d 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,
pdev->devt = devt;
/* delay uevent until 'holders' subdir is created */
- pdev->uevent_suppress = 1;
+ dev_set_uevent_suppress(pdev, 1);
err = device_add(pdev);
if (err)
goto out_put;
@@ -410,7 +410,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
if (!p->holder_dir)
goto out_del;
- pdev->uevent_suppress = 0;
+ dev_set_uevent_suppress(pdev, 0);
if (flags & ADDPART_FLAG_WHOLEDISK) {
err = device_create_file(pdev, &dev_attr_whole_disk);
if (err)
@@ -422,7 +422,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
rcu_assign_pointer(ptbl->part[partno], p);
/* suppress uevent if the disk supresses it */
- if (!ddev->uevent_suppress)
+ if (!dev_get_uevent_suppress(pdev))
kobject_uevent(&pdev->kobj, KOBJ_ADD);
return p;
@@ -455,7 +455,7 @@ void register_disk(struct gendisk *disk)
dev_set_name(ddev, disk->disk_name);
/* delay uevents, until we scanned partition table */
- ddev->uevent_suppress = 1;
+ dev_set_uevent_suppress(ddev, 1);
if (device_add(ddev))
return;
@@ -490,7 +490,7 @@ void register_disk(struct gendisk *disk)
exit:
/* announce disk after possible partitions are created */
- ddev->uevent_suppress = 0;
+ dev_set_uevent_suppress(ddev, 0);
kobject_uevent(&ddev->kobj, KOBJ_ADD);
/* announce possible partitions */
diff --git a/include/linux/device.h b/include/linux/device.h
index 4bea53f..914c101 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -373,7 +373,6 @@ struct device {
struct device_private *p;
struct kobject kobj;
- unsigned uevent_suppress:1;
const char *init_name; /* initial name of the device */
struct device_type *type;
@@ -465,6 +464,16 @@ static inline void dev_set_drvdata(struct device *dev, void *data)
dev->driver_data = data;
}
+static inline unsigned int dev_get_uevent_suppress(const struct device *dev)
+{
+ return dev->kobj.uevent_suppress;
+}
+
+static inline void dev_set_uevent_suppress(struct device *dev, int val)
+{
+ dev->kobj.uevent_suppress = val;
+}
+
static inline int device_is_registered(struct device *dev)
{
return dev->kobj.state_in_sysfs;
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index c9c214d..58ae8e0 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -68,6 +68,7 @@ struct kobject {
unsigned int state_in_sysfs:1;
unsigned int state_add_uevent_sent:1;
unsigned int state_remove_uevent_sent:1;
+ unsigned int uevent_suppress:1;
};
extern int kobject_set_name(struct kobject *kobj, const char *name, ...)
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 318328d..b2181cc 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,
kset = top_kobj->kset;
uevent_ops = kset->uevent_ops;
+ /* skip the event, if uevent_suppress is set*/
+ if (kobj->uevent_suppress) {
+ pr_debug("kobject: '%s' (%p): %s: uevent_suppress "
+ "caused the event to drop!\n",
+ kobject_name(kobj), kobj, __func__);
+ return 0;
+ }
/* skip the event, if the filter returns zero. */
if (uevent_ops && uevent_ops->filter)
if (!uevent_ops->filter(kset, kobj)) {
--
1.6.2
next prev parent reply other threads:[~2009-03-25 0:49 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-25 0:16 [GIT PATCH] driver core patches for 2.6.30 merge window Greg KH
2009-03-25 0:26 ` [PATCH 01/61] edac: struct device - replace bus_id with dev_name(), dev_set_name() Greg Kroah-Hartman
[not found] ` <20090325001659.GA22461-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2009-03-25 0:26 ` [PATCH 02/61] spi: " Greg Kroah-Hartman
2009-03-25 0:26 ` Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 03/61] video: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 04/61] zorro: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 05/61] mmc: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 06/61] mtd: " Greg Kroah-Hartman
2009-03-25 0:26 ` Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 07/61] pci: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 08/61] rapidio: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 09/61] s390: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 10/61] serial: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 11/61] sh: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 12/61] tc: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 13/61] pcmcia: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 14/61] rtc: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 15/61] net: " Greg Kroah-Hartman
2009-03-25 3:31 ` Stephen Hemminger
2009-03-25 4:18 ` Greg KH
2009-03-25 6:29 ` David Miller
2009-03-25 9:34 ` Kay Sievers
2009-03-25 9:34 ` Kay Sievers
2009-03-25 0:26 ` [PATCH 16/61] drm: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 17/61] v4l: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 18/61] amba: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 19/61] dio: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 20/61] dma: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 21/61] eisa: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 22/61] gpio: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 23/61] mca: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 24/61] mfd: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 25/61] wimax: " Greg Kroah-Hartman
2009-03-25 1:22 ` Perez-Gonzalez, Inaky
2009-03-25 0:26 ` [PATCH 26/61] usb: " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 27/61] PS3: replace bus_id usage Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 28/61] USB: FHCI: use dev_name() in place of bus_id Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 29/61] driver core: get rid of struct device's bus_id string array Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 30/61] SYSFS: use standard magic.h for sysfs Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 31/61] sysfs: Take sysfs_mutex when fetching the root inode Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 32/61] driver core: check bus->match without holding device lock Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 33/61] platform: make better use of to_platform_{device,driver}() macros Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 34/61] platform: introduce module id table for platform devices Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 35/61] UIO: Add name attributes for mappings and port regions Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 36/61] uio: add the uio_aec driver Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 37/61] UIO: Take offset into account when determining number of pages that can be mapped Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 38/61] platform driver: fix incorrect use of 'platform_bus_type' with 'struct device_driver' Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 39/61] scsi/m68k: Kill NCR_700_detect() warnings Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 40/61] driver-core: do not register a driver with bus_type not registered Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 41/61] sysfs: sysfs_add_one WARNs with full path to duplicate filename Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 42/61] sysfs: reference sysfs_dirent from sysfs inodes Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 43/61] driver core: remove polling for driver_probe_done(v5) Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 44/61] driver core: create a private portion of struct device Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 45/61] driver core: move klist_children into private structure Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 46/61] driver core: move knode_driver " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 47/61] driver core: move knode_bus " Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 48/61] sysfs: don't block indefinitely for unmapped files Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 49/61] driver core: move platform_data into platform_device Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 50/61] driver core: fix passing platform_data Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 51/61] vcs: hook sysfs devices into object lifetime instead of "binding" Greg Kroah-Hartman
2009-03-25 0:26 ` Greg Kroah-Hartman [this message]
2009-03-25 0:26 ` [PATCH 53/61] Driver core: some cleanup on drivers/base/sys.c Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 54/61] Driver core: Fix device_move() vs. dpm list ordering, v2 Greg Kroah-Hartman
2009-03-25 0:26 ` [PATCH 55/61] sysfs: only allow one scheduled removal callback per kobj Greg Kroah-Hartman
2009-03-25 0:27 ` [PATCH 56/61] kobject: don't block for each kobject_uevent Greg Kroah-Hartman
2009-03-25 0:27 ` [PATCH 57/61] sysfs: fix some bin_vm_ops errors Greg Kroah-Hartman
2009-03-25 0:27 ` [PATCH 58/61] dynamic debug: combine dprintk and dynamic printk Greg Kroah-Hartman
2009-03-25 10:50 ` Ingo Molnar
2009-03-25 13:20 ` Jason Baron
2009-03-25 0:27 ` [PATCH 59/61] dynamic debug: update docs Greg Kroah-Hartman
2009-03-25 0:27 ` [PATCH 60/61] Dynamic debug: allow simple quoting of words Greg Kroah-Hartman
2009-03-25 0:27 ` [PATCH 61/61] Dynamic debug: fix pr_fmt() build error Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1237940825-22904-52-git-send-email-gregkh@suse.de \
--to=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=tom.leiming@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.