Commit 65c3f000 authored by Chris Park's avatar Chris Park Committed by Greg Kroah-Hartman

staging: wilc1000: Optimize code of wilc_get_chipid function

This patch optimize code of wilc_get_chipid function.
u8 type changed to boolean type and removed unnecessary if statement.
Signed-off-by: default avatarChris Park <chris.park@atmel.com>
Signed-off-by: default avatarLeo Kim <leo.kim@atmel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 20f4e712
...@@ -388,7 +388,7 @@ int wilc_wlan_get_firmware(struct net_device *dev) ...@@ -388,7 +388,7 @@ int wilc_wlan_get_firmware(struct net_device *dev)
vif = netdev_priv(dev); vif = netdev_priv(dev);
wilc = vif->wilc; wilc = vif->wilc;
chip_id = wilc_get_chipid(wilc, 0); chip_id = wilc_get_chipid(wilc, false);
if (chip_id < 0x1003a0) if (chip_id < 0x1003a0)
firmware = FIRMWARE_1002; firmware = FIRMWARE_1002;
...@@ -475,7 +475,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, ...@@ -475,7 +475,7 @@ static int linux_wlan_init_test_config(struct net_device *dev,
wilc_get_mac_address(vif, mac_add); wilc_get_mac_address(vif, mac_add);
netdev_dbg(dev, "MAC address is : %pM\n", mac_add); netdev_dbg(dev, "MAC address is : %pM\n", mac_add);
wilc_get_chipid(wilc, 0); wilc_get_chipid(wilc, false);
*(int *)c_val = 1; *(int *)c_val = 1;
......
...@@ -1441,36 +1441,31 @@ static u32 init_chip(struct net_device *dev) ...@@ -1441,36 +1441,31 @@ static u32 init_chip(struct net_device *dev)
return ret; return ret;
} }
u32 wilc_get_chipid(struct wilc *wilc, u8 update) u32 wilc_get_chipid(struct wilc *wilc, bool update)
{ {
static u32 chipid; static u32 chipid;
u32 tempchipid = 0; u32 tempchipid = 0;
u32 rfrevid; u32 rfrevid = 0;
if (chipid == 0 || update != 0) { if (chipid == 0 || update) {
wilc->hif_func->hif_read_reg(wilc, 0x1000, &tempchipid); wilc->hif_func->hif_read_reg(wilc, 0x1000, &tempchipid);
wilc->hif_func->hif_read_reg(wilc, 0x13f4, &rfrevid); wilc->hif_func->hif_read_reg(wilc, 0x13f4, &rfrevid);
if (!ISWILC1000(tempchipid)) { if (!ISWILC1000(tempchipid)) {
chipid = 0; chipid = 0;
goto _fail_; return chipid;
} }
if (tempchipid == 0x1002a0) { if (tempchipid == 0x1002a0) {
if (rfrevid == 0x1) { if (rfrevid != 0x1)
} else {
tempchipid = 0x1002a1; tempchipid = 0x1002a1;
}
} else if (tempchipid == 0x1002b0) { } else if (tempchipid == 0x1002b0) {
if (rfrevid == 3) { if (rfrevid == 0x4)
} else if (rfrevid == 4) {
tempchipid = 0x1002b1; tempchipid = 0x1002b1;
} else { else if (rfrevid != 0x3)
tempchipid = 0x1002b2; tempchipid = 0x1002b2;
} }
}
chipid = tempchipid; chipid = tempchipid;
} }
_fail_:
return chipid; return chipid;
} }
......
...@@ -921,6 +921,6 @@ struct wilc; ...@@ -921,6 +921,6 @@ struct wilc;
int wilc_wlan_init(struct net_device *dev); int wilc_wlan_init(struct net_device *dev);
void wilc_bus_set_max_speed(void); void wilc_bus_set_max_speed(void);
void wilc_bus_set_default_speed(void); void wilc_bus_set_default_speed(void);
u32 wilc_get_chipid(struct wilc *wilc, u8 update); u32 wilc_get_chipid(struct wilc *wilc, bool update);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment