Skip to content

Commit

Permalink
USB: remove dbg() usage in USB networking drivers
Browse files Browse the repository at this point in the history
The dbg() USB macro is so old, it predates me.  The USB networking drivers are
the last hold-out using this macro, and we want to get rid of it, so replace
the usage of it with the proper netdev_dbg() or dev_dbg() (depending on the
context) calls.

Some places we end up using a local variable for the debug call, so also
convert the other existing dev_* calls to use it as well, to save tiny amounts
of code space.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Greg Kroah-Hartman authored and David S. Miller committed Sep 20, 2012
1 parent 4308fc5 commit 49ae25b
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 137 deletions.
36 changes: 20 additions & 16 deletions drivers/net/usb/asix_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
/* Get the MAC address */
ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
if (ret < 0) {
dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
netdev_dbg(dev->net, "read AX_CMD_READ_NODE_ID failed: %d\n",
ret);
goto out;
}
memcpy(dev->net->dev_addr, buf, ETH_ALEN);
Expand Down Expand Up @@ -303,7 +304,7 @@ static int ax88772_reset(struct usbnet *dev)

ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL);
if (ret < 0) {
dbg("Select PHY #1 failed: %d", ret);
netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret);
goto out;
}

Expand Down Expand Up @@ -331,13 +332,13 @@ static int ax88772_reset(struct usbnet *dev)

msleep(150);
rx_ctl = asix_read_rx_ctl(dev);
dbg("RX_CTL is 0x%04x after software reset", rx_ctl);
netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl);
ret = asix_write_rx_ctl(dev, 0x0000);
if (ret < 0)
goto out;

rx_ctl = asix_read_rx_ctl(dev);
dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl);
netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl);

ret = asix_sw_reset(dev, AX_SWRESET_PRL);
if (ret < 0)
Expand All @@ -364,7 +365,7 @@ static int ax88772_reset(struct usbnet *dev)
AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
AX88772_IPG2_DEFAULT, 0, NULL);
if (ret < 0) {
dbg("Write IPG,IPG1,IPG2 failed: %d", ret);
netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret);
goto out;
}

Expand All @@ -381,10 +382,13 @@ static int ax88772_reset(struct usbnet *dev)
goto out;

rx_ctl = asix_read_rx_ctl(dev);
dbg("RX_CTL is 0x%04x after all initializations", rx_ctl);
netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n",
rx_ctl);

rx_ctl = asix_read_medium_status(dev);
dbg("Medium Status is 0x%04x after all initializations", rx_ctl);
netdev_dbg(dev->net,
"Medium Status is 0x%04x after all initializations\n",
rx_ctl);

return 0;

Expand Down Expand Up @@ -416,7 +420,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
/* Get the MAC address */
ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
if (ret < 0) {
dbg("Failed to read MAC address: %d", ret);
netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
return ret;
}
memcpy(dev->net->dev_addr, buf, ETH_ALEN);
Expand All @@ -439,7 +443,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
/* Reset the PHY to normal operation mode */
ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL);
if (ret < 0) {
dbg("Select PHY #1 failed: %d", ret);
netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret);
return ret;
}

Expand All @@ -459,7 +463,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)

/* Read PHYID register *AFTER* the PHY was reset properly */
phyid = asix_get_phyid(dev);
dbg("PHYID=0x%08x", phyid);
netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid);

/* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
if (dev->driver_info->flags & FLAG_FRAMING_AX) {
Expand Down Expand Up @@ -575,13 +579,13 @@ static int ax88178_reset(struct usbnet *dev)
u32 phyid;

asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &status);
dbg("GPIO Status: 0x%04x", status);
netdev_dbg(dev->net, "GPIO Status: 0x%04x\n", status);

asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL);
asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom);
asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL);

dbg("EEPROM index 0x17 is 0x%04x", eeprom);
netdev_dbg(dev->net, "EEPROM index 0x17 is 0x%04x\n", eeprom);

if (eeprom == cpu_to_le16(0xffff)) {
data->phymode = PHY_MODE_MARVELL;
Expand All @@ -592,7 +596,7 @@ static int ax88178_reset(struct usbnet *dev)
data->ledmode = le16_to_cpu(eeprom) >> 8;
gpio0 = (le16_to_cpu(eeprom) & 0x80) ? 0 : 1;
}
dbg("GPIO0: %d, PhyMode: %d", gpio0, data->phymode);
netdev_dbg(dev->net, "GPIO0: %d, PhyMode: %d\n", gpio0, data->phymode);

/* Power up external GigaPHY through AX88178 GPIO pin */
asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40);
Expand All @@ -601,14 +605,14 @@ static int ax88178_reset(struct usbnet *dev)
asix_write_gpio(dev, 0x001c, 300);
asix_write_gpio(dev, 0x003c, 30);
} else {
dbg("gpio phymode == 1 path");
netdev_dbg(dev->net, "gpio phymode == 1 path\n");
asix_write_gpio(dev, AX_GPIO_GPO1EN, 30);
asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30);
}

