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>
This commit is contained in:
Grant Grundler 2011-10-04 09:55:18 +00:00 committed by David S. Miller
parent 610d885d31
commit 83e1b91845
1 changed files with 81 additions and 70 deletions

View File

@ -37,7 +37,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#define DRIVER_VERSION "26-Sep-2011" #define DRIVER_VERSION "26-Sep-2011"
static const char driver_name [] = "asix"; #define DRIVER_NAME "asix"
/* ASIX AX8817X based USB 2.0 Ethernet Devices */ /* ASIX AX8817X based USB 2.0 Ethernet Devices */
@ -115,12 +115,12 @@ static const char driver_name [] = "asix";
#define AX88178_MEDIUM_DEFAULT \ #define AX88178_MEDIUM_DEFAULT \
(AX_MEDIUM_PS | AX_MEDIUM_FD | AX_MEDIUM_AC | \ (AX_MEDIUM_PS | AX_MEDIUM_FD | AX_MEDIUM_AC | \
AX_MEDIUM_RFC | AX_MEDIUM_TFC | AX_MEDIUM_JFE | \ AX_MEDIUM_RFC | AX_MEDIUM_TFC | AX_MEDIUM_JFE | \
AX_MEDIUM_RE ) AX_MEDIUM_RE)
#define AX88772_MEDIUM_DEFAULT \ #define AX88772_MEDIUM_DEFAULT \
(AX_MEDIUM_FD | AX_MEDIUM_RFC | \ (AX_MEDIUM_FD | AX_MEDIUM_RFC | \
AX_MEDIUM_TFC | AX_MEDIUM_PS | \ AX_MEDIUM_TFC | AX_MEDIUM_PS | \
AX_MEDIUM_AC | AX_MEDIUM_RE ) AX_MEDIUM_AC | AX_MEDIUM_RE)
/* AX88772 & AX88178 RX_CTL values */ /* AX88772 & AX88178 RX_CTL values */
#define AX_RX_CTL_SO 0x0080 #define AX_RX_CTL_SO 0x0080
@ -135,8 +135,7 @@ static const char driver_name [] = "asix";
#define AX_RX_CTL_MFB_8192 0x0200 #define AX_RX_CTL_MFB_8192 0x0200
#define AX_RX_CTL_MFB_16384 0x0300 #define AX_RX_CTL_MFB_16384 0x0300
#define AX_DEFAULT_RX_CTL \ #define AX_DEFAULT_RX_CTL (AX_RX_CTL_SO | AX_RX_CTL_AB)
(AX_RX_CTL_SO | AX_RX_CTL_AB )
/* GPIO 0 .. 2 toggles */ /* GPIO 0 .. 2 toggles */
#define AX_GPIO_GPO0EN 0x01 /* GPIO0 Output enable */ #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,
netdev_dbg(dev->net, "asix_write_cmd_async() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n", netdev_dbg(dev->net, "asix_write_cmd_async() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
cmd, value, index, size); cmd, value, index, size);
if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) {
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) {
netdev_err(dev->net, "Error allocating URB in write_cmd_async!\n"); netdev_err(dev->net, "Error allocating URB in write_cmd_async!\n");
return; return;
} }
if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) { req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
if (!req) {
netdev_err(dev->net, "Failed to allocate memory for control request\n"); netdev_err(dev->net, "Failed to allocate memory for control request\n");
usb_free_urb(urb); usb_free_urb(urb);
return; return;
@ -292,7 +294,8 @@ asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
(void *)req, data, size, (void *)req, data, size,
asix_async_cmd_callback, req); asix_async_cmd_callback, req);
if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { status = usb_submit_urb(urb, GFP_ATOMIC);
if (status < 0) {
netdev_err(dev->net, "Error submitting the control message: status=%d\n", netdev_err(dev->net, "Error submitting the control message: status=%d\n",
status); status);
kfree(req); kfree(req);
@ -533,11 +536,11 @@ static u16 asix_read_medium_status(struct usbnet *dev)
if (ret < 0) { if (ret < 0) {
netdev_err(dev->net, "Error reading Medium Status register: %02x\n", netdev_err(dev->net, "Error reading Medium Status register: %02x\n",
ret); ret);
goto out; return ret; /* TODO: callers not checking for error ret */
} }
ret = le16_to_cpu(v);
out: return le16_to_cpu(v);
return ret;
} }
static int asix_write_medium_mode(struct usbnet *dev, u16 mode) static int asix_write_medium_mode(struct usbnet *dev, u16 mode)
@ -738,7 +741,7 @@ static void asix_get_drvinfo (struct net_device *net,
/* Inherit standard device info */ /* Inherit standard device info */
usbnet_get_drvinfo(net, info); usbnet_get_drvinfo(net, info);
strncpy (info->driver, driver_name, sizeof info->driver); strncpy (info->driver, DRIVER_NAME, sizeof info->driver);
strncpy (info->version, DRIVER_VERSION, sizeof info->version); strncpy (info->version, DRIVER_VERSION, sizeof info->version);
info->eedump_len = data->eeprom_len; info->eedump_len = data->eeprom_len;
} }
@ -883,19 +886,20 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
/* Toggle the GPIOs in a manufacturer/model specific way */ /* Toggle the GPIOs in a manufacturer/model specific way */
for (i = 2; i >= 0; i--) { for (i = 2; i >= 0; i--) {
if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS,
(gpio_bits >> (i * 8)) & 0xff, 0, 0, (gpio_bits >> (i * 8)) & 0xff, 0, 0, NULL);
NULL)) < 0) if (ret < 0)
goto out; goto out;
msleep(5); msleep(5);
} }
if ((ret = asix_write_rx_ctl(dev, 0x80)) < 0) ret = asix_write_rx_ctl(dev, 0x80);
if (ret < 0)
goto out; goto out;
/* Get the MAC address */ /* Get the MAC address */
if ((ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
0, 0, ETH_ALEN, buf)) < 0) { if (ret < 0) {
dbg("read AX_CMD_READ_NODE_ID failed: %d", ret); dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
goto out; goto out;
} }
@ -965,51 +969,59 @@ static int ax88772_reset(struct usbnet *dev)
int ret, embd_phy; int ret, embd_phy;
u16 rx_ctl; u16 rx_ctl;
if ((ret = asix_write_gpio(dev, ret = asix_write_gpio(dev,
AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5)) < 0) AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5);
if (ret < 0)
goto out; goto out;
embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0); embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0);
if ((ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL);
embd_phy, 0, 0, NULL)) < 0) { if (ret < 0) {
dbg("Select PHY #1 failed: %d", ret); dbg("Select PHY #1 failed: %d", ret);
goto out; goto out;
} }
if ((ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL)) < 0) ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL);
if (ret < 0)
goto out; goto out;
msleep(150); msleep(150);
if ((ret = asix_sw_reset(dev, AX_SWRESET_CLEAR)) < 0)
ret = asix_sw_reset(dev, AX_SWRESET_CLEAR);
if (ret < 0)
goto out; goto out;
msleep(150); msleep(150);
if (embd_phy) { if (embd_phy) {
if ((ret = asix_sw_reset(dev, AX_SWRESET_IPRL)) < 0) ret = asix_sw_reset(dev, AX_SWRESET_IPRL);
if (ret < 0)
goto out; goto out;
} } else {
else { ret = asix_sw_reset(dev, AX_SWRESET_PRTE);
if ((ret = asix_sw_reset(dev, AX_SWRESET_PRTE)) < 0) if (ret < 0)
goto out; goto out;
} }
msleep(150); msleep(150);
rx_ctl = asix_read_rx_ctl(dev); rx_ctl = asix_read_rx_ctl(dev);
dbg("RX_CTL is 0x%04x after software reset", rx_ctl); dbg("RX_CTL is 0x%04x after software reset", rx_ctl);
if ((ret = asix_write_rx_ctl(dev, 0x0000)) < 0) ret = asix_write_rx_ctl(dev, 0x0000);
if (ret < 0)
goto out; goto out;
rx_ctl = asix_read_rx_ctl(dev); rx_ctl = asix_read_rx_ctl(dev);
dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl); dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl);
if ((ret = asix_sw_reset(dev, AX_SWRESET_PRL)) < 0) ret = asix_sw_reset(dev, AX_SWRESET_PRL);
if (ret < 0)
goto out; goto out;
msleep(150); msleep(150);
if ((ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL)) < 0) ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL);
if (ret < 0)
goto out; goto out;
msleep(150); msleep(150);
@ -1019,18 +1031,21 @@ static int ax88772_reset(struct usbnet *dev)
ADVERTISE_ALL | ADVERTISE_CSMA); ADVERTISE_ALL | ADVERTISE_CSMA);
mii_nway_restart(&dev->mii); mii_nway_restart(&dev->mii);
if ((ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT)) < 0) ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT);
if (ret < 0)
goto out; goto out;
if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0,
AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
AX88772_IPG2_DEFAULT, 0, NULL)) < 0) { AX88772_IPG2_DEFAULT, 0, NULL);
if (ret < 0) {
dbg("Write IPG,IPG1,IPG2 failed: %d", ret); dbg("Write IPG,IPG1,IPG2 failed: %d", ret);
goto out; goto out;
} }
/* Set RX_CTL to default values with 2k buffer, and enable cactus */ /* Set RX_CTL to default values with 2k buffer, and enable cactus */
if ((ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL)) < 0) ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL);
if (ret < 0)
goto out; goto out;
rx_ctl = asix_read_rx_ctl(dev); rx_ctl = asix_read_rx_ctl(dev);
@ -1070,10 +1085,10 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
usbnet_get_endpoints(dev,intf); usbnet_get_endpoints(dev,intf);
/* Get the MAC address */ /* Get the MAC address */
if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
0, 0, ETH_ALEN, buf)) < 0) { if (ret < 0) {
dbg("Failed to read MAC address: %d", ret); dbg("Failed to read MAC address: %d", ret);
goto out; return ret;
} }
memcpy(dev->net->dev_addr, buf, ETH_ALEN); memcpy(dev->net->dev_addr, buf, ETH_ALEN);
@ -1091,8 +1106,9 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
dev->net->netdev_ops = &ax88772_netdev_ops; dev->net->netdev_ops = &ax88772_netdev_ops;
dev->net->ethtool_ops = &ax88772_ethtool_ops; dev->net->ethtool_ops = &ax88772_ethtool_ops;
if ((ret = ax88772_reset(dev)) < 0) ret = ax88772_reset(dev);
goto out; if (ret < 0)
return ret;
/* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
if (dev->driver_info->flags & FLAG_FRAMING_AX) { if (dev->driver_info->flags & FLAG_FRAMING_AX) {
@ -1100,9 +1116,8 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
jumbo eth frames */ jumbo eth frames */
dev->rx_urb_size = 2048; dev->rx_urb_size = 2048;
} }
return 0; return 0;
out:
return ret;
} }
static struct ethtool_ops ax88178_ethtool_ops = { static struct ethtool_ops ax88178_ethtool_ops = {
@ -1260,17 +1275,15 @@ static int ax88178_reset(struct usbnet *dev)
mii_nway_restart(&dev->mii); mii_nway_restart(&dev->mii);
if ((ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT)) < 0) ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT);
goto out; if (ret < 0)
if ((ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL)) < 0)
goto out;
return 0;
out:
return ret; return ret;
ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL);
if (ret < 0)
return ret;
return 0;
} }
static int ax88178_link_reset(struct usbnet *dev) static int ax88178_link_reset(struct usbnet *dev)
@ -1388,10 +1401,10 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
usbnet_get_endpoints(dev,intf); usbnet_get_endpoints(dev,intf);
/* Get the MAC address */ /* Get the MAC address */
if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
0, 0, ETH_ALEN, buf)) < 0) { if (ret < 0) {
dbg("Failed to read MAC address: %d", ret); dbg("Failed to read MAC address: %d", ret);
goto out; return ret;
} }
memcpy(dev->net->dev_addr, buf, ETH_ALEN); memcpy(dev->net->dev_addr, buf, ETH_ALEN);
@ -1412,7 +1425,7 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
ret = ax88178_reset(dev); ret = ax88178_reset(dev);
if (ret < 0) if (ret < 0)
goto out; return ret;
/* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
if (dev->driver_info->flags & FLAG_FRAMING_AX) { if (dev->driver_info->flags & FLAG_FRAMING_AX) {
@ -1420,10 +1433,8 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
jumbo eth frames */ jumbo eth frames */
dev->rx_urb_size = 2048; dev->rx_urb_size = 2048;
} }
return 0;
out: return 0;
return ret;
} }
static const struct driver_info ax8817x_info = { static const struct driver_info ax8817x_info = {
@ -1611,7 +1622,7 @@ static const struct usb_device_id products [] = {
MODULE_DEVICE_TABLE(usb, products); MODULE_DEVICE_TABLE(usb, products);
static struct usb_driver asix_driver = { static struct usb_driver asix_driver = {
.name = "asix", .name = DRIVER_NAME,
.id_table = products, .id_table = products,
.probe = usbnet_probe, .probe = usbnet_probe,
.suspend = usbnet_suspend, .suspend = usbnet_suspend,