diff options
author | Michael Buesch <mb@bu3sch.de> | 2007-10-28 08:07:54 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-11-11 00:59:11 -0500 |
commit | 8a8f1c0437a77cce29c1cb6089f01f22a6d9ca6e (patch) | |
tree | aff63cd4d043135c50cccd43ee32db57f62e79b9 /net/rfkill/rfkill.c | |
parent | 8d8c90e3fd1f8895f6d48bdcb34ba69a1fe73616 (diff) |
rfkill: Register LED triggers before registering switch
Registering the switch triggers a LED event, so we must register
LED triggers before the switch.
This has a potential to fix a crash, depending on how the device
driver initializes the rfkill data structure.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/rfkill/rfkill.c')
-rw-r--r-- | net/rfkill/rfkill.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c index 51d151c0e962..c6a9412fe5bd 100644 --- a/net/rfkill/rfkill.c +++ b/net/rfkill/rfkill.c | |||
@@ -388,19 +388,20 @@ int rfkill_register(struct rfkill *rfkill) | |||
388 | if (!rfkill->toggle_radio) | 388 | if (!rfkill->toggle_radio) |
389 | return -EINVAL; | 389 | return -EINVAL; |
390 | 390 | ||
391 | snprintf(dev->bus_id, sizeof(dev->bus_id), | ||
392 | "rfkill%ld", (long)atomic_inc_return(&rfkill_no) - 1); | ||
393 | |||
394 | rfkill_led_trigger_register(rfkill); | ||
395 | |||
391 | error = rfkill_add_switch(rfkill); | 396 | error = rfkill_add_switch(rfkill); |
392 | if (error) | 397 | if (error) |
393 | return error; | 398 | return error; |
394 | 399 | ||
395 | snprintf(dev->bus_id, sizeof(dev->bus_id), | ||
396 | "rfkill%ld", (long)atomic_inc_return(&rfkill_no) - 1); | ||
397 | |||
398 | error = device_add(dev); | 400 | error = device_add(dev); |
399 | if (error) { | 401 | if (error) { |
400 | rfkill_remove_switch(rfkill); | 402 | rfkill_remove_switch(rfkill); |
401 | return error; | 403 | return error; |
402 | } | 404 | } |
403 | rfkill_led_trigger_register(rfkill); | ||
404 | 405 | ||
405 | return 0; | 406 | return 0; |
406 | } | 407 | } |
@@ -416,9 +417,9 @@ EXPORT_SYMBOL(rfkill_register); | |||
416 | */ | 417 | */ |
417 | void rfkill_unregister(struct rfkill *rfkill) | 418 | void rfkill_unregister(struct rfkill *rfkill) |
418 | { | 419 | { |
419 | rfkill_led_trigger_unregister(rfkill); | ||
420 | device_del(&rfkill->dev); | 420 | device_del(&rfkill->dev); |
421 | rfkill_remove_switch(rfkill); | 421 | rfkill_remove_switch(rfkill); |
422 | rfkill_led_trigger_unregister(rfkill); | ||
422 | put_device(&rfkill->dev); | 423 | put_device(&rfkill->dev); |
423 | } | 424 | } |
424 | EXPORT_SYMBOL(rfkill_unregister); | 425 | EXPORT_SYMBOL(rfkill_unregister); |