diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-07-08 16:29:26 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-18 18:49:49 -0400 |
commit | 60a96a59569bab85571d0089682109bd3324e896 (patch) | |
tree | b70d0174ddae44224ae5c8cea90231e659beff30 /lib | |
parent | a6bb340da32f0abf76656be1619fb85150eef61b (diff) |
Driver core: accept all valid action-strings in uevent-trigger
This allows the uevent file to handle any type of uevent action to be
triggered by userspace instead of just the "add" uevent.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kobject_uevent.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index bd5ecbbafab1..6a80c784a8fb 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c | |||
@@ -33,25 +33,15 @@ static DEFINE_SPINLOCK(sequence_lock); | |||
33 | static struct sock *uevent_sock; | 33 | static struct sock *uevent_sock; |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | static char *action_to_string(enum kobject_action action) | 36 | /* the strings here must match the enum in include/linux/kobject.h */ |
37 | { | 37 | const char *kobject_actions[] = { |
38 | switch (action) { | 38 | "add", |
39 | case KOBJ_ADD: | 39 | "remove", |
40 | return "add"; | 40 | "change", |
41 | case KOBJ_REMOVE: | 41 | "move", |
42 | return "remove"; | 42 | "online", |
43 | case KOBJ_CHANGE: | 43 | "offline", |
44 | return "change"; | 44 | }; |
45 | case KOBJ_OFFLINE: | ||
46 | return "offline"; | ||
47 | case KOBJ_ONLINE: | ||
48 | return "online"; | ||
49 | case KOBJ_MOVE: | ||
50 | return "move"; | ||
51 | default: | ||
52 | return NULL; | ||
53 | } | ||
54 | } | ||
55 | 45 | ||
56 | /** | 46 | /** |
57 | * kobject_uevent_env - send an uevent with environmental data | 47 | * kobject_uevent_env - send an uevent with environmental data |
@@ -83,7 +73,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
83 | 73 | ||
84 | pr_debug("%s\n", __FUNCTION__); | 74 | pr_debug("%s\n", __FUNCTION__); |
85 | 75 | ||
86 | action_string = action_to_string(action); | 76 | action_string = kobject_actions[action]; |
87 | if (!action_string) { | 77 | if (!action_string) { |
88 | pr_debug("kobject attempted to send uevent without action_string!\n"); | 78 | pr_debug("kobject attempted to send uevent without action_string!\n"); |
89 | return -EINVAL; | 79 | return -EINVAL; |