[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210601005155.27997-5-kabel@kernel.org>
Date: Tue, 1 Jun 2021 02:51:49 +0200
From: Marek Behún <kabel@...nel.org>
To: linux-leds@...r.kernel.org
Cc: netdev@...r.kernel.org, Pavel Machek <pavel@....cz>,
Dan Murphy <dmurphy@...com>,
Russell King <linux@...linux.org.uk>,
Andrew Lunn <andrew@...n.ch>,
Matthias Schiffer <matthias.schiffer@...tq-group.com>,
Jacek Anaszewski <jacek.anaszewski@...il.com>,
Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
Marek Behún <kabel@...nel.org>
Subject: [PATCH leds v2 04/10] leds: trigger: netdev: support HW offloading
Add support for HW offloading of the netdev trigger.
We are only offloading if the link is up and rx/tx blinking is
requested.
Signed-off-by: Marek Behún <kabel@...nel.org>
---
drivers/leds/trigger/ledtrig-netdev.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
index 9a98f9c5b8d0..1f1b63d5a78d 100644
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -52,9 +52,17 @@ static void set_baseline_state(struct led_netdev_data *trigger_data)
if (!led_cdev->blink_brightness)
led_cdev->blink_brightness = led_cdev->max_brightness;
- if (!test_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode))
+ if (!test_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode)) {
+ led_trigger_offload_stop(led_cdev);
led_set_brightness(led_cdev, LED_OFF);
- else {
+ } else {
+ bool blink = test_bit(NETDEV_LED_TX, &trigger_data->mode) ||
+ test_bit(NETDEV_LED_RX, &trigger_data->mode);
+ /* Try offload to HW only if RX/TX blinking is requested */
+ if (blink)
+ if (!led_trigger_offload(led_cdev))
+ return;
+
if (test_bit(NETDEV_LED_LINK, &trigger_data->mode))
led_set_brightness(led_cdev,
led_cdev->blink_brightness);
@@ -64,8 +72,7 @@ static void set_baseline_state(struct led_netdev_data *trigger_data)
/* If we are looking for RX/TX start periodically
* checking stats
*/
- if (test_bit(NETDEV_LED_TX, &trigger_data->mode) ||
- test_bit(NETDEV_LED_RX, &trigger_data->mode))
+ if (blink)
schedule_delayed_work(&trigger_data->work, 0);
}
}
--
2.26.3
Powered by blists - more mailing lists