* [PATCH 1/2] net: rfkill: Cleanup error handling in rfkill_init()
@ 2016-11-30 12:03 Michał Kępień
       [not found] ` <20161130120317.11851-1-kernel-ePNcKBjznIDVItvQsEIGlw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Michał Kępień @ 2016-11-30 12:03 UTC (permalink / raw)
  To: Johannes Berg, David S . Miller; +Cc: linux-wireless, netdev, linux-kernel
Use a separate label per error condition in rfkill_init() to make it a
bit cleaner and easier to extend.
Signed-off-by: Michał Kępień <kernel@kempniu.pl>
---
 net/rfkill/core.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 884027f..f28e441 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -1266,24 +1266,25 @@ static int __init rfkill_init(void)
 
 	error = class_register(&rfkill_class);
 	if (error)
-		goto out;
+		goto error_class;
 
 	error = misc_register(&rfkill_miscdev);
-	if (error) {
-		class_unregister(&rfkill_class);
-		goto out;
-	}
+	if (error)
+		goto error_misc;
 
 #ifdef CONFIG_RFKILL_INPUT
 	error = rfkill_handler_init();
-	if (error) {
-		misc_deregister(&rfkill_miscdev);
-		class_unregister(&rfkill_class);
-		goto out;
-	}
+	if (error)
+		goto error_input;
 #endif
 
- out:
+	return 0;
+
+error_input:
+	misc_deregister(&rfkill_miscdev);
+error_misc:
+	class_unregister(&rfkill_class);
+error_class:
 	return error;
 }
 subsys_initcall(rfkill_init);
-- 
2.10.2
^ permalink raw reply related	[flat|nested] 6+ messages in thread[parent not found: <20161130120317.11851-1-kernel-ePNcKBjznIDVItvQsEIGlw@public.gmane.org>]
* [PATCH 2/2] net: rfkill: Add rfkill-any LED trigger [not found] ` <20161130120317.11851-1-kernel-ePNcKBjznIDVItvQsEIGlw@public.gmane.org> @ 2016-11-30 12:03 ` Michał Kępień 2016-12-01 17:29 ` kbuild test robot 2016-12-01 18:06 ` kbuild test robot 0 siblings, 2 replies; 6+ messages in thread From: Michał Kępień @ 2016-11-30 12:03 UTC (permalink / raw) To: Johannes Berg, David S . Miller Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA This patch adds a new "global" (i.e. not per-rfkill device) LED trigger, rfkill-any, which may be useful for laptops with a single "radio LED" and multiple radio transmitters. The trigger is meant to turn a LED on whenever there is at least one radio transmitter active and turn it off otherwise. Signed-off-by: Michał Kępień <kernel-ePNcKBjznIDVItvQsEIGlw@public.gmane.org> --- Note that the search for any active radio will have quadratic complexity whenever __rfkill_switch_all() is used (as it calls rfkill_set_block() for every affected rfkill device), but I intentionally refrained from implementing rfkill_any_led_trigger_event() using struct work_struct to keep things simple, given the average number of rfkill devices in hardware these days. Please let me know in case this should be reworked. net/rfkill/core.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/net/rfkill/core.c b/net/rfkill/core.c index f28e441..5275f2f 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -176,6 +176,47 @@ static void rfkill_led_trigger_unregister(struct rfkill *rfkill) { led_trigger_unregister(&rfkill->led_trigger); } + +static struct led_trigger rfkill_any_led_trigger; + +static void __rfkill_any_led_trigger_event(void) +{ + enum led_brightness brightness = LED_OFF; + struct rfkill *rfkill; + + list_for_each_entry(rfkill, &rfkill_list, node) { + if (!(rfkill->state & RFKILL_BLOCK_ANY)) { + brightness = LED_FULL; + break; + } + } + + led_trigger_event(&rfkill_any_led_trigger, brightness); +} + +static void rfkill_any_led_trigger_event(void) +{ + mutex_lock(&rfkill_global_mutex); + __rfkill_any_led_trigger_event(); + mutex_unlock(&rfkill_global_mutex); +} + +static void rfkill_any_led_trigger_activate(struct led_classdev *led_cdev) +{ + rfkill_any_led_trigger_event(); +} + +static int rfkill_any_led_trigger_register(void) +{ + rfkill_any_led_trigger.name = "rfkill-any"; + rfkill_any_led_trigger.activate = rfkill_any_led_trigger_activate; + return led_trigger_register(&rfkill_any_led_trigger); +} + +static void rfkill_any_led_trigger_unregister(void) +{ + led_trigger_unregister(&rfkill_any_led_trigger); +} #else static void rfkill_led_trigger_event(struct rfkill *rfkill) { @@ -189,6 +230,19 @@ static inline int rfkill_led_trigger_register(struct rfkill *rfkill) static inline void rfkill_led_trigger_unregister(struct rfkill *rfkill) { } + +static void rfkill_any_led_trigger_event(void) +{ +} + +static int rfkill_any_led_trigger_register(void) +{ + return 0; +} + +static void rfkill_any_led_trigger_unregister(void) +{ +} #endif /* CONFIG_RFKILL_LEDS */ static void rfkill_fill_event(struct rfkill_event *ev, struct rfkill *rfkill, @@ -297,6 +351,7 @@ static void rfkill_set_block(struct rfkill *rfkill, bool blocked) spin_unlock_irqrestore(&rfkill->lock, flags); rfkill_led_trigger_event(rfkill); + __rfkill_any_led_trigger_event(); if (prev != curr) rfkill_event(rfkill); @@ -477,6 +532,7 @@ bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked) spin_unlock_irqrestore(&rfkill->lock, flags); rfkill_led_trigger_event(rfkill); + rfkill_any_led_trigger_event(); if (!rfkill->registered) return ret; @@ -523,6 +579,7 @@ bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked) schedule_work(&rfkill->uevent_work); rfkill_led_trigger_event(rfkill); + rfkill_any_led_trigger_event(); return blocked; } @@ -572,6 +629,7 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw) schedule_work(&rfkill->uevent_work); rfkill_led_trigger_event(rfkill); + rfkill_any_led_trigger_event(); } } EXPORT_SYMBOL(rfkill_set_states); @@ -988,6 +1046,7 @@ int __must_check rfkill_register(struct rfkill *rfkill) #endif } + __rfkill_any_led_trigger_event(); rfkill_send_events(rfkill, RFKILL_OP_ADD); mutex_unlock(&rfkill_global_mutex); @@ -1020,6 +1079,7 @@ void rfkill_unregister(struct rfkill *rfkill) mutex_lock(&rfkill_global_mutex); rfkill_send_events(rfkill, RFKILL_OP_DEL); list_del_init(&rfkill->node); + __rfkill_any_led_trigger_event(); mutex_unlock(&rfkill_global_mutex); rfkill_led_trigger_unregister(rfkill); @@ -1278,8 +1338,18 @@ static int __init rfkill_init(void) goto error_input; #endif +#ifdef CONFIG_RFKILL_LEDS + error = rfkill_any_led_trigger_register(); + if (error) + goto error_led_trigger; +#endif + return 0; +error_led_trigger: +#ifdef CONFIG_RFKILL_INPUT + rfkill_handler_exit(); +#endif error_input: misc_deregister(&rfkill_miscdev); error_misc: @@ -1291,6 +1361,9 @@ subsys_initcall(rfkill_init); static void __exit rfkill_exit(void) { +#ifdef CONFIG_RFKILL_LEDS + rfkill_any_led_trigger_unregister(); +#endif #ifdef CONFIG_RFKILL_INPUT rfkill_handler_exit(); #endif -- 2.10.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] net: rfkill: Add rfkill-any LED trigger 2016-11-30 12:03 ` [PATCH 2/2] net: rfkill: Add rfkill-any LED trigger Michał Kępień @ 2016-12-01 17:29 ` kbuild test robot 2016-12-01 20:08 ` Michał Kępień 2016-12-01 18:06 ` kbuild test robot 1 sibling, 1 reply; 6+ messages in thread From: kbuild test robot @ 2016-12-01 17:29 UTC (permalink / raw) To: Michał Kępień Cc: kbuild-all, Johannes Berg, David S . Miller, linux-wireless, netdev, linux-kernel [-- Attachment #1: Type: text/plain, Size: 2205 bytes --] Hi Michał, [auto build test ERROR on mac80211-next/master] [also build test ERROR on v4.9-rc7 next-20161201] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Micha-K-pie/net-rfkill-Cleanup-error-handling-in-rfkill_init/20161202-002119 base: https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master config: i386-randconfig-x004-201648 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=i386 All errors (new ones prefixed by >>): net/rfkill/core.c: In function 'rfkill_set_block': >> net/rfkill/core.c:354:2: error: implicit declaration of function '__rfkill_any_led_trigger_event' [-Werror=implicit-function-declaration] __rfkill_any_led_trigger_event(); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ net/rfkill/core.c: In function 'rfkill_init': net/rfkill/core.c:1349:1: warning: label 'error_led_trigger' defined but not used [-Wunused-label] error_led_trigger: ^~~~~~~~~~~~~~~~~ At top level: net/rfkill/core.c:243:13: warning: 'rfkill_any_led_trigger_unregister' defined but not used [-Wunused-function] static void rfkill_any_led_trigger_unregister(void) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ net/rfkill/core.c:238:12: warning: 'rfkill_any_led_trigger_register' defined but not used [-Wunused-function] static int rfkill_any_led_trigger_register(void) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors vim +/__rfkill_any_led_trigger_event +354 net/rfkill/core.c 348 rfkill->state &= ~RFKILL_BLOCK_SW_SETCALL; 349 rfkill->state &= ~RFKILL_BLOCK_SW_PREV; 350 curr = rfkill->state & RFKILL_BLOCK_SW; 351 spin_unlock_irqrestore(&rfkill->lock, flags); 352 353 rfkill_led_trigger_event(rfkill); > 354 __rfkill_any_led_trigger_event(); 355 356 if (prev != curr) 357 rfkill_event(rfkill); --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 26068 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] net: rfkill: Add rfkill-any LED trigger 2016-12-01 17:29 ` kbuild test robot @ 2016-12-01 20:08 ` Michał Kępień [not found] ` <20161201200804.GA3872-d0zqvqtRkg7MisJl3QRgO5JNpPtI3pG4@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Michał Kępień @ 2016-12-01 20:08 UTC (permalink / raw) To: kbuild test robot Cc: kbuild-all, Johannes Berg, David S . Miller, linux-wireless, netdev, linux-kernel > Hi Michał, > > [auto build test ERROR on mac80211-next/master] > [also build test ERROR on v4.9-rc7 next-20161201] > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] > > url: https://github.com/0day-ci/linux/commits/Micha-K-pie/net-rfkill-Cleanup-error-handling-in-rfkill_init/20161202-002119 > base: https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master > config: i386-randconfig-x004-201648 (attached as .config) > compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 > reproduce: > # save the attached .config to linux build tree > make ARCH=i386 > > All errors (new ones prefixed by >>): > > net/rfkill/core.c: In function 'rfkill_set_block': > >> net/rfkill/core.c:354:2: error: implicit declaration of function '__rfkill_any_led_trigger_event' [-Werror=implicit-function-declaration] > __rfkill_any_led_trigger_event(); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > net/rfkill/core.c: In function 'rfkill_init': > net/rfkill/core.c:1349:1: warning: label 'error_led_trigger' defined but not used [-Wunused-label] > error_led_trigger: > ^~~~~~~~~~~~~~~~~ > At top level: > net/rfkill/core.c:243:13: warning: 'rfkill_any_led_trigger_unregister' defined but not used [-Wunused-function] > static void rfkill_any_led_trigger_unregister(void) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > net/rfkill/core.c:238:12: warning: 'rfkill_any_led_trigger_register' defined but not used [-Wunused-function] > static int rfkill_any_led_trigger_register(void) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > cc1: some warnings being treated as errors > > vim +/__rfkill_any_led_trigger_event +354 net/rfkill/core.c > > 348 rfkill->state &= ~RFKILL_BLOCK_SW_SETCALL; > 349 rfkill->state &= ~RFKILL_BLOCK_SW_PREV; > 350 curr = rfkill->state & RFKILL_BLOCK_SW; > 351 spin_unlock_irqrestore(&rfkill->lock, flags); > 352 > 353 rfkill_led_trigger_event(rfkill); > > 354 __rfkill_any_led_trigger_event(); > 355 > 356 if (prev != curr) > 357 rfkill_event(rfkill); Thanks, these are obviously all valid concerns. Sorry for being sloppy with the ifdefs. If I get positive feedback on the proposed feature itself, all these issues (and the warning pointed out in the other message) will be resolved in v2. -- Best regards, Michał Kępień ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20161201200804.GA3872-d0zqvqtRkg7MisJl3QRgO5JNpPtI3pG4@public.gmane.org>]
* Re: [PATCH 2/2] net: rfkill: Add rfkill-any LED trigger [not found] ` <20161201200804.GA3872-d0zqvqtRkg7MisJl3QRgO5JNpPtI3pG4@public.gmane.org> @ 2016-12-05 13:54 ` Johannes Berg 0 siblings, 0 replies; 6+ messages in thread From: Johannes Berg @ 2016-12-05 13:54 UTC (permalink / raw) To: Michał Kępień, kbuild test robot Cc: kbuild-all-JC7UmRfGjtg, David S . Miller, linux-wireless-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA > Thanks, these are obviously all valid concerns. Sorry for being > sloppy > with the ifdefs. If I get positive feedback on the proposed feature > itself, all these issues (and the warning pointed out in the other > message) will be resolved in v2. Looks fine, please do that. johannes ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] net: rfkill: Add rfkill-any LED trigger 2016-11-30 12:03 ` [PATCH 2/2] net: rfkill: Add rfkill-any LED trigger Michał Kępień 2016-12-01 17:29 ` kbuild test robot @ 2016-12-01 18:06 ` kbuild test robot 1 sibling, 0 replies; 6+ messages in thread From: kbuild test robot @ 2016-12-01 18:06 UTC (permalink / raw) To: Michał Kępień Cc: kbuild-all, Johannes Berg, David S . Miller, linux-wireless, netdev, linux-kernel [-- Attachment #1: Type: text/plain, Size: 1459 bytes --] Hi Michał, [auto build test WARNING on mac80211-next/master] [also build test WARNING on v4.9-rc7 next-20161201] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Micha-K-pie/net-rfkill-Cleanup-error-handling-in-rfkill_init/20161202-002119 base: https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master config: blackfin-allmodconfig (attached as .config) compiler: bfin-uclinux-gcc (GCC) 6.2.0 reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=blackfin All warnings (new ones prefixed by >>): >> WARNING: net/rfkill/rfkill.o(.init.text+0xa2): Section mismatch in reference from the function _init_module() to the function .exit.text:_rfkill_handler_exit() The function __init _init_module() references a function __exit _rfkill_handler_exit(). This is often seen when error handling in the init function uses functionality in the exit path. The fix is often to remove the __exit annotation of _rfkill_handler_exit() so it may be used outside an exit section. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 42125 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-12-05 13:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-30 12:03 [PATCH 1/2] net: rfkill: Cleanup error handling in rfkill_init() Michał Kępień
     [not found] ` <20161130120317.11851-1-kernel-ePNcKBjznIDVItvQsEIGlw@public.gmane.org>
2016-11-30 12:03   ` [PATCH 2/2] net: rfkill: Add rfkill-any LED trigger Michał Kępień
2016-12-01 17:29     ` kbuild test robot
2016-12-01 20:08       ` Michał Kępień
     [not found]         ` <20161201200804.GA3872-d0zqvqtRkg7MisJl3QRgO5JNpPtI3pG4@public.gmane.org>
2016-12-05 13:54           ` Johannes Berg
2016-12-01 18:06     ` kbuild test robot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).