1 From bdec9cb83936e0ac4cb87fed5b49fad0175f7dec Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Wed, 19 Apr 2023 23:07:41 +0200
4 Subject: [PATCH 3/5] leds: trigger: netdev: Rename add namespace to netdev
7 Rename NETDEV trigger enum modes to a more symbolic name and add a
10 Also add __TRIGGER_NETDEV_MAX to identify the max modes of the netdev
13 This is a cleanup to drop the define and no behaviour change are
16 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
17 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
18 Signed-off-by: Lee Jones <lee@kernel.org>
19 Link: https://lore.kernel.org/r/20230419210743.3594-4-ansuelsmth@gmail.com
21 drivers/leds/trigger/ledtrig-netdev.c | 58 ++++++++++++---------------
22 1 file changed, 25 insertions(+), 33 deletions(-)
24 --- a/drivers/leds/trigger/ledtrig-netdev.c
25 +++ b/drivers/leds/trigger/ledtrig-netdev.c
26 @@ -51,15 +51,15 @@ struct led_netdev_data {
30 -#define NETDEV_LED_LINK 0
31 -#define NETDEV_LED_TX 1
32 -#define NETDEV_LED_RX 2
35 -enum netdev_led_attr {
39 +enum led_trigger_netdev_modes {
40 + TRIGGER_NETDEV_LINK = 0,
45 + __TRIGGER_NETDEV_MAX,
48 static void set_baseline_state(struct led_netdev_data *trigger_data)
49 @@ -76,7 +76,7 @@ static void set_baseline_state(struct le
50 if (!trigger_data->carrier_link_up) {
51 led_set_brightness(led_cdev, LED_OFF);
53 - if (test_bit(NETDEV_LED_LINK, &trigger_data->mode))
54 + if (test_bit(TRIGGER_NETDEV_LINK, &trigger_data->mode))
55 led_set_brightness(led_cdev,
56 led_cdev->blink_brightness);
58 @@ -85,8 +85,8 @@ static void set_baseline_state(struct le
59 /* If we are looking for RX/TX start periodically
62 - if (test_bit(NETDEV_LED_TX, &trigger_data->mode) ||
63 - test_bit(NETDEV_LED_RX, &trigger_data->mode))
64 + if (test_bit(TRIGGER_NETDEV_TX, &trigger_data->mode) ||
65 + test_bit(TRIGGER_NETDEV_RX, &trigger_data->mode))
66 schedule_delayed_work(&trigger_data->work, 0);
69 @@ -146,20 +146,16 @@ static ssize_t device_name_store(struct
70 static DEVICE_ATTR_RW(device_name);
72 static ssize_t netdev_led_attr_show(struct device *dev, char *buf,
73 - enum netdev_led_attr attr)
74 + enum led_trigger_netdev_modes attr)
76 struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev);
80 - case NETDEV_ATTR_LINK:
81 - bit = NETDEV_LED_LINK;
83 - case NETDEV_ATTR_TX:
84 - bit = NETDEV_LED_TX;
86 - case NETDEV_ATTR_RX:
87 - bit = NETDEV_LED_RX;
88 + case TRIGGER_NETDEV_LINK:
89 + case TRIGGER_NETDEV_TX:
90 + case TRIGGER_NETDEV_RX:
95 @@ -169,7 +165,7 @@ static ssize_t netdev_led_attr_show(stru
98 static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
99 - size_t size, enum netdev_led_attr attr)
100 + size_t size, enum led_trigger_netdev_modes attr)
102 struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev);
104 @@ -181,14 +177,10 @@ static ssize_t netdev_led_attr_store(str
108 - case NETDEV_ATTR_LINK:
109 - bit = NETDEV_LED_LINK;
111 - case NETDEV_ATTR_TX:
112 - bit = NETDEV_LED_TX;
114 - case NETDEV_ATTR_RX:
115 - bit = NETDEV_LED_RX;
116 + case TRIGGER_NETDEV_LINK:
117 + case TRIGGER_NETDEV_TX:
118 + case TRIGGER_NETDEV_RX:
123 @@ -360,21 +352,21 @@ static void netdev_trig_work(struct work
126 /* If we are not looking for RX/TX then return */
127 - if (!test_bit(NETDEV_LED_TX, &trigger_data->mode) &&
128 - !test_bit(NETDEV_LED_RX, &trigger_data->mode))
129 + if (!test_bit(TRIGGER_NETDEV_TX, &trigger_data->mode) &&
130 + !test_bit(TRIGGER_NETDEV_RX, &trigger_data->mode))
133 dev_stats = dev_get_stats(trigger_data->net_dev, &temp);
135 - (test_bit(NETDEV_LED_TX, &trigger_data->mode) ?
136 + (test_bit(TRIGGER_NETDEV_TX, &trigger_data->mode) ?
137 dev_stats->tx_packets : 0) +
138 - (test_bit(NETDEV_LED_RX, &trigger_data->mode) ?
139 + (test_bit(TRIGGER_NETDEV_RX, &trigger_data->mode) ?
140 dev_stats->rx_packets : 0);
142 if (trigger_data->last_activity != new_activity) {
143 led_stop_software_blink(trigger_data->led_cdev);
145 - invert = test_bit(NETDEV_LED_LINK, &trigger_data->mode);
146 + invert = test_bit(TRIGGER_NETDEV_LINK, &trigger_data->mode);
147 interval = jiffies_to_msecs(
148 atomic_read(&trigger_data->interval));
149 /* base state is ON (link present) */