[PATCH 3/4] leds:trigger:ledtrig-activity Replace "panic_detected" with is_be_panic()

From: Xiaoming Ni
Date: Fri Dec 18 2020 - 06:45:08 EST


Replace the global variable "panic_detected" with is_be_panic()

Signed-off-by: Xiaoming Ni <nixiaoming@xxxxxxxxxx>
---
drivers/leds/trigger/ledtrig-activity.c | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/drivers/leds/trigger/ledtrig-activity.c b/drivers/leds/trigger/ledtrig-activity.c
index 14ba7faaed9e..bbacb3dbe341 100644
--- a/drivers/leds/trigger/ledtrig-activity.c
+++ b/drivers/leds/trigger/ledtrig-activity.c
@@ -17,8 +17,6 @@
#include <linux/timer.h>
#include "../leds.h"

-static int panic_detected;
-
struct activity_data {
struct timer_list timer;
struct led_classdev *led_cdev;
@@ -47,7 +45,7 @@ static void led_activity_function(struct timer_list *t)
if (test_and_clear_bit(LED_BLINK_BRIGHTNESS_CHANGE, &led_cdev->work_flags))
led_cdev->blink_brightness = led_cdev->new_blink_brightness;

- if (unlikely(panic_detected)) {
+ if (unlikely(is_being_panic())) {
/* full brightness in case of panic */
led_set_brightness_nosleep(led_cdev, led_cdev->blink_brightness);
return;
@@ -226,28 +224,15 @@ static int activity_reboot_notifier(struct notifier_block *nb,
return NOTIFY_DONE;
}

-static int activity_panic_notifier(struct notifier_block *nb,
- unsigned long code, void *unused)
-{
- panic_detected = 1;
- return NOTIFY_DONE;
-}
-
static struct notifier_block activity_reboot_nb = {
.notifier_call = activity_reboot_notifier,
};

-static struct notifier_block activity_panic_nb = {
- .notifier_call = activity_panic_notifier,
-};
-
static int __init activity_init(void)
{
int rc = led_trigger_register(&activity_led_trigger);

if (!rc) {
- atomic_notifier_chain_register(&panic_notifier_list,
- &activity_panic_nb);
register_reboot_notifier(&activity_reboot_nb);
}
return rc;
@@ -256,8 +241,6 @@ static int __init activity_init(void)
static void __exit activity_exit(void)
{
unregister_reboot_notifier(&activity_reboot_nb);
- atomic_notifier_chain_unregister(&panic_notifier_list,
- &activity_panic_nb);
led_trigger_unregister(&activity_led_trigger);
}

--
2.27.0