From: Heiner Kallweit <hkallweit1@gmail.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: "linux-leds@vger.kernel.org" <linux-leds@vger.kernel.org>
Subject: [PATCH] leds: triggers: Improve handling of LEDs supporting hw triggers only
Date: Thu, 22 Jul 2021 22:16:05 +0200 [thread overview]
Message-ID: <cfacb5b8-e7bf-c7c8-c5ab-4a8048a67db2@gmail.com> (raw)
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(-)
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
reply other threads:[~2021-07-22 20:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cfacb5b8-e7bf-c7c8-c5ab-4a8048a67db2@gmail.com \
--to=hkallweit1@gmail.com \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).