aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorGrant Grundler <grundler@chromium.org>2011-10-04 05:55:18 -0400
committerDavid S. Miller <davem@davemloft.net>2011-10-04 16:25:31 -0400
commit83e1b91845403f6322284a6e74581cc47d57de9f (patch)
tree3c5fe7a0347ea71c41689076a6e5ba71e8bc30c4 /drivers/net/usb
parent610d885d3176bd807b582401e8990898ae25bed2 (diff)
NET: white space/coding style cleanup of asix driver
check patch was complaining...mostly replaced: if ((ret = asix_foo(xx)) < 0) ... with ret = asix_foo(xx); if (ret < 0) ... Signed-off-by: Grant Grundler <grundler@chromium.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/asix.c153
1 files changed, 82 insertions, 71 deletions
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 8d48affb65fd..1c85c477e174 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -37,7 +37,7 @@
37#include <linux/slab.h> 37#include <linux/slab.h>
38 38
39#define DRIVER_VERSION "26-Sep-2011" 39#define DRIVER_VERSION "26-Sep-2011"
40static const char driver_name [] = "asix"; 40#define DRIVER_NAME "asix"
41 41
42/* ASIX AX8817X based USB 2.0 Ethernet Devices */ 42/* ASIX AX8817X based USB 2.0 Ethernet Devices */
43 43
@@ -115,28 +115,27 @@ static const char driver_name [] = "asix";
115#define AX88178_MEDIUM_DEFAULT \ 115#define AX88178_MEDIUM_DEFAULT \
116 (AX_MEDIUM_PS | AX_MEDIUM_FD | AX_MEDIUM_AC | \ 116 (AX_MEDIUM_PS | AX_MEDIUM_FD | AX_MEDIUM_AC | \
117 AX_MEDIUM_RFC | AX_MEDIUM_TFC | AX_MEDIUM_JFE | \ 117 AX_MEDIUM_RFC | AX_MEDIUM_TFC | AX_MEDIUM_JFE | \
118 AX_MEDIUM_RE ) 118 AX_MEDIUM_RE)
119 119
120#define AX88772_MEDIUM_DEFAULT \ 120#define AX88772_MEDIUM_DEFAULT \
121 (AX_MEDIUM_FD | AX_MEDIUM_RFC | \ 121 (AX_MEDIUM_FD | AX_MEDIUM_RFC | \
122 AX_MEDIUM_TFC | AX_MEDIUM_PS | \ 122 AX_MEDIUM_TFC | AX_MEDIUM_PS | \
123 AX_MEDIUM_AC | AX_MEDIUM_RE ) 123 AX_MEDIUM_AC | AX_MEDIUM_RE)
124 124
125/* AX88772 & AX88178 RX_CTL values */ 125/* AX88772 & AX88178 RX_CTL values */
126#define AX_RX_CTL_SO 0x0080 126#define AX_RX_CTL_SO 0x0080
127#define AX_RX_CTL_AP 0x0020 127#define AX_RX_CTL_AP 0x0020
128#define AX_RX_CTL_AM 0x0010 128#define AX_RX_CTL_AM 0x0010
129#define AX_RX_CTL_AB 0x0008 129#define AX_RX_CTL_AB 0x0008
130#define AX_RX_CTL_SEP 0x0004 130#define AX_RX_CTL_SEP 0x0004
131#define AX_RX_CTL_AMALL 0x0002 131#define AX_RX_CTL_AMALL 0x0002
132#define AX_RX_CTL_PRO 0x0001 132#define AX_RX_CTL_PRO 0x0001
133#define AX_RX_CTL_MFB_2048 0x0000 133#define AX_RX_CTL_MFB_2048 0x0000
134#define AX_RX_CTL_MFB_4096 0x0100 134#define AX_RX_CTL_MFB_4096 0x0100
135#define AX_RX_CTL_MFB_8192 0x0200 135#define AX_RX_CTL_MFB_8192 0x0200
136#define AX_RX_CTL_MFB_16384 0x0300 136#define AX_RX_CTL_MFB_16384 0x0300
137 137
138#define AX_DEFAULT_RX_CTL \ 138#define AX_DEFAULT_RX_CTL (AX_RX_CTL_SO | AX_RX_CTL_AB)
139 (AX_RX_CTL_SO | AX_RX_CTL_AB )
140 139
141/* GPIO 0 .. 2 toggles */ 140/* GPIO 0 .. 2 toggles */
142#define AX_GPIO_GPO0EN 0x01 /* GPIO0 Output enable */ 141#define AX_GPIO_GPO0EN 0x01 /* GPIO0 Output enable */
@@ -270,12 +269,15 @@ asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
270 269
271 netdev_dbg(dev->net, "asix_write_cmd_async() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n", 270 netdev_dbg(dev->net, "asix_write_cmd_async() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
272 cmd, value, index, size); 271 cmd, value, index, size);
273 if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) { 272
273 urb = usb_alloc_urb(0, GFP_ATOMIC);
274 if (!urb) {
274 netdev_err(dev->net, "Error allocating URB in write_cmd_async!\n"); 275 netdev_err(dev->net, "Error allocating URB in write_cmd_async!\n");
275 return; 276 return;
276 } 277 }
277 278
278 if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) { 279 req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
280 if (!req) {
279 netdev_err(dev->net, "Failed to allocate memory for control request\n"); 281 netdev_err(dev->net, "Failed to allocate memory for control request\n");
280 usb_free_urb(urb); 282 usb_free_urb(urb);
281 return; 283 return;
@@ -292,7 +294,8 @@ asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
292 (void *)req, data, size, 294 (void *)req, data, size,
293 asix_async_cmd_callback, req); 295 asix_async_cmd_callback, req);
294 296
295 if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { 297 status = usb_submit_urb(urb, GFP_ATOMIC);
298 if (status < 0) {
296 netdev_err(dev->net, "Error submitting the control message: status=%d\n", 299 netdev_err(dev->net, "Error submitting the control message: status=%d\n",
297 status); 300 status);
298 kfree(req); 301 kfree(req);
@@ -533,11 +536,11 @@ static u16 asix_read_medium_status(struct usbnet *dev)
533 if (ret < 0) { 536 if (ret < 0) {
534 netdev_err(dev->net, "Error reading Medium Status register: %02x\n", 537 netdev_err(dev->net, "Error reading Medium Status register: %02x\n",
535 ret); 538 ret);
536 goto out; 539 return ret; /* TODO: callers not checking for error ret */
537 } 540 }
538 ret = le16_to_cpu(v); 541
539out: 542 return le16_to_cpu(v);
540 return ret; 543
541} 544}
542 545
543static int asix_write_medium_mode(struct usbnet *dev, u16 mode) 546static int asix_write_medium_mode(struct usbnet *dev, u16 mode)
@@ -738,7 +741,7 @@ static void asix_get_drvinfo (struct net_device *net,
738 741
739 /* Inherit standard device info */ 742 /* Inherit standard device info */
740 usbnet_get_drvinfo(net, info); 743 usbnet_get_drvinfo(net, info);
741 strncpy (info->driver, driver_name, sizeof info->driver); 744 strncpy (info->driver, DRIVER_NAME, sizeof info->driver);
742 strncpy (info->version, DRIVER_VERSION, sizeof info->version); 745 strncpy (info->version, DRIVER_VERSION, sizeof info->version);
743 info->eedump_len = data->eeprom_len; 746 info->eedump_len = data->eeprom_len;
744} 747}
@@ -883,19 +886,20 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
883 886
884 /* Toggle the GPIOs in a manufacturer/model specific way */ 887 /* Toggle the GPIOs in a manufacturer/model specific way */
885 for (i = 2; i >= 0; i--) { 888 for (i = 2; i >= 0; i--) {
886 if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, 889 ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS,
887 (gpio_bits >> (i * 8)) & 0xff, 0, 0, 890 (gpio_bits >> (i * 8)) & 0xff, 0, 0, NULL);
888 NULL)) < 0) 891 if (ret < 0)
889 goto out; 892 goto out;
890 msleep(5); 893 msleep(5);
891 } 894 }
892 895
893 if ((ret = asix_write_rx_ctl(dev, 0x80)) < 0) 896 ret = asix_write_rx_ctl(dev, 0x80);
897 if (ret < 0)
894 goto out; 898 goto out;
895 899
896 /* Get the MAC address */ 900 /* Get the MAC address */
897 if ((ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 901 ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
898 0, 0, ETH_ALEN, buf)) < 0) { 902 if (ret < 0) {
899 dbg("read AX_CMD_READ_NODE_ID failed: %d", ret); 903 dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
900 goto out; 904 goto out;
901 } 905 }
@@ -965,51 +969,59 @@ static int ax88772_reset(struct usbnet *dev)
965 int ret, embd_phy; 969 int ret, embd_phy;
966 u16 rx_ctl; 970 u16 rx_ctl;
967 971
968 if ((ret = asix_write_gpio(dev, 972 ret = asix_write_gpio(dev,
969 AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5)) < 0) 973 AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5);
974 if (ret < 0)
970 goto out; 975 goto out;
971 976
972 embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0); 977 embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0);
973 978
974 if ((ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 979 ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL);
975 embd_phy, 0, 0, NULL)) < 0) { 980 if (ret < 0) {
976 dbg("Select PHY #1 failed: %d", ret); 981 dbg("Select PHY #1 failed: %d", ret);
977 goto out; 982 goto out;
978 } 983 }
979 984
980 if ((ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL)) < 0) 985 ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL);
986 if (ret < 0)
981 goto out; 987 goto out;
982 988
983 msleep(150); 989 msleep(150);
984 if ((ret = asix_sw_reset(dev, AX_SWRESET_CLEAR)) < 0) 990
991 ret = asix_sw_reset(dev, AX_SWRESET_CLEAR);
992 if (ret < 0)
985 goto out; 993 goto out;
986 994
987 msleep(150); 995 msleep(150);
988 996
989 if (embd_phy) { 997 if (embd_phy) {
990 if ((ret = asix_sw_reset(dev, AX_SWRESET_IPRL)) < 0) 998 ret = asix_sw_reset(dev, AX_SWRESET_IPRL);
999 if (ret < 0)
991 goto out; 1000 goto out;
992 } 1001 } else {
993 else { 1002 ret = asix_sw_reset(dev, AX_SWRESET_PRTE);
994 if ((ret = asix_sw_reset(dev, AX_SWRESET_PRTE)) < 0) 1003 if (ret < 0)
995 goto out; 1004 goto out;
996 } 1005 }
997 1006
998 msleep(150); 1007 msleep(150);
999 rx_ctl = asix_read_rx_ctl(dev); 1008 rx_ctl = asix_read_rx_ctl(dev);
1000 dbg("RX_CTL is 0x%04x after software reset", rx_ctl); 1009 dbg("RX_CTL is 0x%04x after software reset", rx_ctl);
1001 if ((ret = asix_write_rx_ctl(dev, 0x0000)) < 0) 1010 ret = asix_write_rx_ctl(dev, 0x0000);
1011 if (ret < 0)
1002 goto out; 1012 goto out;
1003 1013
1004 rx_ctl = asix_read_rx_ctl(dev); 1014 rx_ctl = asix_read_rx_ctl(dev);
1005 dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl); 1015 dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl);
1006 1016
1007 if ((ret = asix_sw_reset(dev, AX_SWRESET_PRL)) < 0) 1017 ret = asix_sw_reset(dev, AX_SWRESET_PRL);
1018 if (ret < 0)
1008 goto out; 1019 goto out;
1009 1020
1010 msleep(150); 1021 msleep(150);
1011 1022
1012 if ((ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL)) < 0) 1023 ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL);
1024 if (ret < 0)
1013 goto out; 1025 goto out;
1014 1026
1015 msleep(150); 1027 msleep(150);
@@ -1019,18 +1031,21 @@ static int ax88772_reset(struct usbnet *dev)
1019 ADVERTISE_ALL | ADVERTISE_CSMA); 1031 ADVERTISE_ALL | ADVERTISE_CSMA);
1020 mii_nway_restart(&dev->mii); 1032 mii_nway_restart(&dev->mii);
1021 1033
1022 if ((ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT)) < 0) 1034 ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT);
1035 if (ret < 0)
1023 goto out; 1036 goto out;
1024 1037
1025 if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, 1038 ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0,
1026 AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, 1039 AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
1027 AX88772_IPG2_DEFAULT, 0, NULL)) < 0) { 1040 AX88772_IPG2_DEFAULT, 0, NULL);
1041 if (ret < 0) {
1028 dbg("Write IPG,IPG1,IPG2 failed: %d", ret); 1042 dbg("Write IPG,IPG1,IPG2 failed: %d", ret);
1029 goto out; 1043 goto out;
1030 } 1044 }
1031 1045
1032 /* Set RX_CTL to default values with 2k buffer, and enable cactus */ 1046 /* Set RX_CTL to default values with 2k buffer, and enable cactus */
1033 if ((ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL)) < 0) 1047 ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL);
1048 if (ret < 0)
1034 goto out; 1049 goto out;
1035 1050
1036 rx_ctl = asix_read_rx_ctl(dev); 1051 rx_ctl = asix_read_rx_ctl(dev);
@@ -1070,10 +1085,10 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
1070 usbnet_get_endpoints(dev,intf); 1085 usbnet_get_endpoints(dev,intf);
1071 1086
1072 /* Get the MAC address */ 1087 /* Get the MAC address */
1073 if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 1088 ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
1074 0, 0, ETH_ALEN, buf)) < 0) { 1089 if (ret < 0) {
1075 dbg("Failed to read MAC address: %d", ret); 1090 dbg("Failed to read MAC address: %d", ret);
1076 goto out; 1091 return ret;
1077 } 1092 }
1078 memcpy(dev->net->dev_addr, buf, ETH_ALEN); 1093 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
1079 1094
@@ -1091,8 +1106,9 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
1091 dev->net->netdev_ops = &ax88772_netdev_ops; 1106 dev->net->netdev_ops = &ax88772_netdev_ops;
1092 dev->net->ethtool_ops = &ax88772_ethtool_ops; 1107 dev->net->ethtool_ops = &ax88772_ethtool_ops;
1093 1108
1094 if ((ret = ax88772_reset(dev)) < 0) 1109 ret = ax88772_reset(dev);
1095 goto out; 1110 if (ret < 0)
1111 return ret;
1096 1112
1097 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ 1113 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
1098 if (dev->driver_info->flags & FLAG_FRAMING_AX) { 1114 if (dev->driver_info->flags & FLAG_FRAMING_AX) {
@@ -1100,9 +1116,8 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
1100 jumbo eth frames */ 1116 jumbo eth frames */
1101 dev->rx_urb_size = 2048; 1117 dev->rx_urb_size = 2048;
1102 } 1118 }
1119
1103 return 0; 1120 return 0;
1104out:
1105 return ret;
1106} 1121}
1107 1122
1108static struct ethtool_ops ax88178_ethtool_ops = { 1123static struct ethtool_ops ax88178_ethtool_ops = {
@@ -1260,17 +1275,15 @@ static int ax88178_reset(struct usbnet *dev)
1260 1275
1261 mii_nway_restart(&dev->mii); 1276 mii_nway_restart(&dev->mii);
1262 1277
1263 if ((ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT)) < 0) 1278 ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT);
1264 goto out; 1279 if (ret < 0)
1280 return ret;
1265 1281
1266 if ((ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL)) < 0) 1282 ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL);
1267 goto out; 1283 if (ret < 0)
1284 return ret;
1268 1285
1269 return 0; 1286 return 0;
1270
1271out:
1272 return ret;
1273
1274} 1287}
1275 1288
1276static int ax88178_link_reset(struct usbnet *dev) 1289static int ax88178_link_reset(struct usbnet *dev)
@@ -1388,10 +1401,10 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
1388 usbnet_get_endpoints(dev,intf); 1401 usbnet_get_endpoints(dev,intf);
1389 1402
1390 /* Get the MAC address */ 1403 /* Get the MAC address */
1391 if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 1404 ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
1392 0, 0, ETH_ALEN, buf)) < 0) { 1405 if (ret < 0) {
1393 dbg("Failed to read MAC address: %d", ret); 1406 dbg("Failed to read MAC address: %d", ret);
1394 goto out; 1407 return ret;
1395 } 1408 }
1396 memcpy(dev->net->dev_addr, buf, ETH_ALEN); 1409 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
1397 1410
@@ -1412,7 +1425,7 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
1412 1425
1413 ret = ax88178_reset(dev); 1426 ret = ax88178_reset(dev);
1414 if (ret < 0) 1427 if (ret < 0)
1415 goto out; 1428 return ret;
1416 1429
1417 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ 1430 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
1418 if (dev->driver_info->flags & FLAG_FRAMING_AX) { 1431 if (dev->driver_info->flags & FLAG_FRAMING_AX) {
@@ -1420,10 +1433,8 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
1420 jumbo eth frames */ 1433 jumbo eth frames */
1421 dev->rx_urb_size = 2048; 1434 dev->rx_urb_size = 2048;
1422 } 1435 }
1423 return 0;
1424 1436
1425out: 1437 return 0;
1426 return ret;
1427} 1438}
1428 1439
1429static const struct driver_info ax8817x_info = { 1440static const struct driver_info ax8817x_info = {
@@ -1611,7 +1622,7 @@ static const struct usb_device_id products [] = {
1611MODULE_DEVICE_TABLE(usb, products); 1622MODULE_DEVICE_TABLE(usb, products);
1612 1623
1613static struct usb_driver asix_driver = { 1624static struct usb_driver asix_driver = {
1614 .name = "asix", 1625 .name = DRIVER_NAME,
1615 .id_table = products, 1626 .id_table = products,
1616 .probe = usbnet_probe, 1627 .probe = usbnet_probe,
1617 .suspend = usbnet_suspend, 1628 .suspend = usbnet_suspend,