mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Rong Zhang <i@rong.moe>
Cc: "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>,
	"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
Subject: Re: [PATCH v7 08/13] leds: trigger: netdev: Implement hw_offloaded() callback
Date: Thu, 24 Sep 2026 09:53:16 +0100	[thread overview]
Message-ID: <20260924085316.GB331088@google.com> (raw)
In-Reply-To: <20260921-leds-trigger-hw-changed-v7-8-fe3cdb6dec51@rong.moe>

--- checkpatch.pl: clean (0 issues) ---

On Mon, 21 Sep 2026, Rong Zhang wrote:

> "netdev" can run in hardware control according to hardware capabilities
> and trigger options.
> 
> Implement hw_offloaded() callback to provide its hardware control state
> to the LED core, and document the relation between the custom
> "offloaded" attribute and the generic "trigger_may_offload_to_hw"
> attribute.
> 
> The callback mimics how the existing "offloaded" attribute does, i.e.,
> locklessly reads hw_control, as it's just a hint and don't need to be
> accurate.
> 
> Acked-by: Ike Panhc <ikepanhc@gmail.com>
> Signed-off-by: Rong Zhang <i@rong.moe>
> ---
> Changes in v7:
> - Rename the offloaded() callback to hw_offloaded() (thanks Lee Jones)
> - Rename the trigger_may_offload attribute to
>   trigger_may_offload_to_hw (ditto)
> 
> Changes in v3:
> - Do not deprecate netdev's "offloaded" attribute (thanks Thomas
>   Weißschuh)
> - Document the relation between the custom "offloaded" attribute and the
>   generic "trigger_may_offload" attribute (ditto)
> ---
>  Documentation/ABI/testing/sysfs-class-led                | 3 +++
>  Documentation/ABI/testing/sysfs-class-led-trigger-netdev | 3 +++
>  drivers/leds/trigger/ledtrig-netdev.c                    | 8 ++++++++
>  3 files changed, 14 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-class-led b/Documentation/ABI/testing/sysfs-class-led
> index 123e3a15b7d6..ea113fed10ef 100644
> --- a/Documentation/ABI/testing/sysfs-class-led
> +++ b/Documentation/ABI/testing/sysfs-class-led
> @@ -101,6 +101,9 @@ Description:
>  		- `[foo_trigger]`: the trigger is selected and offloaded to
>  		  hardware.
>  
> +		The "netdev" trigger also provides a custom attribute to
> +		indicate its state, see `/sys/class/leds/<led>/offloaded`.
> +
>  What:		/sys/class/leds/<led>/inverted
>  Date:		January 2011
>  KernelVersion:	2.6.38
> diff --git a/Documentation/ABI/testing/sysfs-class-led-trigger-netdev b/Documentation/ABI/testing/sysfs-class-led-trigger-netdev
> index ed46b37ab8a2..203ea58396ed 100644
> --- a/Documentation/ABI/testing/sysfs-class-led-trigger-netdev
> +++ b/Documentation/ABI/testing/sysfs-class-led-trigger-netdev
> @@ -75,6 +75,9 @@ Description:
>  		If 1, the LED blinking in requested mode is offloaded to
>  		hardware.
>  
> +		LED trigger core also provides a generic attribute for this
> +		purpose, see `/sys/class/leds/<led>/trigger_may_offload_to_hw`.
> +
>  What:		/sys/class/leds/<led>/link_10
>  Date:		Jun 2023
>  KernelVersion:	6.5
> diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
> index 5b4e92c14dbb..60409f054e22 100644
> --- a/drivers/leds/trigger/ledtrig-netdev.c
> +++ b/drivers/leds/trigger/ledtrig-netdev.c
> @@ -798,10 +798,18 @@ static void netdev_trig_deactivate(struct led_classdev *led_cdev)
>  	kfree(trigger_data);
>  }
>  
> +static bool netdev_trig_hw_offloaded(struct led_classdev *led_cdev)
> +{
> +	struct led_netdev_data *trigger_data = led_get_trigger_data(led_cdev);
> +
> +	return trigger_data->hw_control;

How sure are we that trigger_data can NEVER be NULL?

> +}
> +
>  static struct led_trigger netdev_led_trigger = {
>  	.name = "netdev",
>  	.activate = netdev_trig_activate,
>  	.deactivate = netdev_trig_deactivate,
> +	.hw_offloaded = netdev_trig_hw_offloaded,
>  	.groups = netdev_trig_groups,
>  };
>  
> 
> -- 
> 2.55.0
> 

-- 
Lee Jones

  reply	other threads:[~2026-09-24  8:53 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 ` [PATCH v7 04/13] leds: trigger: Move led_trigger_group to the right place Rong Zhang
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 [this message]
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=20260924085316.GB331088@google.com \
    --to=lee@kernel.org \
    --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=i@rong.moe \
    --cc=ikepanhc@gmail.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=kabel@kernel.org \
    --cc=kuba@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

all inboxes | Powered by JetHome®