Skip to content

Commit 6a1ac56

Browse files
committed
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
2 parents d464572 + 406e7f9 commit 6a1ac56

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

Documentation/ABI/testing/sysfs-class-led-trigger-pattern

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ Description:
3737
0-| / \/ \/
3838
+---0----1----2----3----4----5----6------------> time (s)
3939

40-
2. To make the LED go instantly from one brigntess value to another,
41-
we should use use zero-time lengths (the brightness must be same as
40+
2. To make the LED go instantly from one brightness value to another,
41+
we should use zero-time lengths (the brightness must be same as
4242
the previous tuple's). So the format should be:
4343
"brightness_1 duration_1 brightness_1 0 brightness_2 duration_2
4444
brightness_2 0 ...". For example:

drivers/leds/trigger/ledtrig-pattern.c

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ static void pattern_trig_timer_function(struct timer_list *t)
7575
{
7676
struct pattern_trig_data *data = from_timer(data, t, timer);
7777

78-
mutex_lock(&data->lock);
79-
8078
for (;;) {
8179
if (!data->is_indefinite && !data->repeat)
8280
break;
@@ -87,9 +85,10 @@ static void pattern_trig_timer_function(struct timer_list *t)
8785
data->curr->brightness);
8886
mod_timer(&data->timer,
8987
jiffies + msecs_to_jiffies(data->curr->delta_t));
90-
91-
/* Skip the tuple with zero duration */
92-
pattern_trig_update_patterns(data);
88+
if (!data->next->delta_t) {
89+
/* Skip the tuple with zero duration */
90+
pattern_trig_update_patterns(data);
91+
}
9392
/* Select next tuple */
9493
pattern_trig_update_patterns(data);
9594
} else {
@@ -116,8 +115,6 @@ static void pattern_trig_timer_function(struct timer_list *t)
116115

117116
break;
118117
}
119-
120-
mutex_unlock(&data->lock);
121118
}
122119

123120
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,
176173
if (res < -1 || res == 0)
177174
return -EINVAL;
178175

179-
/*
180-
* Clear previous patterns' performence firstly, and remove the timer
181-
* without mutex lock to avoid dead lock.
182-
*/
183-
del_timer_sync(&data->timer);
184-
185176
mutex_lock(&data->lock);
186177

178+
del_timer_sync(&data->timer);
179+
187180
if (data->is_hw_pattern)
188181
led_cdev->pattern_clear(led_cdev);
189182

@@ -234,14 +227,10 @@ static ssize_t pattern_trig_store_patterns(struct led_classdev *led_cdev,
234227
struct pattern_trig_data *data = led_cdev->trigger_data;
235228
int ccount, cr, offset = 0, err = 0;
236229

237-
/*
238-
* Clear previous patterns' performence firstly, and remove the timer
239-
* without mutex lock to avoid dead lock.
240-
*/
241-
del_timer_sync(&data->timer);
242-
243230
mutex_lock(&data->lock);
244231

232+
del_timer_sync(&data->timer);
233+
245234
if (data->is_hw_pattern)
246235
led_cdev->pattern_clear(led_cdev);
247236

0 commit comments

Comments
 (0)