Commit 6a1ac56c authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'led-fixes-for-4.20-rc2' of...

Merge tag 'led-fixes-for-4.20-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds

Pull LED fixes from Jacek Anaszewski:
 "All three fixes are related to the newly added pattern trigger:

   - remove mutex_lock() from timer callback, which would trigger
     problems related to sleeping in atomic context, the removal is
     harmless since mutex protection turned out to be redundant in this
     case

   - fix pattern parsing to properly handle intervals with brightness == 0

   - fix typos in the ABI documentation"

* tag 'led-fixes-for-4.20-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds:
  Documentation: ABI: led-trigger-pattern: Fix typos
  leds: trigger: Fix sleeping function called from invalid context
  Fix pattern handling optimalization
parents d464572a 406e7f98
...@@ -37,8 +37,8 @@ Description: ...@@ -37,8 +37,8 @@ Description:
0-| / \/ \/ 0-| / \/ \/
+---0----1----2----3----4----5----6------------> time (s) +---0----1----2----3----4----5----6------------> time (s)
2. To make the LED go instantly from one brigntess value to another, 2. To make the LED go instantly from one brightness value to another,
we should use use zero-time lengths (the brightness must be same as we should use zero-time lengths (the brightness must be same as
the previous tuple's). So the format should be: the previous tuple's). So the format should be:
"brightness_1 duration_1 brightness_1 0 brightness_2 duration_2 "brightness_1 duration_1 brightness_1 0 brightness_2 duration_2
brightness_2 0 ...". For example: brightness_2 0 ...". For example:
......
...@@ -75,8 +75,6 @@ static void pattern_trig_timer_function(struct timer_list *t) ...@@ -75,8 +75,6 @@ static void pattern_trig_timer_function(struct timer_list *t)
{ {
struct pattern_trig_data *data = from_timer(data, t, timer); struct pattern_trig_data *data = from_timer(data, t, timer);
mutex_lock(&data->lock);
for (;;) { for (;;) {
if (!data->is_indefinite && !data->repeat) if (!data->is_indefinite && !data->repeat)
break; break;
...@@ -87,9 +85,10 @@ static void pattern_trig_timer_function(struct timer_list *t) ...@@ -87,9 +85,10 @@ static void pattern_trig_timer_function(struct timer_list *t)
data->curr->brightness); data->curr->brightness);
mod_timer(&data->timer, mod_timer(&data->timer,
jiffies + msecs_to_jiffies(data->curr->delta_t)); jiffies + msecs_to_jiffies(data->curr->delta_t));
if (!data->next->delta_t) {
/* Skip the tuple with zero duration */ /* Skip the tuple with zero duration */
pattern_trig_update_patterns(data); pattern_trig_update_patterns(data);
}
/* Select next tuple */ /* Select next tuple */
pattern_trig_update_patterns(data); pattern_trig_update_patterns(data);
} else { } else {
...@@ -116,8 +115,6 @@ static void pattern_trig_timer_function(struct timer_list *t) ...@@ -116,8 +115,6 @@ static void pattern_trig_timer_function(struct timer_list *t)
break; break;
} }
mutex_unlock(&data->lock);
} }
static int pattern_trig_start_pattern(struct led_classdev *led_cdev) static int pattern_trig_start_pattern(struct led_classdev *led_cdev)
...@@ -176,14 +173,10 @@ static ssize_t repeat_store(struct device *dev, struct device_attribute *attr, ...@@ -176,14 +173,10 @@ static ssize_t repeat_store(struct device *dev, struct device_attribute *attr,
if (res < -1 || res == 0) if (res < -1 || res == 0)
return -EINVAL; return -EINVAL;
/*
* Clear previous patterns' performence firstly, and remove the timer
* without mutex lock to avoid dead lock.
*/
del_timer_sync(&data->timer);
mutex_lock(&data->lock); mutex_lock(&data->lock);
del_timer_sync(&data->timer);
if (data->is_hw_pattern) if (data->is_hw_pattern)
led_cdev->pattern_clear(led_cdev); led_cdev->pattern_clear(led_cdev);
...@@ -234,14 +227,10 @@ static ssize_t pattern_trig_store_patterns(struct led_classdev *led_cdev, ...@@ -234,14 +227,10 @@ static ssize_t pattern_trig_store_patterns(struct led_classdev *led_cdev,
struct pattern_trig_data *data = led_cdev->trigger_data; struct pattern_trig_data *data = led_cdev->trigger_data;
int ccount, cr, offset = 0, err = 0; int ccount, cr, offset = 0, err = 0;
/*
* Clear previous patterns' performence firstly, and remove the timer
* without mutex lock to avoid dead lock.
*/
del_timer_sync(&data->timer);
mutex_lock(&data->lock); mutex_lock(&data->lock);
del_timer_sync(&data->timer);
if (data->is_hw_pattern) if (data->is_hw_pattern)
led_cdev->pattern_clear(led_cdev); led_cdev->pattern_clear(led_cdev);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment