Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754849AbcJEKDy (ORCPT ); Wed, 5 Oct 2016 06:03:54 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:37450 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754787AbcJEKDw (ORCPT ); Wed, 5 Oct 2016 06:03:52 -0400 X-AuditID: cbfee61a-f79786d000004c78-c7-57f4d00659f1 From: Jacek Anaszewski To: linux-leds@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jacek Anaszewski , Pavel Machek Subject: [PATCH 1/2] leds: ledtrig-heartbeat: Make top brightness adjustable Date: Wed, 05 Oct 2016 12:03:31 +0200 Message-id: <1475661812-26215-1-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNLMWRmVeSWpSXmKPExsVy+t9jAV22C1/CDT4v57Tovfqc0eLyrjls FlvfrGO0uHvqKJsDi0ffllWMHitWf2f3+LxJLoA5ys0mIzUxJbVIITUvOT8lMy/dVik0xE3X QkkhLzE31VYpQtc3JEhJoSwxpxTIMzJAAw7OAe7BSvp2CW4Zbxb3MhfsEaqY924PUwPjLv4u Rk4OCQETib7FN1ggbDGJC/fWs3UxcnEICSxllLj0YykjhPOTUeLN22ZGkCo2AUOJny9eM3Ux cnCICMhJ7DxTCRJmFsiRODLnNzuILSzgI3FvdwsTiM0ioCqx6dBiZhCbV8BD4ubzj1DL5CRO HpvMOoGRewEjwypGidSC5ILipPRcw7zUcr3ixNzi0rx0veT83E2M4IB7JrWD8eAu90OMAhyM Sjy8CWpfwoVYE8uKK3MPMUpwMCuJ8CafBwrxpiRWVqUW5ccXleakFh9iNAU6YCKzlGhyPjAa 8kriDU3MTcyNDSzMLS1NjJTEeRtnPwsXEkhPLEnNTk0tSC2C6WPi4JRqYDQ68fqsvC+D0r3L NiJZYUeWr8m4NC9z3vnUvvwpIo+O2Hhf9aowsn3tVa7i0imzj+nY+oKWR2kBE+KDv12yD/8r HPdz3bmzZ1qfLt23PGb2xMkCDwt4OgS9XW9u+pC8wbVl1oIfaTwL7Oe27M23Ube68+X9186I 3gVL2EP857TEh/36UyOw5YkSS3FGoqEWc1FxIgBg3Q/bTgIAAA== X-MTR: 20000000000000000@CPGS Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2296 Lines: 66 LED class heartbeat trigger allowed only for blinking with max_brightness value. This patch adds more flexibility by exploiting part of LED core software blink infrastructure. Signed-off-by: Jacek Anaszewski Cc: Pavel Machek --- drivers/leds/trigger/ledtrig-heartbeat.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/leds/trigger/ledtrig-heartbeat.c b/drivers/leds/trigger/ledtrig-heartbeat.c index c9f3862..9cc3e97 100644 --- a/drivers/leds/trigger/ledtrig-heartbeat.c +++ b/drivers/leds/trigger/ledtrig-heartbeat.c @@ -59,26 +59,26 @@ static void led_heartbeat_function(unsigned long data) delay = msecs_to_jiffies(70); heartbeat_data->phase++; if (!heartbeat_data->invert) - brightness = led_cdev->max_brightness; + brightness = led_cdev->blink_brightness; break; case 1: delay = heartbeat_data->period / 4 - msecs_to_jiffies(70); heartbeat_data->phase++; if (heartbeat_data->invert) - brightness = led_cdev->max_brightness; + brightness = led_cdev->blink_brightness; break; case 2: delay = msecs_to_jiffies(70); heartbeat_data->phase++; if (!heartbeat_data->invert) - brightness = led_cdev->max_brightness; + brightness = led_cdev->blink_brightness; break; default: delay = heartbeat_data->period - heartbeat_data->period / 4 - msecs_to_jiffies(70); heartbeat_data->phase = 0; if (heartbeat_data->invert) - brightness = led_cdev->max_brightness; + brightness = led_cdev->blink_brightness; break; } @@ -133,7 +133,10 @@ static void heartbeat_trig_activate(struct led_classdev *led_cdev) setup_timer(&heartbeat_data->timer, led_heartbeat_function, (unsigned long) led_cdev); heartbeat_data->phase = 0; + if (!led_cdev->blink_brightness) + led_cdev->blink_brightness = led_cdev->max_brightness; led_heartbeat_function(heartbeat_data->timer.data); + led_cdev->flags |= LED_BLINK_SW; led_cdev->activated = true; } @@ -145,6 +148,7 @@ static void heartbeat_trig_deactivate(struct led_classdev *led_cdev) del_timer_sync(&heartbeat_data->timer); device_remove_file(led_cdev->dev, &dev_attr_invert); kfree(heartbeat_data); + led_cdev->flags &= ~LED_BLINK_SW; led_cdev->activated = false; } } -- 1.9.1