hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c
....@@ -1,7 +1,9 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #include <net/mac80211.h>
33 #include <linux/bcma/bcma_driver_chipcommon.h>
4
-#include <linux/gpio.h>
4
+#include <linux/gpio/driver.h>
5
+#include <linux/gpio/machine.h>
6
+#include <linux/gpio/consumer.h>
57
68 #include "mac80211_if.h"
79 #include "pub.h"
....@@ -19,16 +21,13 @@
1921
2022 static void brcms_radio_led_ctrl(struct brcms_info *wl, bool state)
2123 {
22
- if (wl->radio_led.gpio == -1)
24
+ if (!wl->radio_led.gpiod)
2325 return;
2426
25
- if (wl->radio_led.active_low)
26
- state = !state;
27
-
2827 if (state)
29
- gpio_set_value(wl->radio_led.gpio, 1);
28
+ gpiod_set_value(wl->radio_led.gpiod, 1);
3029 else
31
- gpio_set_value(wl->radio_led.gpio, 0);
30
+ gpiod_set_value(wl->radio_led.gpiod, 0);
3231 }
3332
3433
....@@ -45,8 +44,8 @@
4544 {
4645 if (wl->led_dev.dev)
4746 led_classdev_unregister(&wl->led_dev);
48
- if (wl->radio_led.gpio != -1)
49
- gpio_free(wl->radio_led.gpio);
47
+ if (wl->radio_led.gpiod)
48
+ gpiochip_free_own_desc(wl->radio_led.gpiod);
5049 }
5150
5251 int brcms_led_register(struct brcms_info *wl)
....@@ -61,12 +60,8 @@
6160 &sprom->gpio1,
6261 &sprom->gpio2,
6362 &sprom->gpio3 };
64
- unsigned gpio = -1;
65
- bool active_low = false;
66
-
67
- /* none by default */
68
- radio_led->gpio = -1;
69
- radio_led->active_low = false;
63
+ int hwnum = -1;
64
+ enum gpio_lookup_flags lflags = GPIO_ACTIVE_HIGH;
7065
7166 if (!bcma_gpio || !gpio_is_valid(bcma_gpio->base))
7267 return -ENODEV;
....@@ -75,30 +70,26 @@
7570 for (i = 0; i < BRCMS_LED_NO; i++) {
7671 u8 led = *leds[i];
7772 if ((led & BRCMS_LED_BEH_MASK) == BRCMS_LED_RADIO) {
78
- gpio = bcma_gpio->base + i;
73
+ hwnum = i;
7974 if (led & BRCMS_LED_AL_MASK)
80
- active_low = true;
75
+ lflags = GPIO_ACTIVE_LOW;
8176 break;
8277 }
8378 }
8479
85
- if (gpio == -1 || !gpio_is_valid(gpio))
80
+ /* No LED, bail out */
81
+ if (hwnum == -1)
8682 return -ENODEV;
8783
88
- /* request and configure LED gpio */
89
- err = gpio_request_one(gpio,
90
- active_low ? GPIOF_OUT_INIT_HIGH
91
- : GPIOF_OUT_INIT_LOW,
92
- "radio on");
93
- if (err) {
94
- wiphy_err(wl->wiphy, "requesting led gpio %d failed (err: %d)\n",
95
- gpio, err);
96
- return err;
97
- }
98
- err = gpio_direction_output(gpio, 1);
99
- if (err) {
100
- wiphy_err(wl->wiphy, "cannot set led gpio %d to output (err: %d)\n",
101
- gpio, err);
84
+ /* Try to obtain this LED GPIO line */
85
+ radio_led->gpiod = gpiochip_request_own_desc(bcma_gpio, hwnum,
86
+ "radio on", lflags,
87
+ GPIOD_OUT_LOW);
88
+
89
+ if (IS_ERR(radio_led->gpiod)) {
90
+ err = PTR_ERR(radio_led->gpiod);
91
+ wiphy_err(wl->wiphy, "requesting led GPIO failed (err: %d)\n",
92
+ err);
10293 return err;
10394 }
10495
....@@ -117,11 +108,8 @@
117108 return err;
118109 }
119110
120
- wiphy_info(wl->wiphy, "registered radio enabled led device: %s gpio: %d\n",
121
- wl->radio_led.name,
122
- gpio);
123
- radio_led->gpio = gpio;
124
- radio_led->active_low = active_low;
111
+ wiphy_info(wl->wiphy, "registered radio enabled led device: %s\n",
112
+ wl->radio_led.name);
125113
126114 return 0;
127115 }