Netdev List
 help / color / mirror / Atom feed
From: Rong Zhang <i@rong.moe>
To: "Lee Jones" <lee@kernel.org>, "Pavel Machek" <pavel@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	"Benson Leung" <bleung@chromium.org>,
	"Guenter Roeck" <groeck@chromium.org>,
	"Marek Behún" <kabel@kernel.org>,
	"Mark Pearson" <mpearson-lenovo@squebb.ca>,
	"Derek J. Clark" <derekjohn.clark@gmail.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Ike Panhc" <ikepanhc@gmail.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	Jakub Kicinski <kuba@kernel.org>,
	 Vishnu Sankar <vishnuocv@gmail.com>,
	Vishnu Sankar <vsankar@lenovo.com>,
	 linux-leds@vger.kernel.org, netdev@vger.kernel.org,
	 linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	 chrome-platform@lists.linux.dev,
	platform-driver-x86@vger.kernel.org,  Rong Zhang <i@rong.moe>
Subject: [PATCH v7 04/13] leds: trigger: Move led_trigger_group to the right place
Date: Mon, 21 Sep 2026 03:40:18 +0800	[thread overview]
Message-ID: <20260921-leds-trigger-hw-changed-v7-4-fe3cdb6dec51@rong.moe> (raw)
In-Reply-To: <20260921-leds-trigger-hw-changed-v7-0-fe3cdb6dec51@rong.moe>

Currently led_trigger_group and its members are placed at led-class.c,
but they falls into the triggers namespace and does triggers stuff.
Placing them at led-class.c also requires the read and write callback to
be exported and results in an extra #ifdef block.

Move it into led-triggers.c, so that it becomes the only symbol to be
exported for sysfs attributes.

Signed-off-by: Rong Zhang <i@rong.moe>
---
Changes in v7:
- Add a new patch to the series to collect trigger attribute stuff
  together into led-triggers.c (thanks Lee Jones)
---
 drivers/leds/led-class.c    | 11 -----------
 drivers/leds/led-triggers.c | 25 +++++++++++++++++--------
 drivers/leds/leds.h         |  7 +------
 3 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 39cc2f3ea63f..7f51715fac69 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -90,17 +90,6 @@ static ssize_t max_brightness_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(max_brightness);
 
-#ifdef CONFIG_LEDS_TRIGGERS
-static const BIN_ATTR(trigger, 0644, led_trigger_read, led_trigger_write, 0);
-static const struct bin_attribute *const led_trigger_bin_attrs[] = {
-	&bin_attr_trigger,
-	NULL,
-};
-static const struct attribute_group led_trigger_group = {
-	.bin_attrs = led_trigger_bin_attrs,
-};
-#endif
-
 static struct attribute *led_class_attrs[] = {
 	&dev_attr_brightness.attr,
 	&dev_attr_max_brightness.attr,
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 804a04b326c4..de6056bc80e6 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -52,9 +52,9 @@ bool led_trigger_is_hw_controlled(struct led_classdev *led_cdev)
 }
 EXPORT_SYMBOL_GPL(led_trigger_is_hw_controlled);
 
