From patchwork Mon Sep 6 13:53:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chaochao2021666@163.com X-Patchwork-Id: 507676 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14385C433EF for ; Mon, 6 Sep 2021 13:54:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DACD060EE1 for ; Mon, 6 Sep 2021 13:54:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242165AbhIFN4B (ORCPT ); Mon, 6 Sep 2021 09:56:01 -0400 Received: from m12-18.163.com ([220.181.12.18]:33838 "EHLO m12-18.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243839AbhIFNzD (ORCPT ); Mon, 6 Sep 2021 09:55:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=0GdV2fz1bx2ayoXl8Z z+z4cLRJnH9KOzRfn6OCrKlBg=; b=feNWH5v2BefT93jem8qA7JNIJRI+9xwKSt SxyudnoZNN3uBoV5hBj61NlEozdMaFwb1CRrRkJLUKII3ilDVMRkJP74Tkhj6VT6 sdBJ6HvV3B0NMSi0JsVyrw22JBbYUDnsdF6wbm9K2M/+i8wOn4dm2jNyWdNM3XLT ZBFWn0Zno= Received: from localhost.localdomain (unknown [183.220.75.228]) by smtp14 (Coremail) with SMTP id EsCowABX_b5kHTZhfthN4A--.43881S2; Mon, 06 Sep 2021 21:53:42 +0800 (CST) From: chaochao2021666@163.com To: pavel@ucw.cz Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, jan.kiszk@siemens.com, 464759471@qq.com, chao zeng Subject: [PATCH 1/3] leds:triggers:Extend the kernel panic LED trigger Date: Mon, 6 Sep 2021 21:53:18 +0800 Message-Id: <20210906135320.23134-1-chaochao2021666@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: EsCowABX_b5kHTZhfthN4A--.43881S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxXF1rGw4rXFWDGw4fAry7ZFb_yoW5tr1Dp3 40kay5Gr48JFs8JF4kZF48tFya93ykArWYyFWxC3yUKa45tF48JFyvyw13Ja4rXa4Uurs0 yw15tryFkw4xJF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jRCJQUUUUU= X-Originating-IP: [183.220.75.228] X-CM-SenderInfo: 5fkd0uhkdrjiasrwlli6rwjhhfrp/1tbiSgYGdVPAPoiNgwAAsU Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: chao zeng This commit extend panic trigger, add two new panic trigger "panic_on" and "panic_off" and keep the "panic" compatible with "panic_blink". All the led on the "panic_on" would light and on the "panic_off" would turn off Expand the panic state of led to meet more requirements Signed-off-by: chao zeng --- drivers/leds/trigger/ledtrig-panic.c | 39 ++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/leds/trigger/ledtrig-panic.c b/drivers/leds/trigger/ledtrig-panic.c index 64abf2e91608..1274bc94b5dd 100644 --- a/drivers/leds/trigger/ledtrig-panic.c +++ b/drivers/leds/trigger/ledtrig-panic.c @@ -12,19 +12,26 @@ #include #include "../leds.h" -static struct led_trigger *trigger; +enum led_display_type { + ON, + OFF, + BLINK, + DISPLAY_TYPE_COUNT, +}; + +static struct led_trigger *panic_trigger[DISPLAY_TYPE_COUNT]; /* * This is called in a special context by the atomic panic * notifier. This means the trigger can be changed without * worrying about locking. */ -static void led_trigger_set_panic(struct led_classdev *led_cdev) +static void led_trigger_set_panic(struct led_classdev *led_cdev, const char *type) { struct led_trigger *trig; list_for_each_entry(trig, &trigger_list, next_trig) { - if (strcmp("panic", trig->name)) + if (strcmp(type, trig->name)) continue; if (led_cdev->trigger) list_del(&led_cdev->trig_list); @@ -37,6 +44,10 @@ static void led_trigger_set_panic(struct led_classdev *led_cdev) led_cdev->trigger = trig; if (trig->activate) trig->activate(led_cdev); + + /*Clear current brightness work*/ + led_cdev->work_flags = 0; + break; } } @@ -48,7 +59,12 @@ static int led_trigger_panic_notifier(struct notifier_block *nb, list_for_each_entry(led_cdev, &leds_list, node) if (led_cdev->flags & LED_PANIC_INDICATOR) - led_trigger_set_panic(led_cdev); + led_trigger_set_panic(led_cdev, "panic"); + else if (led_cdev->flags & LED_PANIC_INDICATOR_ON) + led_trigger_set_panic(led_cdev, "panic_on"); + else if (led_cdev->flags & LED_PANIC_INDICATOR_OFF) + led_trigger_set_panic(led_cdev, "panic_off"); + return NOTIFY_DONE; } @@ -56,9 +72,12 @@ static struct notifier_block led_trigger_panic_nb = { .notifier_call = led_trigger_panic_notifier, }; -static long led_panic_blink(int state) +static long led_panic_activity(int state) { - led_trigger_event(trigger, state ? LED_FULL : LED_OFF); + led_trigger_event(panic_trigger[BLINK], state ? LED_FULL : LED_OFF); + led_trigger_event(panic_trigger[ON], LED_FULL); + led_trigger_event(panic_trigger[OFF], LED_OFF); + return 0; } @@ -67,8 +86,12 @@ static int __init ledtrig_panic_init(void) atomic_notifier_chain_register(&panic_notifier_list, &led_trigger_panic_nb); - led_trigger_register_simple("panic", &trigger); - panic_blink = led_panic_blink; + led_trigger_register_simple("panic", &panic_trigger[BLINK]); + led_trigger_register_simple("panic_on", &panic_trigger[ON]); + led_trigger_register_simple("panic_off", &panic_trigger[OFF]); + + panic_blink = led_panic_activity; + return 0; } device_initcall(ledtrig_panic_init); From patchwork Mon Sep 6 13:53:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chaochao2021666@163.com X-Patchwork-Id: 507675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B2C2C433F5 for ; Mon, 6 Sep 2021 13:55:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79E0F60F6B for ; Mon, 6 Sep 2021 13:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242693AbhIFN4C (ORCPT ); Mon, 6 Sep 2021 09:56:02 -0400 Received: from m12-18.163.com ([220.181.12.18]:34307 "EHLO m12-18.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243923AbhIFNzJ (ORCPT ); Mon, 6 Sep 2021 09:55:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=eru+PgjB5lPQrWe1PB y1vaDhviHWfygF3DD2no18Ytw=; b=LOGzmAbMvHaciWsVWC3a7u+6NjCq2BkPbw UTUevTvyWV/YuXgxvUO7G5LQ8KAdfhN4RwOz6Rzo5n4CAr7qYNQ0Ln/5+vJ9QhH5 zxrpwA502rA8tVVsenvCHUl4tdBHvNmu88jq6B0ETXFII6CFXG39TrvF0OzqsBSQ GGG8W6o0c= Received: from localhost.localdomain (unknown [183.220.75.228]) by smtp14 (Coremail) with SMTP id EsCowABX_b5kHTZhfthN4A--.43881S3; Mon, 06 Sep 2021 21:53:48 +0800 (CST) From: chaochao2021666@163.com To: pavel@ucw.cz Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, jan.kiszk@siemens.com, 464759471@qq.com, chao zeng Subject: [PATCH 2/3] leds:gpio:Add the support for "panic-indicator-on" and "panic-indicator-off" Date: Mon, 6 Sep 2021 21:53:19 +0800 Message-Id: <20210906135320.23134-2-chaochao2021666@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210906135320.23134-1-chaochao2021666@163.com> References: <20210906135320.23134-1-chaochao2021666@163.com> X-CM-TRANSID: EsCowABX_b5kHTZhfthN4A--.43881S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7tFWruryDJw47Kw47tF17GFg_yoW5JFy8pa n5Cr9F9Fs3GF10y3s7A3W2qa12yw40yry7JF97Gay5JFyUKFyfXr95tF13ZFWUAFZ2kaya qa13JFnIkFZrAaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07bjKs8UUUUU= X-Originating-IP: [183.220.75.228] X-CM-SenderInfo: 5fkd0uhkdrjiasrwlli6rwjhhfrp/1tbiLw0GdVUMZ5L+6QAAsq Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: chao zeng This commit extend the panic indicator,allowing to set LED a variety of different of states on a kernel panic.There are on and off state in addition to blink for a given LED. Signed-off-by: chao zeng --- drivers/leds/leds-gpio.c | 9 +++++++++ include/linux/leds.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 092eb59a7d32..d77ec57f3f71 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -103,6 +103,11 @@ static int create_gpio_led(const struct gpio_led *template, led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; if (template->panic_indicator) led_dat->cdev.flags |= LED_PANIC_INDICATOR; + else if (template->panic_indicator_on) + led_dat->cdev.flags |= LED_PANIC_INDICATOR_ON; + else if (template->panic_indicator_off) + led_dat->cdev.flags |= LED_PANIC_INDICATOR_OFF; + if (template->retain_state_shutdown) led_dat->cdev.flags |= LED_RETAIN_AT_SHUTDOWN; @@ -169,6 +174,10 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) led.retain_state_shutdown = 1; if (fwnode_property_present(child, "panic-indicator")) led.panic_indicator = 1; + else if (fwnode_property_present(child, "panic-indicator-on")) + led.panic_indicator_on = 1; + else if (fwnode_property_present(child, "panic-indicator-off")) + led.panic_indicator_off = 1; ret = create_gpio_led(&led, led_dat, dev, child, NULL); if (ret < 0) { diff --git a/include/linux/leds.h b/include/linux/leds.h index a0b730be40ad..6b3ae1dbc65f 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -85,6 +85,8 @@ struct led_classdev { #define LED_BRIGHT_HW_CHANGED BIT(21) #define LED_RETAIN_AT_SHUTDOWN BIT(22) #define LED_INIT_DEFAULT_TRIGGER BIT(23) +#define LED_PANIC_INDICATOR_ON BIT(24) +#define LED_PANIC_INDICATOR_OFF BIT(25) /* set_brightness_work / blink_timer flags, atomic, private. */ unsigned long work_flags; @@ -521,6 +523,8 @@ struct gpio_led { unsigned active_low : 1; unsigned retain_state_suspended : 1; unsigned panic_indicator : 1; + unsigned panic_indicator_on : 1; + unsigned panic_indicator_off : 1; unsigned default_state : 2; unsigned retain_state_shutdown : 1; /* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */ From patchwork Mon Sep 6 13:53:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chaochao2021666@163.com X-Patchwork-Id: 507376 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB8BAC433FE for ; Mon, 6 Sep 2021 13:55:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 890B560F9E for ; Mon, 6 Sep 2021 13:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244728AbhIFN4C (ORCPT ); Mon, 6 Sep 2021 09:56:02 -0400 Received: from m12-18.163.com ([220.181.12.18]:36960 "EHLO m12-18.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244237AbhIFNzc (ORCPT ); Mon, 6 Sep 2021 09:55:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=UlU0ugQ9eiCibe2wkZ 2zmgFWKjVJd3Z1u7PCG+vABgc=; b=hvIrKPGPUVz5JsluKF7Hl9ULrUkQ1pGf/j z3aBHe+2mUO3zXPVtvA7XPpiPHENAk/5bnHtw2HXB50zKHgDUio3InCy3kQUwtda NgyfHkVXTfGLuIfohMikwnhJOq83R3ebTdguFPNUL1yh3f50DIqLlFIysJXH29gX /aWkjTXHs= Received: from localhost.localdomain (unknown [183.220.75.228]) by smtp14 (Coremail) with SMTP id EsCowABX_b5kHTZhfthN4A--.43881S4; Mon, 06 Sep 2021 21:53:51 +0800 (CST) From: chaochao2021666@163.com To: pavel@ucw.cz Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, jan.kiszk@siemens.com, 464759471@qq.com, chao zeng Subject: [PATCH 3/3] dt-bindings:leds:Extend panic led state Date: Mon, 6 Sep 2021 21:53:20 +0800 Message-Id: <20210906135320.23134-3-chaochao2021666@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210906135320.23134-1-chaochao2021666@163.com> References: <20210906135320.23134-1-chaochao2021666@163.com> X-CM-TRANSID: EsCowABX_b5kHTZhfthN4A--.43881S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7GF4xKr13WFy3try8WF1xXwb_yoW8JF15pw s3Ca4jqFyrtryxu3s2q3W0qw1akF4kCFyUGFZrWw1UtFs8JF1Sgw4Skr15WFyUAayxZay7 uF1SkFyUKa40yrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07bOvtZUUUUU= X-Originating-IP: [183.220.75.228] X-CM-SenderInfo: 5fkd0uhkdrjiasrwlli6rwjhhfrp/1tbiEQ8GdV7+4qFwbgAAsQ Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: chao zeng Add extra "panic-indicator-on" and "panic-indicator-off" to extend the panic led status.Not only blink to indicate the panic Signed-off-by: chao zeng --- Documentation/devicetree/bindings/leds/common.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml index 697102707703..7eb367063155 100644 --- a/Documentation/devicetree/bindings/leds/common.yaml +++ b/Documentation/devicetree/bindings/leds/common.yaml @@ -125,7 +125,19 @@ properties: panic-indicator: description: This property specifies that the LED should be used, if at all possible, - as a panic indicator. + using blink as a panic indicator. + type: boolean + + panic-indicator-on: + description: + This property specifies that the LED should be used, if at all possible, + using led on as a panic indicator. + type: boolean + + panic-indicator-off: + description: + This property specifies that the LED should be used, if at all possible, + using led off as a panic indicator. type: boolean retain-state-shutdown: