From patchwork Wed Mar 30 19:11:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 8702191 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 80E1BC0553 for ; Wed, 30 Mar 2016 19:13:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9123C2037E for ; Wed, 30 Mar 2016 19:13:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F45A202C8 for ; Wed, 30 Mar 2016 19:13:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1alLWl-0001Gv-6z; Wed, 30 Mar 2016 19:11:39 +0000 Received: from mail-qg0-x235.google.com ([2607:f8b0:400d:c04::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1alLWi-00019H-0Z for linux-arm-kernel@lists.infradead.org; Wed, 30 Mar 2016 19:11:37 +0000 Received: by mail-qg0-x235.google.com with SMTP id n34so39550216qge.1 for ; Wed, 30 Mar 2016 12:11:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=w83kpqVoz0wanA3dneZHleGhLpBpoUhqwa9eKfVBhtI=; b=EOBvpw/62w1LdhU/j6M/D77hqhHv3NLJ0a0jM8dSOOeKxvYqFld1aUtahUAP/xRH5E VGSK91Ty7DzY9afSYeB0W7PMDgf+6HdE7NICzgKV7dmg258YoqfGDeGqfyJFW/2Ov6SS lSrpiZ+Gr+kFGQpDOpxUIQ9CrHuVN5c+TCimpaiBnT0SlhUJRw0g+b2o0tiUqRhDtOsi 6aC32Ov1nAFpICImxjxVyB6cDq4JiArjLfZUEWpawSRUIW0X8EAIK42OuVt6zeD59T0w G/6R5mtjnNbgEUSYZSmvcAp1gFfSJRz83+OB/YaqB9P0S7fi3Fkw7JtZnP9UGJ4Bwjk7 JjKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=w83kpqVoz0wanA3dneZHleGhLpBpoUhqwa9eKfVBhtI=; b=Z0aRK+EGlmVcaAhFfdl0Xj3zqr7K8sbjytLCVsZyE2xVWKp+WHTiKq5vY5sXr23Yyi YvSqRzLfeRmvQiI7n5ZpArXJlg2U9Tq0cSqb+kNteyP9uPp/yRHRRLvDxUer1WzkcDtv vJvWfI+P6RYia7Y78JDqJ2EEWiGOr1ujhVMofVGrgjA1WQIwpmS9pfdvGlypdPrOFizf D4kEIEacNpNdAcwczhNTQQHKdhF6A7sA/JNobb95a0Tggw39rF9gCYhfE8yaL0Iwf7nA 6PmXIXvT4KFrSlMQIOaFfKz1v5rcZDE4CrU1ieU3N4dm19Mx/grLSBJwTLSlAr8Yr/ye w2gg== X-Gm-Message-State: AD7BkJK0n1NfZsqT1bSIkYIaH3uxfC5wHFFWIMryprEh5mYGPhlvB2ctpe/If6rv5dogEg== X-Received: by 10.140.42.39 with SMTP id b36mr11912370qga.4.1459365074500; Wed, 30 Mar 2016 12:11:14 -0700 (PDT) Received: from localhost ([190.2.108.156]) by smtp.gmail.com with ESMTPSA id 18sm2027281qhm.9.2016.03.30.12.11.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Mar 2016 12:11:13 -0700 (PDT) Date: Wed, 30 Mar 2016 16:11:09 -0300 From: Ezequiel Garcia To: Jacek Anaszewski , Arnd Bergmann Subject: Re: [PATCH 1/3] leds: trigger: Introduce a kernel panic LED trigger Message-ID: <20160330191109.GA27372@laptop.cereza> References: <1459283749-22451-1-git-send-email-ezequiel@vanguardiasur.com.ar> <1459283749-22451-2-git-send-email-ezequiel@vanguardiasur.com.ar> <56FB9C6A.2090402@samsung.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <56FB9C6A.2090402@samsung.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160330_121136_200911_2950C356 X-CRM114-Status: GOOD ( 18.54 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: k.kozlowski@samsung.com, linux-kernel@vger.kernel.org, kgene@kernel.org, Richard Purdie , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP +lkml On 30 Mar 11:29 AM, Jacek Anaszewski wrote: > Hi Ezequiel, > > Thanks for the patch. I've tested it on exynos4412-trats2 board > with leds-aat1290 driver, by executing: > > echo "c" > /proc/sysrq-trigger > > I was able to notice the blinking then. > > Applied to the for-next branch of linux-leds.git. > Notice that we currently need LEDs to be dedicated to the panic trigger, which is pretty lame as LEDs are scarce and are most likely assigned to something else. So, here's a toy patch to switch all the installed LEDs to the panic trigger on kernel panic. Patch is half-baked, but it shows the idea. (Interestingly, it also blinks the LEDs on a USB keyboard!) Is there any value in polishing this and find a way upstream? diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index aa84e5b37593..caaf6161a7ae 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -321,6 +321,20 @@ void devm_led_classdev_unregister(struct device *dev, } EXPORT_SYMBOL_GPL(devm_led_classdev_unregister); +static int led_panic_notifier(struct notifier_block *nb, + unsigned long code, void *unused) +{ + struct led_classdev *led_cdev; + + list_for_each_entry(led_cdev, &leds_list, node) + led_trigger_set_at_panic(led_cdev, "panic"); + return NOTIFY_DONE; +} + +static struct notifier_block led_panic_nb = { + .notifier_call = led_panic_notifier, +}; + static int __init leds_init(void) { leds_class = class_create(THIS_MODULE, "leds"); @@ -328,6 +342,8 @@ static int __init leds_init(void) return PTR_ERR(leds_class); leds_class->pm = &leds_class_dev_pm_ops; leds_class->dev_groups = led_groups; + atomic_notifier_chain_register(&panic_notifier_list, + &led_panic_nb); return 0; } diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index 2181581795d3..8c1d33acdfa8 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -148,6 +148,21 @@ void led_trigger_remove(struct led_classdev *led_cdev) } EXPORT_SYMBOL_GPL(led_trigger_remove); +void led_trigger_set_at_panic(struct led_classdev *led_cdev, const char *name) +{ + struct led_trigger *trig; + + list_for_each_entry(trig, &trigger_list, next_trig) { + if (strcmp(name, trig->name)) + continue; + list_add_tail(&led_cdev->trig_list, &trig->led_cdevs); + led_cdev->trigger = trig; + if (trig->activate) + trig->activate(led_cdev); + break; + } +} + void led_trigger_set_default(struct led_classdev *led_cdev) { struct led_trigger *trig; diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h index db3f20da7221..8cfa10f626a6 100644 --- a/drivers/leds/leds.h +++ b/drivers/leds/leds.h @@ -21,6 +21,7 @@ static inline int led_get_brightness(struct led_classdev *led_cdev) return led_cdev->brightness; } +void led_trigger_set_at_panic(struct led_classdev *led_cdev, const char *name); void led_init_core(struct led_classdev *led_cdev); void led_stop_software_blink(struct led_classdev *led_cdev); void led_set_brightness_nopm(struct led_classdev *led_cdev,