/* Read PHYID register *AFTER* powering up PHY */
phyid = asix_get_phyid(dev);
dbg("PHYID=0x%08x", phyid);
netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid);

/* Set AX88178 to enable MII/GMII/RGMII interface for external PHY */
asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL);
Expand Down Expand Up @@ -770,7 +774,7 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
/* Get the MAC address */
ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
if (ret < 0) {
dbg("Failed to read MAC address: %d", ret);
netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
return ret;
}
memcpy(dev->net->dev_addr, buf, ETH_ALEN);
Expand Down
55 changes: 32 additions & 23 deletions drivers/net/usb/catc.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ static void catc_rx_done(struct urb *urb)
}

if (status) {
dbg("rx_done, status %d, length %d", status, urb->actual_length);
dev_dbg(&urb->dev->dev, "rx_done, status %d, length %d\n",
status, urb->actual_length);
return;
}

Expand Down Expand Up @@ -275,10 +276,11 @@ static void catc_rx_done(struct urb *urb)
if (atomic_read(&catc->recq_sz)) {
int state;
atomic_dec(&catc->recq_sz);
dbg("getting extra packet");
netdev_dbg(catc->netdev, "getting extra packet\n");
urb->dev = catc->usbdev;
if ((state = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
dbg("submit(rx_urb) status %d", state);
netdev_dbg(catc->netdev,
"submit(rx_urb) status %d\n", state);
}
} else {
clear_bit(RX_RUNNING, &catc->flags);
Expand Down Expand Up @@ -317,18 +319,20 @@ static void catc_irq_done(struct urb *urb)
return;
/* -EPIPE: should clear the halt */
default: /* error */
dbg("irq_done, status %d, data %02x %02x.", status, data[0], data[1]);
dev_dbg(&urb->dev->dev,
"irq_done, status %d, data %02x %02x.\n",
status, data[0], data[1]);
goto resubmit;
}

if (linksts == LinkGood) {
netif_carrier_on(catc->netdev);
dbg("link ok");
netdev_dbg(catc->netdev, "link ok\n");
}

if (linksts == LinkBad) {
netif_carrier_off(catc->netdev);
dbg("link bad");
netdev_dbg(catc->netdev, "link bad\n");
}

if (hasdata) {
Expand Down Expand Up @@ -385,7 +389,7 @@ static void catc_tx_done(struct urb *urb)
int r, status = urb->status;

if (status == -ECONNRESET) {
dbg("Tx Reset.");
dev_dbg(&urb->dev->dev, "Tx Reset.\n");
urb->status = 0;
catc->netdev->trans_start = jiffies;
catc->netdev->stats.tx_errors++;
Expand All @@ -395,7 +399,8 @@ static void catc_tx_done(struct urb *urb)
}

if (status) {
dbg("tx_done, status %d, length %d", status, urb->actual_length);
dev_dbg(&urb->dev->dev, "tx_done, status %d, length %d\n",
status, urb->actual_length);
return;
}

Expand Down Expand Up @@ -511,7 +516,8 @@ static void catc_ctrl_done(struct urb *urb)
int status = urb->status;

if (status)
dbg("ctrl_done, status %d, len %d.", status, urb->actual_length);
dev_dbg(&urb->dev->dev, "ctrl_done, status %d, len %d.\n",
status, urb->actual_length);

spin_lock_irqsave(&catc->ctrl_lock, flags);

Expand Down Expand Up @@ -667,7 +673,9 @@ static void catc_set_multicast_list(struct net_device *netdev)
f5u011_mchash_async(catc, catc->multicast);
if (catc->rxmode[0] != rx) {
catc->rxmode[0] = rx;
dbg("Setting RX mode to %2.2X %2.2X", catc->rxmode[0], catc->rxmode[1]);
netdev_dbg(catc->netdev,
"Setting RX mode to %2.2X %2.2X\n",
catc->rxmode[0], catc->rxmode[1]);
f5u011_rxmode_async(catc, catc->rxmode);
}
}
Expand Down Expand Up @@ -766,6 +774,7 @@ static const struct net_device_ops catc_netdev_ops = {

static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct device *dev = &intf->dev;
struct usb_device *usbdev = interface_to_usbdev(intf);
struct net_device *netdev;
struct catc *catc;
Expand All @@ -774,7 +783,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id

if (usb_set_interface(usbdev,
intf->altsetting->desc.bInterfaceNumber, 1)) {
dev_err(&intf->dev, "Can't set altsetting 1.\n");
dev_err(dev, "Can't set altsetting 1.\n");
return -EIO;
}

Expand Down Expand Up @@ -817,7 +826,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
if (le16_to_cpu(usbdev->descriptor.idVendor) == 0x0423 &&
le16_to_cpu(usbdev->descriptor.idProduct) == 0xa &&
le16_to_cpu(catc->usbdev->descriptor.bcdDevice) == 0x0130) {
dbg("Testing for f5u011");
dev_dbg(dev, "Testing for f5u011\n");
catc->is_f5u011 = 1;
atomic_set(&catc->recq_sz, 0);
pktsz = RX_PKT_SZ;
Expand All @@ -838,7 +847,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
catc->irq_buf, 2, catc_irq_done, catc, 1);

if (!catc->is_f5u011) {
dbg("Checking memory size\n");
dev_dbg(dev, "Checking memory size\n");

i = 0x12345678;
catc_write_mem(catc, 0x7a80, &i, 4);
Expand All @@ -850,57 +859,57 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
case 0x12345678:
catc_set_reg(catc, TxBufCount, 8);
catc_set_reg(catc, RxBufCount, 32);
dbg("64k Memory\n");
dev_dbg(dev, "64k Memory\n");
break;
default:
dev_warn(&intf->dev,
"Couldn't detect memory size, assuming 32k\n");
case 0x87654321:
catc_set_reg(catc, TxBufCount, 4);
catc_set_reg(catc, RxBufCount, 16);
dbg("32k Memory\n");
dev_dbg(dev, "32k Memory\n");
break;
}

dbg("Getting MAC from SEEROM.");
dev_dbg(dev, "Getting MAC from SEEROM.\n");

catc_get_mac(catc, netdev->dev_addr);

dbg("Setting MAC into registers.");
dev_dbg(dev, "Setting MAC into registers.\n");

for (i = 0; i < 6; i++)
catc_set_reg(catc, StationAddr0 - i, netdev->dev_addr[i]);

dbg("Filling the multicast list.");
dev_dbg(dev, "Filling the multicast list.\n");

memset(broadcast, 0xff, 6);
catc_multicast(broadcast, catc->multicast);
catc_multicast(netdev->dev_addr, catc->multicast);
catc_write_mem(catc, 0xfa80, catc->multicast, 64);

dbg("Clearing error counters.");
dev_dbg(dev, "Clearing error counters.\n");

for (i = 0; i < 8; i++)
catc_set_reg(catc, EthStats + i, 0);
catc->last_stats = jiffies;

dbg("Enabling.");
dev_dbg(dev, "Enabling.\n");

catc_set_reg(catc, MaxBurst, RX_MAX_BURST);
catc_set_reg(catc, OpModes, OpTxMerge | OpRxMerge | OpLenInclude | Op3MemWaits);
catc_set_reg(catc, LEDCtrl, LEDLink);
catc_set_reg(catc, RxUnit, RxEnable | RxPolarity | RxMultiCast);
} else {
dbg("Performing reset\n");
dev_dbg(dev, "Performing reset\n");
catc_reset(catc);
catc_get_mac(catc, netdev->dev_addr);

dbg("Setting RX Mode");
dev_dbg(dev, "Setting RX Mode\n");
catc->rxmode[0] = RxEnable | RxPolarity | RxMultiCast;
catc->rxmode[1] = 0;
f5u011_rxmode(catc, catc->rxmode);
}
dbg("Init done.");
dev_dbg(dev, "Init done.\n");
printk(KERN_INFO "%s: %s USB Ethernet at usb-%s-%s, %pM.\n",
netdev->name, (catc->is_f5u011) ? "Belkin F5U011" : "CATC EL1210A NetMate",
usbdev->bus->bus_name, usbdev->devpath, netdev->dev_addr);
Expand Down
10 changes: 7 additions & 3 deletions drivers/net/usb/gl620a.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
// get the packet count of the received skb
count = le32_to_cpu(header->packet_count);
if (count > GL_MAX_TRANSMIT_PACKETS) {
dbg("genelink: invalid received packet count %u", count);
netdev_dbg(dev->net,
"genelink: invalid received packet count %u\n",
count);
return 0;
}

Expand All @@ -107,7 +109,8 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)

// this may be a broken packet
if (size > GL_MAX_PACKET_LEN) {
dbg("genelink: invalid rx length %d", size);
netdev_dbg(dev->net, "genelink: invalid rx length %d\n",
size);
return 0;
}

Expand All @@ -133,7 +136,8 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
skb_pull(skb, 4);

if (skb->len > GL_MAX_PACKET_LEN) {
dbg("genelink: invalid rx length %d", skb->len);
netdev_dbg(dev->net, "genelink: invalid rx length %d\n",
skb->len);
return 0;
}
return 1;
Expand Down
Loading

0 comments on commit 49ae25b

Please sign in to comment.