[SRU][Xenial][PATCH 0/1] rfkill: Add rfkill-any LED trigger

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[SRU][Xenial][PATCH 0/1] rfkill: Add rfkill-any LED trigger

Joseph Salisbury-3
BugLink: http://bugs.launchpad.net/bugs/1745130

== SRU Justification ==
This bug was reported against a Fujitsu u7x7 laptop series based on Skylake hardware.
It has a single rfkill button and a single LED for wlan and bluetooth. Both
drivers currently provide a single rfkill trigger, so the led could
just be assigned to one. This was resolved by mainline commit 9b8e34e211, which added a
"rfkill-any" led trigger to correctly handle the led with multiple
rfkill devices. That was added by one of the fujitsu-laptop maintainers and
the driver sets it as the default trigger.  
 
Commit 9b8e34e211b1 is in mainline as of 4.11-rc1.

== Fix ==
commit 9b8e34e211b15af429b72388a8f2b3b1823d172e
Author: Michał Kępień <[hidden email]>
Date:   Fri Jan 6 07:07:47 2017 +0100

    rfkill: Add rfkill-any LED trigger

== Regression Potential ==
Medium.  This commit affects all arches, but it has been in mainline since
4.11-rc1 with no reported issues.

== Test Case ==
A test kernel was built with this patch and tested by the original bug reporter.
The bug reporter states the test kernel resolved the bug.

Michał Kępień (1):
  rfkill: Add rfkill-any LED trigger

 net/rfkill/core.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

--
2.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[SRU][Xenial][PATCH 1/1] rfkill: Add rfkill-any LED trigger

Joseph Salisbury-3
From: Michał Kępień <[hidden email]>

BugLink: http://bugs.launchpad.net/bugs/1745130

Add a new "global" (i.e. not per-rfkill device) LED trigger, rfkill-any,
which may be useful on 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ń <[hidden email]>
Signed-off-by: Johannes Berg <[hidden email]>
(back ported from commit 9b8e34e211b15af429b72388a8f2b3b1823d172e)
Signed-off-by: Joseph Salisbury <[hidden email]>
---
 net/rfkill/core.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index cf5b69a..9e43ad9 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -174,6 +174,50 @@ static void rfkill_led_trigger_unregister(struct rfkill *rfkill)
 {
  led_trigger_unregister(&rfkill->led_trigger);
 }
+
+static struct led_trigger rfkill_any_led_trigger;
+static struct work_struct rfkill_any_work;
+
+static void rfkill_any_led_trigger_worker(struct work_struct *work)
+{
+ enum led_brightness brightness = LED_OFF;
+ struct rfkill *rfkill;
+
+ mutex_lock(&rfkill_global_mutex);
+ list_for_each_entry(rfkill, &rfkill_list, node) {
+ if (!(rfkill->state & RFKILL_BLOCK_ANY)) {
+ brightness = LED_FULL;
+ break;
+ }
+ }
+ mutex_unlock(&rfkill_global_mutex);
+
+ led_trigger_event(&rfkill_any_led_trigger, brightness);
+}
+
+static void rfkill_any_led_trigger_event(void)
+{
+ schedule_work(&rfkill_any_work);
+}
+
+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)
+{
+ INIT_WORK(&rfkill_any_work, rfkill_any_led_trigger_worker);
+ 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);
+ cancel_work_sync(&rfkill_any_work);
+}
 #else
 static void rfkill_led_trigger_event(struct rfkill *rfkill)
 {
@@ -187,6 +231,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,
@@ -318,6 +375,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);
@@ -487,6 +545,8 @@ bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked)
  if (!rfkill->registered)
  return ret;
 
+ rfkill_any_led_trigger_event();
+
  if (change)
  schedule_work(&rfkill->uevent_work);
 
@@ -529,6 +589,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;
 }
@@ -578,6 +639,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);
@@ -989,6 +1051,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);
@@ -1021,6 +1084,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);
@@ -1276,6 +1340,10 @@ static int __init rfkill_init(void)
  goto out;
  }
 
+ error = rfkill_any_led_trigger_register();
+ if (error)
+ goto error_led_trigger;
+
 #ifdef CONFIG_RFKILL_INPUT
  error = rfkill_handler_init();
  if (error) {
@@ -1287,6 +1355,9 @@ static int __init rfkill_init(void)
 
  out:
  return error;
+
+error_led_trigger:
+ misc_deregister(&rfkill_miscdev);
 }
 subsys_initcall(rfkill_init);
 
@@ -1295,6 +1366,7 @@ static void __exit rfkill_exit(void)
 #ifdef CONFIG_RFKILL_INPUT
  rfkill_handler_exit();
 #endif
+ rfkill_any_led_trigger_unregister();
  misc_deregister(&rfkill_miscdev);
  class_unregister(&rfkill_class);
 }
