aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/kobject.c4
-rw-r--r--lib/kobject_uevent.c64
2 files changed, 34 insertions, 34 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index a181abed89f6..7a0e6809490d 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -207,7 +207,7 @@ int kobject_register(struct kobject * kobj)
207 kobject_name(kobj),error); 207 kobject_name(kobj),error);
208 dump_stack(); 208 dump_stack();
209 } else 209 } else
210 kobject_hotplug(kobj, KOBJ_ADD); 210 kobject_uevent(kobj, KOBJ_ADD);
211 } else 211 } else
212 error = -EINVAL; 212 error = -EINVAL;
213 return error; 213 return error;
@@ -312,7 +312,7 @@ void kobject_del(struct kobject * kobj)
312void kobject_unregister(struct kobject * kobj) 312void kobject_unregister(struct kobject * kobj)
313{ 313{
314 pr_debug("kobject %s: unregistering\n",kobject_name(kobj)); 314 pr_debug("kobject %s: unregistering\n",kobject_name(kobj));
315 kobject_hotplug(kobj, KOBJ_REMOVE); 315 kobject_uevent(kobj, KOBJ_REMOVE);
316 kobject_del(kobj); 316 kobject_del(kobj);
317 kobject_put(kobj); 317 kobject_put(kobj);
318} 318}
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index dd061da3aba9..01479e5c6d18 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -22,12 +22,12 @@
22#include <linux/kobject.h> 22#include <linux/kobject.h>
23#include <net/sock.h> 23#include <net/sock.h>
24 24
25#define BUFFER_SIZE 1024 /* buffer for the hotplug env */ 25#define BUFFER_SIZE 1024 /* buffer for the variables */
26#define NUM_ENVP 32 /* number of env pointers */ 26#define NUM_ENVP 32 /* number of env pointers */
27 27
28#if defined(CONFIG_HOTPLUG) 28#if defined(CONFIG_HOTPLUG)
29char hotplug_path[HOTPLUG_PATH_LEN] = "/sbin/hotplug"; 29char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug";
30u64 hotplug_seqnum; 30u64 uevent_seqnum;
31static DEFINE_SPINLOCK(sequence_lock); 31static DEFINE_SPINLOCK(sequence_lock);
32static struct sock *uevent_sock; 32static struct sock *uevent_sock;
33 33
@@ -50,12 +50,12 @@ static char *action_to_string(enum kobject_action action)
50} 50}
51 51
52/** 52/**
53 * kobject_hotplug - notify userspace by executing /sbin/hotplug 53 * kobject_uevent - notify userspace by ending an uevent
54 * 54 *
55 * @action: action that is happening (usually "ADD" or "REMOVE") 55 * @action: action that is happening (usually KOBJ_ADD and KOBJ_REMOVE)
56 * @kobj: struct kobject that the action is happening to 56 * @kobj: struct kobject that the action is happening to
57 */ 57 */
58void kobject_hotplug(struct kobject *kobj, enum kobject_action action) 58void kobject_uevent(struct kobject *kobj, enum kobject_action action)
59{ 59{
60 char **envp; 60 char **envp;
61 char *buffer; 61 char *buffer;
@@ -65,7 +65,7 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
65 const char *subsystem; 65 const char *subsystem;
66 struct kobject *top_kobj; 66 struct kobject *top_kobj;
67 struct kset *kset; 67 struct kset *kset;
68 struct kset_hotplug_ops *hotplug_ops; 68 struct kset_uevent_ops *uevent_ops;
69 u64 seq; 69 u64 seq;
70 char *seq_buff; 70 char *seq_buff;
71 int i = 0; 71 int i = 0;
@@ -88,11 +88,11 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
88 return; 88 return;
89 89
90 kset = top_kobj->kset; 90 kset = top_kobj->kset;
91 hotplug_ops = kset->hotplug_ops; 91 uevent_ops = kset->uevent_ops;
92 92
93 /* skip the event, if the filter returns zero. */ 93 /* skip the event, if the filter returns zero. */
94 if (hotplug_ops && hotplug_ops->filter) 94 if (uevent_ops && uevent_ops->filter)
95 if (!hotplug_ops->filter(kset, kobj)) 95 if (!uevent_ops->filter(kset, kobj))
96 return; 96 return;
97 97
98 /* environment index */ 98 /* environment index */
@@ -111,8 +111,8 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
111 goto exit; 111 goto exit;
112 112
113 /* originating subsystem */ 113 /* originating subsystem */
114 if (hotplug_ops && hotplug_ops->name) 114 if (uevent_ops && uevent_ops->name)
115 subsystem = hotplug_ops->name(kset, kobj); 115 subsystem = uevent_ops->name(kset, kobj);
116 else 116 else
117 subsystem = kobject_name(&kset->kobj); 117 subsystem = kobject_name(&kset->kobj);
118 118
@@ -134,12 +134,12 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
134 scratch += strlen("SEQNUM=18446744073709551616") + 1; 134 scratch += strlen("SEQNUM=18446744073709551616") + 1;
135 135
136 /* let the kset specific function add its stuff */ 136 /* let the kset specific function add its stuff */
137 if (hotplug_ops && hotplug_ops->hotplug) { 137 if (uevent_ops && uevent_ops->uevent) {
138 retval = hotplug_ops->hotplug (kset, kobj, 138 retval = uevent_ops->uevent(kset, kobj,
139 &envp[i], NUM_ENVP - i, scratch, 139 &envp[i], NUM_ENVP - i, scratch,
140 BUFFER_SIZE - (scratch - buffer)); 140 BUFFER_SIZE - (scratch - buffer));
141 if (retval) { 141 if (retval) {
142 pr_debug ("%s - hotplug() returned %d\n", 142 pr_debug ("%s - uevent() returned %d\n",
143 __FUNCTION__, retval); 143 __FUNCTION__, retval);
144 goto exit; 144 goto exit;
145 } 145 }
@@ -147,7 +147,7 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
147 147
148 /* we will send an event, request a new sequence number */ 148 /* we will send an event, request a new sequence number */
149 spin_lock(&sequence_lock); 149 spin_lock(&sequence_lock);
150 seq = ++hotplug_seqnum; 150 seq = ++uevent_seqnum;
151 spin_unlock(&sequence_lock); 151 spin_unlock(&sequence_lock);
152 sprintf(seq_buff, "SEQNUM=%llu", (unsigned long long)seq); 152 sprintf(seq_buff, "SEQNUM=%llu", (unsigned long long)seq);
153 153
@@ -177,10 +177,10 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
177 } 177 }
178 178
179 /* call uevent_helper, usually only enabled during early boot */ 179 /* call uevent_helper, usually only enabled during early boot */
180 if (hotplug_path[0]) { 180 if (uevent_helper[0]) {
181 char *argv [3]; 181 char *argv [3];
182 182
183 argv [0] = hotplug_path; 183 argv [0] = uevent_helper;
184 argv [1] = (char *)subsystem; 184 argv [1] = (char *)subsystem;
185 argv [2] = NULL; 185 argv [2] = NULL;
186 call_usermodehelper (argv[0], argv, envp, 0); 186 call_usermodehelper (argv[0], argv, envp, 0);
@@ -192,39 +192,39 @@ exit:
192 kfree(envp); 192 kfree(envp);
193 return; 193 return;
194} 194}
195EXPORT_SYMBOL(kobject_hotplug); 195EXPORT_SYMBOL_GPL(kobject_uevent);
196 196
197/** 197/**
198 * add_hotplug_env_var - helper for creating hotplug environment variables 198 * add_uevent_var - helper for creating event variables
199 * @envp: Pointer to table of environment variables, as passed into 199 * @envp: Pointer to table of environment variables, as passed into
200 * hotplug() method. 200 * uevent() method.
201 * @num_envp: Number of environment variable slots available, as 201 * @num_envp: Number of environment variable slots available, as
202 * passed into hotplug() method. 202 * passed into uevent() method.
203 * @cur_index: Pointer to current index into @envp. It should be 203 * @cur_index: Pointer to current index into @envp. It should be
204 * initialized to 0 before the first call to add_hotplug_env_var(), 204 * initialized to 0 before the first call to add_uevent_var(),
205 * and will be incremented on success. 205 * and will be incremented on success.
206 * @buffer: Pointer to buffer for environment variables, as passed 206 * @buffer: Pointer to buffer for environment variables, as passed
207 * into hotplug() method. 207 * into uevent() method.
208 * @buffer_size: Length of @buffer, as passed into hotplug() method. 208 * @buffer_size: Length of @buffer, as passed into uevent() method.
209 * @cur_len: Pointer to current length of space used in @buffer. 209 * @cur_len: Pointer to current length of space used in @buffer.
210 * Should be initialized to 0 before the first call to 210 * Should be initialized to 0 before the first call to
211 * add_hotplug_env_var(), and will be incremented on success. 211 * add_uevent_var(), and will be incremented on success.
212 * @format: Format for creating environment variable (of the form 212 * @format: Format for creating environment variable (of the form
213 * "XXX=%x") for snprintf(). 213 * "XXX=%x") for snprintf().
214 * 214 *
215 * Returns 0 if environment variable was added successfully or -ENOMEM 215 * Returns 0 if environment variable was added successfully or -ENOMEM
216 * if no space was available. 216 * if no space was available.
217 */ 217 */
218int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, 218int add_uevent_var(char **envp, int num_envp, int *cur_index,
219 char *buffer, int buffer_size, int *cur_len, 219 char *buffer, int buffer_size, int *cur_len,
220 const char *format, ...) 220 const char *format, ...)
221{ 221{
222 va_list args; 222 va_list args;
223 223
224 /* 224 /*
225 * We check against num_envp - 1 to make sure there is at 225 * We check against num_envp - 1 to make sure there is at
226 * least one slot left after we return, since the hotplug 226 * least one slot left after we return, since kobject_uevent()
227 * method needs to set the last slot to NULL. 227 * needs to set the last slot to NULL.
228 */ 228 */
229 if (*cur_index >= num_envp - 1) 229 if (*cur_index >= num_envp - 1)
230 return -ENOMEM; 230 return -ENOMEM;
@@ -243,7 +243,7 @@ int add_hotplug_env_var(char **envp, int num_envp, int *cur_index,
243 (*cur_index)++; 243 (*cur_index)++;
244 return 0; 244 return 0;
245} 245}
246EXPORT_SYMBOL(add_hotplug_env_var); 246EXPORT_SYMBOL_GPL(add_uevent_var);
247 247
248static int __init kobject_uevent_init(void) 248static int __init kobject_uevent_init(void)
249{ 249{