Skip to content

Commit a8d1a32

Browse files
ajaykathatclaudiubeznea
authored andcommitted
staging: wilc1000: use 'interrupt' for handling IRQ
Modified code to handle IRQ using 'interrupt' property. Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
1 parent 80bea52 commit a8d1a32

5 files changed

Lines changed: 16 additions & 84 deletions

File tree

drivers/staging/wilc1000/netdev.c

Lines changed: 7 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -167,88 +167,35 @@ static irqreturn_t isr_bh_routine(int irq, void *userdata)
167167

168168
static int init_irq(struct net_device *dev)
169169
{
170-
int ret = 0;
171170
struct wilc_vif *vif = netdev_priv(dev);
172171
struct wilc *wl = vif->wilc;
173172

174-
#if KERNEL_VERSION(3, 13, 0) < LINUX_VERSION_CODE
175-
176-
wl->gpio_irq = gpiod_get(wl->dt_dev, "irq", GPIOD_IN);
177-
if (IS_ERR(wl->gpio_irq)) {
178-
dev_warn(wl->dev, "failed to get IRQ GPIO, load default\r\n");
179-
wl->gpio_irq = gpio_to_desc(GPIO_NUM);
180-
if (!wl->gpio_irq) {
181-
dev_warn(wl->dev, "failed to load default irq\r\n");
182-
return -EINVAL;
183-
}
184-
} else {
185-
dev_info(wl->dev, "got gpio_irq successfully\r\n");
186-
}
187-
188-
ret = gpiod_direction_input(wl->gpio_irq);
189-
if (ret) {
190-
PRINT_ER(dev, "could not obtain gpio for WILC_INTR\n");
191-
return -EINVAL;
192-
}
193-
194-
wl->dev_irq_num = gpiod_to_irq(wl->gpio_irq);
195-
if (wl->dev_irq_num < 0) {
196-
PRINT_ER(dev, "could not the IRQ\n");
197-
goto free_gpio;
198-
}
199-
#else
200-
wl->gpio_irq = of_get_named_gpio_flags(wl->dt_dev->of_node,
201-
"irq-gpios", 0, NULL);
202-
if (wl->gpio_irq < 0) {
203-
wl->gpio_irq = GPIO_NUM;
204-
dev_warn(wl->dev, "failed to get IRQ GPIO, load default\r\n");
205-
}
206-
207-
if ((gpio_request(wl->gpio_irq, "WILC_INTR") == 0) &&
208-
(gpio_direction_input(wl->gpio_irq) == 0)) {
209-
wl->dev_irq_num = gpio_to_irq(wl->gpio_irq);
210-
} else {
211-
dev_err(wl->dev, "could not obtain gpio for WILC_INTR\n");
212-
wl->gpio_irq = 0;
213-
return -EINVAL;
214-
}
215-
216-
#endif
217-
218173
if (wl->io_type == WILC_HIF_SPI ||
219174
wl->io_type == WILC_HIF_SDIO_GPIO_IRQ) {
220175
if (request_threaded_irq(wl->dev_irq_num, isr_uh_routine,
221176
isr_bh_routine, IRQF_TRIGGER_FALLING |
222177
IRQF_ONESHOT |
223178
IRQF_NO_SUSPEND,
224179
"WILC_IRQ", wl) < 0) {
225-
PRINT_ER(dev, "Failed to request IRQ\n");
226-
goto free_gpio;
180+
PRINT_ER(dev, "Failed to request IRQ [%d]\n",
181+
wl->dev_irq_num);
182+
return -EINVAL;
227183
}
228184
} else {
229185
if (request_irq(wl->dev_irq_num, host_wakeup_isr,
230186
IRQF_TRIGGER_FALLING |
231187
IRQF_NO_SUSPEND,
232188
"WILC_IRQ", wl) < 0) {
233-
PRINT_ER(dev, "Failed to request IRQ\n");
234-
goto free_gpio;
189+
PRINT_ER(dev, "Failed to request IRQ [%d]\n",
190+
wl->dev_irq_num);
191+
return -EINVAL;
235192
}
236193
}
237194

238195
PRINT_INFO(dev, GENERIC_DBG, "IRQ request succeeded IRQ-NUM= %d\n",
239196
wl->dev_irq_num);
240197
enable_irq_wake(wl->dev_irq_num);
241198
return 0;
242-
243-
free_gpio:
244-
#if KERNEL_VERSION(3, 13, 0) < LINUX_VERSION_CODE
245-
gpiod_put(wl->gpio_irq);
246-
wl->gpio_irq = NULL;
247-
#else
248-
gpio_free(wl->gpio_irq);
249-
wl->gpio_irq = 0;
250-
#endif
251-
return -EINVAL;
252199
}
253200

254201
static void deinit_irq(struct net_device *dev)
@@ -257,24 +204,8 @@ static void deinit_irq(struct net_device *dev)
257204
struct wilc *wilc = vif->wilc;
258205

259206
/* Deinitialize IRQ */
260-
if (wilc->dev_irq_num > 0) {
207+
if (wilc->dev_irq_num)
261208
free_irq(wilc->dev_irq_num, wilc);
262-
wilc->dev_irq_num = -1;
263-
}
264-
265-
#if KERNEL_VERSION(3, 13, 0) < LINUX_VERSION_CODE
266-
if (wilc->gpio_irq) {
267-
gpiod_put(wilc->gpio_irq);
268-
wilc->gpio_irq = NULL;
269-
}
270-
#else
271-
if (wilc->gpio_irq > 0) {
272-
gpio_free(wilc->gpio_irq);
273-
wilc->gpio_irq = 0;
274-
}
275-
276-
#endif
277-
278209
}
279210

280211
void wilc_mac_indicate(struct wilc *wilc)

drivers/staging/wilc1000/netdev.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,6 @@ struct wilc {
377377
const struct wilc_hif_func *hif_func;
378378
int io_type;
379379
s8 mac_status;
380-
#if KERNEL_VERSION(3, 13, 0) < LINUX_VERSION_CODE
381-
struct gpio_desc *gpio_irq;
382-
#else
383-
int gpio_irq;
384-
#endif
385380
struct clk *rtc_clk;
386381
bool initialized;
387382
int dev_irq_num;

drivers/staging/wilc1000/sdio.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/module.h>
1212
#include <linux/pm_runtime.h>
1313
#include <linux/mmc/sdio.h>
14+
#include <linux/of_irq.h>
1415

1516
#include "netdev.h"
1617
#include "wlan.h"
@@ -148,6 +149,7 @@ static int wilc_sdio_probe(struct sdio_func *func,
148149
int ret, io_type;
149150
static bool init_power;
150151
struct wilc_sdio *sdio_priv;
152+
int irq_num;
151153

152154
sdio_priv = kzalloc(sizeof(*sdio_priv), GFP_KERNEL);
153155
if (!sdio_priv)
@@ -170,7 +172,11 @@ static int wilc_sdio_probe(struct sdio_func *func,
170172
wilc->dt_dev = &func->card->dev;
171173
sdio_priv->wl = wilc;
172174

173-
wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc_clk");
175+
irq_num = of_irq_get(func->card->dev.of_node, 0);
176+
if (irq_num > 0)
177+
wilc->dev_irq_num = irq_num;
178+
179+
wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc");
174180
if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
175181
return -EPROBE_DEFER;
176182
else if (!IS_ERR(wilc->rtc_clk))

drivers/staging/wilc1000/spi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ static int wilc_bus_probe(struct spi_device *spi)
134134
wilc->dev = &spi->dev;
135135
wilc->bus_data = spi_priv;
136136
wilc->dt_dev = &spi->dev;
137+
wilc->dev_irq_num = spi->irq;
137138

138-
wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc_clk");
139+
wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc");
139140
if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
140141
return -EPROBE_DEFER;
141142
else if (!IS_ERR(wilc->rtc_clk))

drivers/staging/wilc1000/wlan.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ static inline bool is_wilc3000(u32 id)
241241
#define WILC_TX_BUFF_SIZE (64 * 1024)
242242

243243
#define MODALIAS "WILC_SPI"
244-
#define GPIO_NUM 0x5B
245244
#define GPIO_NUM_CHIP_EN 94
246245
#define GPIO_NUM_RESET 60
247246

0 commit comments

Comments
 (0)