@@ -27,10 +27,23 @@ LIST_HEAD(trigger_list);
/* Used by LED Class */
-static inline bool
-trigger_relevant(struct led_classdev *led_cdev, struct led_trigger *trig)
+static bool led_hw_trig_only(struct led_classdev *led_cdev)
{
- return !trig->trigger_type || trig->trigger_type == led_cdev->trigger_type;
+ return !led_cdev->brightness_set && !led_cdev->brightness_set_blocking &&
+ !led_cdev->blink_set && !led_cdev->pattern_set;
+}
+
+static bool trigger_relevant(struct led_classdev *led_cdev,
+ struct led_trigger *trig)
+{
+ if (trig->trigger_type == led_cdev->trigger_type)
+ return true;
+
+ /* LED supports matching hw triggers only */
+ if (led_hw_trig_only(led_cdev))
+ return false;
+
+ return !trig->trigger_type;
}
ssize_t led_trigger_write(struct file *filp, struct kobject *kobj,
A LED supporting HW triggers only (example: network PHY LED indicating 100M link or 1000M link or ..) may have none of the software LED control callbacks implemented. As of today the software LED control triggers would be available nevertheless. This doesn't make sense. If a LED supports HW triggers only, offer only the matching HW triggers. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> --- drivers/leds/led-triggers.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)