diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-08-14 09:15:12 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-12 17:51:01 -0400 |
commit | 7eff2e7a8b65c25920207324e56611150eb1cd9a (patch) | |
tree | 02a0eeba9d25d996233e30c18f258dfae0ae2139 /drivers/w1 | |
parent | 8380770c842faef3001e44662953d64ad9a93663 (diff) |
Driver core: change add_uevent_var to use a struct
This changes the uevent buffer functions to use a struct instead of a
long list of parameters. It does no longer require the caller to do the
proper buffer termination and size accounting, which is currently wrong
in some places. It fixes a known bug where parts of the uevent
environment are overwritten because of wrong index calculations.
Many thanks to Mathieu Desnoyers for finding bugs and improving the
error handling.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/w1')
-rw-r--r-- | drivers/w1/w1.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index a593f900eff4..070217322c9f 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c | |||
@@ -197,7 +197,7 @@ static struct w1_family w1_default_family = { | |||
197 | .fops = &w1_default_fops, | 197 | .fops = &w1_default_fops, |
198 | }; | 198 | }; |
199 | 199 | ||
200 | static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); | 200 | static int w1_uevent(struct device *dev, struct kobj_uevent_env *env); |
201 | 201 | ||
202 | static struct bus_type w1_bus_type = { | 202 | static struct bus_type w1_bus_type = { |
203 | .name = "w1", | 203 | .name = "w1", |
@@ -396,13 +396,12 @@ static void w1_destroy_master_attributes(struct w1_master *master) | |||
396 | } | 396 | } |
397 | 397 | ||
398 | #ifdef CONFIG_HOTPLUG | 398 | #ifdef CONFIG_HOTPLUG |
399 | static int w1_uevent(struct device *dev, char **envp, int num_envp, | 399 | static int w1_uevent(struct device *dev, struct kobj_uevent_env *env) |
400 | char *buffer, int buffer_size) | ||
401 | { | 400 | { |
402 | struct w1_master *md = NULL; | 401 | struct w1_master *md = NULL; |
403 | struct w1_slave *sl = NULL; | 402 | struct w1_slave *sl = NULL; |
404 | char *event_owner, *name; | 403 | char *event_owner, *name; |
405 | int err, cur_index=0, cur_len=0; | 404 | int err; |
406 | 405 | ||
407 | if (dev->driver == &w1_master_driver) { | 406 | if (dev->driver == &w1_master_driver) { |
408 | md = container_of(dev, struct w1_master, dev); | 407 | md = container_of(dev, struct w1_master, dev); |
@@ -423,23 +422,19 @@ static int w1_uevent(struct device *dev, char **envp, int num_envp, | |||
423 | if (dev->driver != &w1_slave_driver || !sl) | 422 | if (dev->driver != &w1_slave_driver || !sl) |
424 | return 0; | 423 | return 0; |
425 | 424 | ||
426 | err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size, | 425 | err = add_uevent_var(env, "W1_FID=%02X", sl->reg_num.family); |
427 | &cur_len, "W1_FID=%02X", sl->reg_num.family); | ||
428 | if (err) | 426 | if (err) |
429 | return err; | 427 | return err; |
430 | 428 | ||
431 | err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size, | 429 | err = add_uevent_var(env, "W1_SLAVE_ID=%024LX", |
432 | &cur_len, "W1_SLAVE_ID=%024LX", | 430 | (unsigned long long)sl->reg_num.id); |
433 | (unsigned long long)sl->reg_num.id); | ||
434 | envp[cur_index] = NULL; | ||
435 | if (err) | 431 | if (err) |
436 | return err; | 432 | return err; |
437 | 433 | ||
438 | return 0; | 434 | return 0; |
439 | }; | 435 | }; |
440 | #else | 436 | #else |
441 | static int w1_uevent(struct device *dev, char **envp, int num_envp, | 437 | static int w1_uevent(struct device *dev, struct kobj_uevent_env *env) |
442 | char *buffer, int buffer_size) | ||
443 | { | 438 | { |
444 | return 0; | 439 | return 0; |
445 | } | 440 | } |