@@ -170,6 +170,9 @@ static int init_irq(struct net_device *dev)
170170 struct wilc_vif * vif = netdev_priv (dev );
171171 struct wilc * wl = vif -> wilc ;
172172
173+ if (wl -> dev_irq_num <= 0 )
174+ return 0 ;
175+
173176 if (wl -> io_type == WILC_HIF_SPI ||
174177 wl -> io_type == WILC_HIF_SDIO_GPIO_IRQ ) {
175178 if (request_threaded_irq (wl -> dev_irq_num , isr_uh_routine ,
@@ -182,8 +185,7 @@ static int init_irq(struct net_device *dev)
182185 return - EINVAL ;
183186 }
184187 } else {
185- if (wl -> dev_irq_num &&
186- request_irq (wl -> dev_irq_num , host_wakeup_isr ,
188+ if (request_irq (wl -> dev_irq_num , host_wakeup_isr ,
187189 IRQF_TRIGGER_FALLING |
188190 IRQF_NO_SUSPEND ,
189191 "WILC_IRQ" , wl ) < 0 ) {
@@ -1345,152 +1347,4 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
13451347 return vif ;
13461348}
13471349
1348- #if KERNEL_VERSION (3 , 13 , 0 ) < LINUX_VERSION_CODE
1349- static int wilc_wlan_power (struct wilc * wilc , int power )
1350- {
1351- struct gpio_desc * gpio_reset ;
1352- struct gpio_desc * gpio_chip_en ;
1353- int ret = 0 ;
1354-
1355- pr_info ("wifi_pm : %d\n" , power );
1356-
1357- gpio_reset = gpiod_get (wilc -> dt_dev , "reset" , GPIOD_ASIS );
1358- if (IS_ERR (gpio_reset )) {
1359- dev_warn (wilc -> dev , "failed to get Reset GPIO, try default\r\n" );
1360- gpio_reset = gpio_to_desc (GPIO_NUM_RESET );
1361- if (!gpio_reset ) {
1362- dev_warn (wilc -> dev ,
1363- "failed to get default Reset GPIO\r\n" );
1364- return - EIO ;
1365- }
1366- } else {
1367- dev_info (wilc -> dev , "succesfully got gpio_reset\r\n" );
1368- }
1369-
1370- gpio_chip_en = gpiod_get (wilc -> dt_dev , "chip_en" , GPIOD_ASIS );
1371- if (IS_ERR (gpio_chip_en )) {
1372- gpio_chip_en = gpio_to_desc (GPIO_NUM_CHIP_EN );
1373- if (!gpio_chip_en ) {
1374- dev_warn (wilc -> dev ,
1375- "failed to get default chip_en GPIO\r\n" );
1376- gpiod_put (gpio_reset );
1377- return - EIO ;
1378- }
1379- } else {
1380- dev_info (wilc -> dev , "succesfully got gpio_chip_en\r\n" );
1381- }
1382-
1383- if (power ) {
1384- ret = gpiod_direction_output (gpio_chip_en , 1 );
1385- if (ret < 0 ) {
1386- dev_warn (wilc -> dev ,
1387- "failed to set chip_en GPIO direction\r\n" );
1388- goto out ;
1389- ret = - EIO ;
1390- }
1391- mdelay (5 );
1392- ret = gpiod_direction_output (gpio_reset , 1 );
1393- if (ret ) {
1394- dev_warn (wilc -> dev ,
1395- "failed to set reset GPIO direction\r\n" );
1396- goto out ;
1397- ret = - EIO ;
1398- }
1399- } else {
1400- ret = gpiod_direction_output (gpio_reset , 0 );
1401- if (ret ) {
1402- dev_warn (wilc -> dev ,
1403- "failed to set chip_en GPIO direction\r\n" );
1404- goto out ;
1405- ret = - EIO ;
1406- }
1407- ret = gpiod_direction_output (gpio_chip_en , 0 );
1408- if (ret ) {
1409- dev_warn (wilc -> dev ,
1410- "failed to set reset GPIO direction\r\n" );
1411- goto out ;
1412- ret = - EIO ;
1413- }
1414- }
1415-
1416- out :
1417- gpiod_put (gpio_chip_en );
1418- gpiod_put (gpio_reset );
1419-
1420- return ret ;
1421- }
1422- #else
1423- static int wilc_wlan_power (struct wilc * wilc , int power )
1424- {
1425- int gpio_reset ;
1426- int gpio_chip_en ;
1427- struct device_node * of_node = wilc -> dt_dev -> of_node ;
1428-
1429- pr_info ("wifi_pm : %d\n" , power );
1430-
1431- gpio_reset = of_get_named_gpio_flags (of_node , "reset-gpios" , 0 , NULL );
1432-
1433- if (gpio_reset < 0 ) {
1434- gpio_reset = GPIO_NUM_RESET ;
1435- pr_info ("wifi_pm : load default reset GPIO %d\n" , gpio_reset );
1436- }
1437-
1438- gpio_chip_en = of_get_named_gpio_flags (of_node , "chip_en-gpios" , 0 ,
1439- NULL );
1440-
1441- if (gpio_chip_en < 0 ) {
1442- gpio_chip_en = GPIO_NUM_CHIP_EN ;
1443- pr_info ("wifi_pm : load default chip_en GPIO %d\n" ,
1444- gpio_chip_en );
1445- }
1446-
1447- if (gpio_request (gpio_chip_en , "CHIP_EN" ) == 0 &&
1448- gpio_request (gpio_reset , "RESET" ) == 0 ) {
1449- gpio_direction_output (gpio_chip_en , 0 );
1450- gpio_direction_output (gpio_reset , 0 );
1451- if (power ) {
1452- gpio_set_value (gpio_chip_en , 1 );
1453- mdelay (5 );
1454- gpio_set_value (gpio_reset , 1 );
1455- } else {
1456- gpio_set_value (gpio_reset , 0 );
1457- gpio_set_value (gpio_chip_en , 0 );
1458- }
1459- gpio_free (gpio_chip_en );
1460- gpio_free (gpio_reset );
1461- } else {
1462- dev_err (wilc -> dev ,
1463- "Error requesting GPIOs for CHIP_EN and RESET" );
1464- return - EIO ;
1465- }
1466-
1467- return 0 ;
1468- }
1469- #endif
1470-
1471- int wilc_wlan_power_on_sequence (struct wilc * wilc )
1472- {
1473- int ret ;
1474-
1475- ret = wilc_wlan_power (wilc , 0 );
1476- if (ret )
1477- return ret ;
1478- ret = wilc_wlan_power (wilc , 1 );
1479- if (ret )
1480- return ret ;
1481-
1482- return 0 ;
1483- }
1484-
1485- int wilc_wlan_power_off_sequence (struct wilc * wilc )
1486- {
1487- int ret ;
1488-
1489- ret = wilc_wlan_power (wilc , 0 );
1490- if (ret )
1491- return ret ;
1492-
1493- return 0 ;
1494- }
1495-
14961350MODULE_LICENSE ("GPL" );
0 commit comments