Skip to content

Commit 7a80aa2

Browse files
ajaykathatgregkh
authored andcommitted
staging: wilc1000: return zero on success and non-zero on function failure
Some of the HIF layer API's return zero for failure and non-zero for success condition. Now, modified the functions to return zero for success and non-zero for failure as its recommended approach suggested in [1]. 1. https://lore.kernel.org/driverdev-devel/[email protected]/ Signed-off-by: Ajay Singh <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0443b3f commit 7a80aa2

File tree

4 files changed

+197
-239
lines changed

4 files changed

+197
-239
lines changed

drivers/staging/wilc1000/netdev.c

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static int wilc_wlan_get_firmware(struct net_device *dev)
183183
{
184184
struct wilc_vif *vif = netdev_priv(dev);
185185
struct wilc *wilc = vif->wilc;
186-
int chip_id, ret = 0;
186+
int chip_id;
187187
const struct firmware *wilc_firmware;
188188
char *firmware;
189189

@@ -198,14 +198,11 @@ static int wilc_wlan_get_firmware(struct net_device *dev)
198198

199199
if (request_firmware(&wilc_firmware, firmware, wilc->dev) != 0) {
200200
netdev_err(dev, "%s - firmware not available\n", firmware);
201-
ret = -1;
202-
goto fail;
201+
return -EINVAL;
203202
}
204203
wilc->firmware = wilc_firmware;
205204

206-
fail:
207-
208-
return ret;
205+
return 0;
209206
}
210207

211208
static int wilc_start_firmware(struct net_device *dev)
@@ -215,7 +212,7 @@ static int wilc_start_firmware(struct net_device *dev)
215212
int ret = 0;
216213

217214
ret = wilc_wlan_start(wilc);
218-
if (ret < 0)
215+
if (ret)
219216
return ret;
220217

221218
if (!wait_for_completion_timeout(&wilc->sync_event,
@@ -238,7 +235,7 @@ static int wilc1000_firmware_download(struct net_device *dev)
238235

239236
ret = wilc_wlan_firmware_download(wilc, wilc->firmware->data,
240237
wilc->firmware->size);
241-
if (ret < 0)
238+
if (ret)
242239
return ret;
243240

244241
release_firmware(wilc->firmware);
@@ -417,7 +414,7 @@ static int wilc_init_fw_config(struct net_device *dev, struct wilc_vif *vif)
417414
return 0;
418415

419416
fail:
420-
return -1;
417+
return -EINVAL;
421418
}
422419

423420
static void wlan_deinitialize_threads(struct net_device *dev)
@@ -497,14 +494,12 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
497494
wl->close = 0;
498495

499496
ret = wilc_wlan_init(dev);
500-
if (ret < 0)
501-
return -EIO;
497+
if (ret)
498+
return ret;
502499

503500
ret = wlan_initialize_threads(dev);
504-
if (ret < 0) {
505-
ret = -EIO;
501+
if (ret)
506502
goto fail_wilc_wlan;
507-
}
508503

509504
if (wl->gpio_irq && init_irq(dev)) {
510505
ret = -EIO;
@@ -518,22 +513,17 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
518513
goto fail_irq_init;
519514
}
520515

521-
if (wilc_wlan_get_firmware(dev)) {
522-
ret = -EIO;
516+
ret = wilc_wlan_get_firmware(dev);
517+
if (ret)
523518
goto fail_irq_enable;
524-
}
525519

526520
ret = wilc1000_firmware_download(dev);
527-
if (ret < 0) {
528-
ret = -EIO;
521+
if (ret)
529522
goto fail_irq_enable;
530-
}
531523

532524
ret = wilc_start_firmware(dev);
533-
if (ret < 0) {
534-
ret = -EIO;
525+
if (ret)
535526
goto fail_irq_enable;
536-
}
537527

538528
if (wilc_wlan_cfg_get(vif, 1, WID_FIRMWARE_VERSION, 1, 0)) {
539529
int size;
@@ -545,11 +535,10 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
545535
firmware_ver[size] = '\0';
546536
netdev_dbg(dev, "Firmware Ver = %s\n", firmware_ver);
547537
}
548-
ret = wilc_init_fw_config(dev, vif);
549538

550-
if (ret < 0) {
539+
ret = wilc_init_fw_config(dev, vif);
540+
if (ret) {
551541
netdev_err(dev, "Failed to configure firmware\n");
552-
ret = -EIO;
553542
goto fail_fw_start;
554543
}
555544
wl->initialized = true;
@@ -600,11 +589,11 @@ static int wilc_mac_open(struct net_device *ndev)
600589
netdev_dbg(ndev, "MAC OPEN[%p]\n", ndev);
601590

602591
ret = wilc_init_host_int(ndev);
603-
if (ret < 0)
592+
if (ret)
604593
return ret;
605594

606595
ret = wilc_wlan_initialize(ndev, vif);
607-
if (ret < 0) {
596+
if (ret) {
608597
wilc_deinit_host_int(ndev);
609598
return ret;
610599
}

0 commit comments

Comments
 (0)