--
2.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK/cmnt: [SRU][Xenial][PATCH 1/1] rfkill: Add rfkill-any LED trigger

Stefan Bader-2
On 02.02.2018 15:24, Joseph Salisbury wrote:

> From: Michał Kępień <[hidden email]>
>
> BugLink: http://bugs.launchpad.net/bugs/1745130
>
> Add a new "global" (i.e. not per-rfkill device) LED trigger, rfkill-any,
> which may be useful on 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ń <[hidden email]>
> Signed-off-by: Johannes Berg <[hidden email]>
> (back ported from commit 9b8e34e211b15af429b72388a8f2b3b1823d172e)
> Signed-off-by: Joseph Salisbury <[hidden email]>
Acked-by: Stefan Bader <[hidden email]>

> ---

Strictly this is something that should be using the HWE kernel (maybe depends on
how badly one thinks about a non-working LED for accumulated transmission
activity). But since it is mostly "new driver" category and relatively contained
I do not see real strong reasons to push against it.

-Stefan

>  net/rfkill/core.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 72 insertions(+)
>
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index cf5b69a..9e43ad9 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
> @@ -174,6 +174,50 @@ static void rfkill_led_trigger_unregister(struct rfkill *rfkill)
>  {
>   led_trigger_unregister(&rfkill->led_trigger);
>  }
> +
> +static struct led_trigger rfkill_any_led_trigger;
> +static struct work_struct rfkill_any_work;
> +
> +static void rfkill_any_led_trigger_worker(struct work_struct *work)
> +{
> + enum led_brightness brightness = LED_OFF;
> + struct rfkill *rfkill;
> +
> + mutex_lock(&rfkill_global_mutex);
> + list_for_each_entry(rfkill, &rfkill_list, node) {
> + if (!(rfkill->state & RFKILL_BLOCK_ANY)) {
> + brightness = LED_FULL;
> + break;
> + }
> + }
> + mutex_unlock(&rfkill_global_mutex);
> +
> + led_trigger_event(&rfkill_any_led_trigger, brightness);
> +}
> +
> +static void rfkill_any_led_trigger_event(void)
> +{
> + schedule_work(&rfkill_any_work);
> +}
> +
> +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)
> +{
> + INIT_WORK(&rfkill_any_work, rfkill_any_led_trigger_worker);
> + 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);
> + cancel_work_sync(&rfkill_any_work);
> +}
>  #else
>  static void rfkill_led_trigger_event(struct rfkill *rfkill)
>  {
> @@ -187,6 +231,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,
> @@ -318,6 +375,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);
> @@ -487,6 +545,8 @@ bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked)
>   if (!rfkill->registered)
>   return ret;
>  
> + rfkill_any_led_trigger_event();
> +
>   if (change)
>   schedule_work(&rfkill->uevent_work);
>  
> @@ -529,6 +589,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;
>  }
> @@ -578,6 +639,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);
> @@ -989,6 +1051,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);
> @@ -1021,6 +1084,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);
> @@ -1276,6 +1340,10 @@ static int __init rfkill_init(void)
>   goto out;
>   }
>  
> + error = rfkill_any_led_trigger_register();
> + if (error)
> + goto error_led_trigger;
> +
>  #ifdef CONFIG_RFKILL_INPUT
>   error = rfkill_handler_init();
>   if (error) {
> @@ -1287,6 +1355,9 @@ static int __init rfkill_init(void)
>  
>   out:
>   return error;
> +
> +error_led_trigger:
> + misc_deregister(&rfkill_miscdev);
>  }
>  subsys_initcall(rfkill_init);
>  
> @@ -1295,6 +1366,7 @@ static void __exit rfkill_exit(void)
>  #ifdef CONFIG_RFKILL_INPUT
>   rfkill_handler_exit();
>  #endif
> + rfkill_any_led_trigger_unregister();
>   misc_deregister(&rfkill_miscdev);
>   class_unregister(&rfkill_class);
>  }
>


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

ACK: [SRU][Xenial][PATCH 1/1] rfkill: Add rfkill-any LED trigger

Kleber Souza
In reply to this post by Joseph Salisbury-3
On 02/02/18 15:24, Joseph Salisbury wrote:

> From: Michał Kępień <[hidden email]>
>
> BugLink: http://bugs.launchpad.net/bugs/1745130
>
> Add a new "global" (i.e. not per-rfkill device) LED trigger, rfkill-any,
> which may be useful on 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ń <[hidden email]>
> Signed-off-by: Johannes Berg <[hidden email]>
> (back ported from commit 9b8e34e211b15af429b72388a8f2b3b1823d172e)
> Signed-off-by: Joseph Salisbury <[hidden email]>

Acked-by: Kleber Sacilotto de Souza <[hidden email]>

> ---
>  net/rfkill/core.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 72 insertions(+)
>
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index cf5b69a..9e43ad9 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
> @@ -174,6 +174,50 @@ static void rfkill_led_trigger_unregister(struct rfkill *rfkill)
>  {
>   led_trigger_unregister(&rfkill->led_trigger);
>  }
> +
> +static struct led_trigger rfkill_any_led_trigger;
> +static struct work_struct rfkill_any_work;
> +
> +static void rfkill_any_led_trigger_worker(struct work_struct *work)
> +{
> + enum led_brightness brightness = LED_OFF;
> + struct rfkill *rfkill;
> +
> + mutex_lock(&rfkill_global_mutex);
> + list_for_each_entry(rfkill, &rfkill_list, node) {
> + if (!(rfkill->state & RFKILL_BLOCK_ANY)) {
> + brightness = LED_FULL;
> + break;
> + }
> + }
> + mutex_unlock(&rfkill_global_mutex);
> +
> + led_trigger_event(&rfkill_any_led_trigger, brightness);
> +}
> +
> +static void rfkill_any_led_trigger_event(void)
> +{
> + schedule_work(&rfkill_any_work);
> +}
> +
> +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)
> +{
> + INIT_WORK(&rfkill_any_work, rfkill_any_led_trigger_worker);
> + 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);
> + cancel_work_sync(&rfkill_any_work);
> +}
>  #else
>  static void rfkill_led_trigger_event(struct rfkill *rfkill)
>  {
> @@ -187,6 +231,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,
> @@ -318,6 +375,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);
> @@ -487,6 +545,8 @@ bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked)
>   if (!rfkill->registered)
>   return ret;
>  
> + rfkill_any_led_trigger_event();
> +
>   if (change)
>   schedule_work(&rfkill->uevent_work);
>  
> @@ -529,6 +589,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;
>  }
> @@ -578,6 +639,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);
> @@ -989,6 +1051,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);
> @@ -1021,6 +1084,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);
> @@ -1276,6 +1340,10 @@ static int __init rfkill_init(void)
>   goto out;
>   }
>  
> + error = rfkill_any_led_trigger_register();
> + if (error)
> + goto error_led_trigger;
> +
>  #ifdef CONFIG_RFKILL_INPUT
>   error = rfkill_handler_init();
>   if (error) {
> @@ -1287,6 +1355,9 @@ static int __init rfkill_init(void)
>  
>   out:
>   return error;
> +
> +error_led_trigger:
> + misc_deregister(&rfkill_miscdev);
>  }
>  subsys_initcall(rfkill_init);
>  
> @@ -1295,6 +1366,7 @@ static void __exit rfkill_exit(void)
>  #ifdef CONFIG_RFKILL_INPUT
>   rfkill_handler_exit();
>  #endif
> + rfkill_any_led_trigger_unregister();
>   misc_deregister(&rfkill_miscdev);
>   class_unregister(&rfkill_class);
>  }
>

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED: [SRU][Xenial][PATCH 0/1] rfkill: Add rfkill-any LED trigger

Stefan Bader-2
In reply to this post by Joseph Salisbury-3
On 02.02.2018 15:24, Joseph Salisbury wrote:

> BugLink: http://bugs.launchpad.net/bugs/1745130
>
> == SRU Justification ==
> This bug was reported against a Fujitsu u7x7 laptop series based on Skylake hardware.
> It has a single rfkill button and a single LED for wlan and bluetooth. Both
> drivers currently provide a single rfkill trigger, so the led could
> just be assigned to one. This was resolved by mainline commit 9b8e34e211, which added a
> "rfkill-any" led trigger to correctly handle the led with multiple
> rfkill devices. That was added by one of the fujitsu-laptop maintainers and
> the driver sets it as the default trigger.  
>  
> Commit 9b8e34e211b1 is in mainline as of 4.11-rc1.
>
> == Fix ==
> commit 9b8e34e211b15af429b72388a8f2b3b1823d172e
> Author: Michał Kępień <[hidden email]>
> Date:   Fri Jan 6 07:07:47 2017 +0100
>
>     rfkill: Add rfkill-any LED trigger
>
> == Regression Potential ==
> Medium.  This commit affects all arches, but it has been in mainline since
> 4.11-rc1 with no reported issues.
>
> == Test Case ==
> A test kernel was built with this patch and tested by the original bug reporter.
> The bug reporter states the test kernel resolved the bug.
>
> Michał Kępień (1):
>   rfkill: Add rfkill-any LED trigger
>
>  net/rfkill/core.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 72 insertions(+)
>
Applied to xenial/master-next


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team

signature.asc (836 bytes) Download Attachment