[PATCH] leds: triggers: Improve handling of LEDs supporting hw triggers only

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 drivers/leds/led-triggers.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 4e7b78a84..48924bad2 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -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,
-- 
2.32.0




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux