aboutsummaryrefslogtreecommitdiffstats
path: root/net/rfkill
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2008-06-23 16:23:05 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-06-26 14:21:21 -0400
commitffb67c34e436fb163c4067936ccec797354fa6c6 (patch)
tree58553e810c7d55595c82d6d397fa4027be1da7ae /net/rfkill
parent99c632e5a304e1f76350eb9e8b2493514de8b60c (diff)
rfkill: add uevent notifications
Use the notification chains to also send uevents, so that userspace can be notified of state changes of every rfkill switch. Userspace should use these events for OSD/status report applications and rfkill GUI frontends. HAL might want to broadcast them over DBUS, for example. It might be also useful for userspace implementations of rfkill-input, or to use HAL as the platform driver which promotes rfkill switch change events into input events (to synchronize all other switches) when necessary for platforms that lack a convenient platform-specific kernel module to do it. Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Acked-by: Ivo van Doorn <IvDoorn@gmail.com> Cc: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/rfkill')
-rw-r--r--net/rfkill/rfkill.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index 3c7773475ea6..dd1c3f18f31d 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -386,12 +386,51 @@ static int rfkill_resume(struct device *dev)
386#define rfkill_resume NULL 386#define rfkill_resume NULL
387#endif 387#endif
388 388
389static int rfkill_blocking_uevent_notifier(struct notifier_block *nb,
390 unsigned long eventid,
391 void *data)
392{
393 struct rfkill *rfkill = (struct rfkill *)data;
394
395 switch (eventid) {
396 case RFKILL_STATE_CHANGED:
397 kobject_uevent(&rfkill->dev.kobj, KOBJ_CHANGE);
398 break;
399 default:
400 break;
401 }
402
403 return NOTIFY_DONE;
404}
405
406static struct notifier_block rfkill_blocking_uevent_nb = {
407 .notifier_call = rfkill_blocking_uevent_notifier,
408 .priority = 0,
409};
410
411static int rfkill_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
412{
413 struct rfkill *rfkill = to_rfkill(dev);
414 int error;
415
416 error = add_uevent_var(env, "RFKILL_NAME=%s", rfkill->name);
417 if (error)
418 return error;
419 error = add_uevent_var(env, "RFKILL_TYPE=%s",
420 rfkill_get_type_str(rfkill->type));
421 if (error)
422 return error;
423 error = add_uevent_var(env, "RFKILL_STATE=%d", rfkill->state);
424 return error;
425}
426
389static struct class rfkill_class = { 427static struct class rfkill_class = {
390 .name = "rfkill", 428 .name = "rfkill",
391 .dev_release = rfkill_release, 429 .dev_release = rfkill_release,
392 .dev_attrs = rfkill_dev_attrs, 430 .dev_attrs = rfkill_dev_attrs,
393 .suspend = rfkill_suspend, 431 .suspend = rfkill_suspend,
394 .resume = rfkill_resume, 432 .resume = rfkill_resume,
433 .dev_uevent = rfkill_dev_uevent,
395}; 434};
396 435
397static int rfkill_add_switch(struct rfkill *rfkill) 436static int rfkill_add_switch(struct rfkill *rfkill)
@@ -566,11 +605,14 @@ static int __init rfkill_init(void)
566 return error; 605 return error;
567 } 606 }
568 607
608 register_rfkill_notifier(&rfkill_blocking_uevent_nb);
609
569 return 0; 610 return 0;
570} 611}
571 612
572static void __exit rfkill_exit(void) 613static void __exit rfkill_exit(void)
573{ 614{
615 unregister_rfkill_notifier(&rfkill_blocking_uevent_nb);
574 class_unregister(&rfkill_class); 616 class_unregister(&rfkill_class);
575} 617}
576 618