-ssize_t led_trigger_write(struct file *filp, struct kobject *kobj,
-			  const struct bin_attribute *bin_attr, char *buf,
-			  loff_t pos, size_t count)
+static ssize_t trigger_write(struct file *filp, struct kobject *kobj,
+			     const struct bin_attribute *bin_attr, char *buf,
+			     loff_t pos, size_t count)
 {
 	struct device *dev = kobj_to_dev(kobj);
 	struct led_classdev *led_cdev = dev_get_drvdata(dev);
@@ -97,7 +97,6 @@ ssize_t led_trigger_write(struct file *filp, struct kobject *kobj,
 	mutex_unlock(&led_cdev->led_access);
 	return ret;
 }
-EXPORT_SYMBOL_GPL(led_trigger_write);
 
 __printf(3, 4)
 static int led_trigger_snprintf(char *buf, ssize_t size, const char *fmt, ...)
@@ -149,9 +148,9 @@ static int led_trigger_format(char *buf, size_t size,
  * attribute, which is not limited by length. This is _not_ good design, do not
  * copy it.
  */
-ssize_t led_trigger_read(struct file *filp, struct kobject *kobj,
-			const struct bin_attribute *attr, char *buf,
-			loff_t pos, size_t count)
+static ssize_t trigger_read(struct file *filp, struct kobject *kobj,
+			    const struct bin_attribute *attr, char *buf,
+			    loff_t pos, size_t count)
 {
 	struct device *dev = kobj_to_dev(kobj);
 	struct led_classdev *led_cdev = dev_get_drvdata(dev);
@@ -179,7 +178,17 @@ ssize_t led_trigger_read(struct file *filp, struct kobject *kobj,
 
 	return len;
 }
-EXPORT_SYMBOL_GPL(led_trigger_read);
+static const BIN_ATTR_RW(trigger, 0);
+
+static const struct bin_attribute *const led_trigger_bin_attrs[] = {
+	&bin_attr_trigger,
+	NULL
+};
+
+const struct attribute_group led_trigger_group = {
+	.bin_attrs = led_trigger_bin_attrs,
+};
+EXPORT_SYMBOL_GPL(led_trigger_group);
 
 /* Caller must ensure led_cdev->trigger_lock held */
 int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h
index bee46651e068..c1db21e943b0 100644
--- a/drivers/leds/leds.h
+++ b/drivers/leds/leds.h
@@ -21,14 +21,9 @@ void led_init_core(struct led_classdev *led_cdev);
 void led_stop_software_blink(struct led_classdev *led_cdev);
 void led_set_brightness_nopm(struct led_classdev *led_cdev, unsigned int value);
 void led_set_brightness_nosleep(struct led_classdev *led_cdev, unsigned int value);
-ssize_t led_trigger_read(struct file *filp, struct kobject *kobj,
-			const struct bin_attribute *attr, char *buf,
-			loff_t pos, size_t count);
-ssize_t led_trigger_write(struct file *filp, struct kobject *kobj,
-			const struct bin_attribute *bin_attr, char *buf,
-			loff_t pos, size_t count);
 
 extern struct rw_semaphore leds_list_lock;
 extern struct list_head leds_list;
+extern const struct attribute_group led_trigger_group;
 
 #endif	/* __LEDS_H_INCLUDED */

-- 
2.55.0


  parent reply	other threads:[~2026-09-20 19:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-20 19:40 [PATCH v7 00/13] leds: Add support for hardware-initiated hardware control trigger transition Rong Zhang
2026-09-20 19:40 ` [PATCH v7 01/13] leds: class: Always protect brightness_show() with led_access Rong Zhang
2026-09-20 19:40 ` [PATCH v7 02/13] leds: trigger: Move led_trigger_is_hw_controlled() to the right place Rong Zhang
2026-09-24  8:37   ` Lee Jones
2026-09-24 11:45     ` Rong Zhang
2026-09-20 19:40 ` [PATCH v7 03/13] leds: class: Remove hardware control trigger when writing brightness Rong Zhang
2026-09-20 19:40 ` Rong Zhang [this message]
2026-09-20 19:40 ` [PATCH v7 05/13] leds: trigger: Add hw_offloaded() callback and provide trigger_may_offload_to_hw attribute Rong Zhang
2026-09-20 19:40 ` [PATCH v7 06/13] leds: cros_ec: Implement hw_offloaded() trigger callback Rong Zhang
2026-09-20 19:40 ` [PATCH v7 07/13] leds: turris-omnia: Implement hw_offloaded() trigger callback and declare hw_control_trigger Rong Zhang
2026-09-20 19:40 ` [PATCH v7 08/13] leds: trigger: netdev: Implement hw_offloaded() callback Rong Zhang
2026-09-24  8:53   ` Lee Jones
2026-09-24 11:47     ` Rong Zhang
2026-09-20 19:40 ` [PATCH v7 09/13] leds: trigger: Enforce strict checks in led_trigger_is_hw_controlled() Rong Zhang
2026-09-20 19:40 ` [PATCH v7 10/13] leds: trigger: Add led_trigger_notify_hw_control_changed() interface Rong Zhang
2026-09-20 19:40 ` [PATCH v7 11/13] platform/x86: ideapad-laptop: Serialize keyboard backlight tracking Rong Zhang
2026-09-20 19:40 ` [PATCH v7 12/13] platform/x86: ideapad-laptop: Decouple hardware & classdev brightness for keyboard backlight Rong Zhang
2026-09-20 19:40 ` [PATCH v7 13/13] platform/x86: ideapad-laptop: Fully support auto " Rong Zhang
2026-09-24 12:25 ` (subset) [PATCH v7 00/13] leds: Add support for hardware-initiated hardware control trigger transition Lee Jones

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=20260921-leds-trigger-hw-changed-v7-4-fe3cdb6dec51@rong.moe \
    --to=i@rong.moe \
    --cc=andrew+netdev@lunn.ch \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=corbet@lwn.net \
    --cc=derekjohn.clark@gmail.com \
    --cc=groeck@chromium.org \
    --cc=hansg@kernel.org \
    --cc=ikepanhc@gmail.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=kabel@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=vishnuocv@gmail.com \
    --cc=vsankar@lenovo.com \
    /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