OSDN Git Service

Fix pattern handling optimalization
authorPavel Machek <pavel@ucw.cz>
Wed, 24 Oct 2018 20:44:39 +0000 (22:44 +0200)
committerJacek Anaszewski <jacek.anaszewski@gmail.com>
Thu, 25 Oct 2018 18:47:46 +0000 (20:47 +0200)
Check for zero duration before skipping step. This fixes pattern

    echo "0 1000 10 2550 0 1000" > pattern

which should do [  .-xXx-.] but does [   Xx-.]

Signed-off-by: Pavel Machek <pavel@ucw.cz>
Suggested-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
drivers/leds/trigger/ledtrig-pattern.c

index ce7acd1..174a298 100644 (file)
@@ -87,9 +87,10 @@ static void pattern_trig_timer_function(struct timer_list *t)
                                           data->curr->brightness);
                        mod_timer(&data->timer,
                                  jiffies + msecs_to_jiffies(data->curr->delta_t));
-
-                       /* Skip the tuple with zero duration */
-                       pattern_trig_update_patterns(data);
+                       if (!data->next->delta_t) {
+                               /* Skip the tuple with zero duration */
+                               pattern_trig_update_patterns(data);
+                       }
                        /* Select next tuple */
                        pattern_trig_update_patterns(data);
                } else {