Hi Marek,
Bitops are guaranteed to be atomic and this was done for a reason.
On 10/30/20 12:44 PM, Marek Behún wrote:
Use bit fields members in struct led_netdev_data instead of one mode
member and set_bit/clear_bit/test_bit functions. These functions are
suitable for longer or variable length bit arrays.
Signed-off-by: Marek Behún <kabel@xxxxxxxxxx>
---
drivers/leds/trigger/ledtrig-netdev.c | 69 ++++++++++++---------------
1 file changed, 30 insertions(+), 39 deletions(-)
diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
index 4f6b73e3b491..8f013b6df4fa 100644
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -49,11 +49,11 @@ struct led_netdev_data {
atomic_t interval;
unsigned int last_activity;
- unsigned long mode;
-#define NETDEV_LED_LINK 0
-#define NETDEV_LED_TX 1
-#define NETDEV_LED_RX 2
-#define NETDEV_LED_MODE_LINKUP 3
+ unsigned link:1;
+ unsigned tx:1;
+ unsigned rx:1;
+
+ unsigned linkup:1;
};
enum netdev_led_attr {
@@ -73,10 +73,10 @@ 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 (!trigger_data->linkup)
led_set_brightness(led_cdev, LED_OFF);
[...]
--
Best regards,
Jacek Anaszewski