aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Glendinning <steve.glendinning@shawell.net>2012-11-29 23:52:44 -0500
committerDavid S. Miller <davem@davemloft.net>2012-11-30 12:27:20 -0500
commite3c678e6d7484dc03fc36d3bfebb8ebb94574110 (patch)
tree3c07932e262fd50033ef600d72fea81cc1594620
parent2305c54ffc389f1e73f2b1122a4c75bb0e8e6601 (diff)
smsc75xx: expand check_ macros
These macros, while reducing the amount of code, hide flow control and make the code more confusing to follow and review. This patch expands them. It should have no functional effect on the driver. Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/usb/smsc75xx.c735
1 files changed, 576 insertions, 159 deletions
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 86d924951d2e..1cbd936bb028 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -64,15 +64,6 @@
64#define SUSPEND_ALLMODES (SUSPEND_SUSPEND0 | SUSPEND_SUSPEND1 | \ 64#define SUSPEND_ALLMODES (SUSPEND_SUSPEND0 | SUSPEND_SUSPEND1 | \
65 SUSPEND_SUSPEND2 | SUSPEND_SUSPEND3) 65 SUSPEND_SUSPEND2 | SUSPEND_SUSPEND3)
66 66
67#define check_warn(ret, fmt, args...) \
68 ({ if (ret < 0) netdev_warn(dev->net, fmt, ##args); })
69
70#define check_warn_return(ret, fmt, args...) \
71 ({ if (ret < 0) { netdev_warn(dev->net, fmt, ##args); return ret; } })
72
73#define check_warn_goto_done(ret, fmt, args...) \
74 ({ if (ret < 0) { netdev_warn(dev->net, fmt, ##args); goto done; } })
75
76struct smsc75xx_priv { 67struct smsc75xx_priv {
77 struct usbnet *dev; 68 struct usbnet *dev;
78 u32 rfe_ctl; 69 u32 rfe_ctl;
@@ -182,7 +173,10 @@ static __must_check int __smsc75xx_phy_wait_not_busy(struct usbnet *dev,
182 173
183 do { 174 do {
184 ret = __smsc75xx_read_reg(dev, MII_ACCESS, &val, in_pm); 175 ret = __smsc75xx_read_reg(dev, MII_ACCESS, &val, in_pm);
185 check_warn_return(ret, "Error reading MII_ACCESS\n"); 176 if (ret < 0) {
177 netdev_warn(dev->net, "Error reading MII_ACCESS\n");
178 return ret;
179 }
186 180
187 if (!(val & MII_ACCESS_BUSY)) 181 if (!(val & MII_ACCESS_BUSY))
188 return 0; 182 return 0;
@@ -202,7 +196,10 @@ static int __smsc75xx_mdio_read(struct net_device *netdev, int phy_id, int idx,
202 196
203 /* confirm MII not busy */ 197 /* confirm MII not busy */
204 ret = __smsc75xx_phy_wait_not_busy(dev, in_pm); 198 ret = __smsc75xx_phy_wait_not_busy(dev, in_pm);
205 check_warn_goto_done(ret, "MII is busy in smsc75xx_mdio_read\n"); 199 if (ret < 0) {
200 netdev_warn(dev->net, "MII is busy in smsc75xx_mdio_read\n");
201 goto done;
202 }
206 203
207 /* set the address, index & direction (read from PHY) */ 204 /* set the address, index & direction (read from PHY) */
208 phy_id &= dev->mii.phy_id_mask; 205 phy_id &= dev->mii.phy_id_mask;
@@ -211,13 +208,22 @@ static int __smsc75xx_mdio_read(struct net_device *netdev, int phy_id, int idx,
211 | ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR) 208 | ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR)
212 | MII_ACCESS_READ | MII_ACCESS_BUSY; 209 | MII_ACCESS_READ | MII_ACCESS_BUSY;
213 ret = __smsc75xx_write_reg(dev, MII_ACCESS, addr, in_pm); 210 ret = __smsc75xx_write_reg(dev, MII_ACCESS, addr, in_pm);
214 check_warn_goto_done(ret, "Error writing MII_ACCESS\n"); 211 if (ret < 0) {
212 netdev_warn(dev->net, "Error writing MII_ACCESS\n");
213 goto done;
214 }
215 215
216 ret = __smsc75xx_phy_wait_not_busy(dev, in_pm); 216 ret = __smsc75xx_phy_wait_not_busy(dev, in_pm);
217 check_warn_goto_done(ret, "Timed out reading MII reg %02X\n", idx); 217 if (ret < 0) {
218 netdev_warn(dev->net, "Timed out reading MII reg %02X\n", idx);
219 goto done;
220 }
218 221
219 ret = __smsc75xx_read_reg(dev, MII_DATA, &val, in_pm); 222 ret = __smsc75xx_read_reg(dev, MII_DATA, &val, in_pm);
220 check_warn_goto_done(ret, "Error reading MII_DATA\n"); 223 if (ret < 0) {
224 netdev_warn(dev->net, "Error reading MII_DATA\n");
225 goto done;
226 }
221 227
222 ret = (u16)(val & 0xFFFF); 228 ret = (u16)(val & 0xFFFF);
223 229
@@ -237,11 +243,17 @@ static void __smsc75xx_mdio_write(struct net_device *netdev, int phy_id,
237 243
238 /* confirm MII not busy */ 244 /* confirm MII not busy */
239 ret = __smsc75xx_phy_wait_not_busy(dev, in_pm); 245 ret = __smsc75xx_phy_wait_not_busy(dev, in_pm);
240 check_warn_goto_done(ret, "MII is busy in smsc75xx_mdio_write\n"); 246 if (ret < 0) {
247 netdev_warn(dev->net, "MII is busy in smsc75xx_mdio_write\n");
248 goto done;
249 }
241 250
242 val = regval; 251 val = regval;
243 ret = __smsc75xx_write_reg(dev, MII_DATA, val, in_pm); 252 ret = __smsc75xx_write_reg(dev, MII_DATA, val, in_pm);
244 check_warn_goto_done(ret, "Error writing MII_DATA\n"); 253 if (ret < 0) {
254 netdev_warn(dev->net, "Error writing MII_DATA\n");
255 goto done;
256 }
245 257
246 /* set the address, index & direction (write to PHY) */ 258 /* set the address, index & direction (write to PHY) */
247 phy_id &= dev->mii.phy_id_mask; 259 phy_id &= dev->mii.phy_id_mask;
@@ -250,10 +262,16 @@ static void __smsc75xx_mdio_write(struct net_device *netdev, int phy_id,
250 | ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR) 262 | ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR)
251 | MII_ACCESS_WRITE | MII_ACCESS_BUSY; 263 | MII_ACCESS_WRITE | MII_ACCESS_BUSY;
252 ret = __smsc75xx_write_reg(dev, MII_ACCESS, addr, in_pm); 264 ret = __smsc75xx_write_reg(dev, MII_ACCESS, addr, in_pm);
253 check_warn_goto_done(ret, "Error writing MII_ACCESS\n"); 265 if (ret < 0) {
266 netdev_warn(dev->net, "Error writing MII_ACCESS\n");
267 goto done;
268 }
254 269
255 ret = __smsc75xx_phy_wait_not_busy(dev, in_pm); 270 ret = __smsc75xx_phy_wait_not_busy(dev, in_pm);
256 check_warn_goto_done(ret, "Timed out writing MII reg %02X\n", idx); 271 if (ret < 0) {
272 netdev_warn(dev->net, "Timed out writing MII reg %02X\n", idx);
273 goto done;
274 }
257 275
258done: 276done:
259 mutex_unlock(&dev->phy_mutex); 277 mutex_unlock(&dev->phy_mutex);
@@ -290,7 +308,10 @@ static int smsc75xx_wait_eeprom(struct usbnet *dev)
290 308
291 do { 309 do {
292 ret = smsc75xx_read_reg(dev, E2P_CMD, &val); 310 ret = smsc75xx_read_reg(dev, E2P_CMD, &val);
293 check_warn_return(ret, "Error reading E2P_CMD\n"); 311 if (ret < 0) {
312 netdev_warn(dev->net, "Error reading E2P_CMD\n");
313 return ret;
314 }
294 315
295 if (!(val & E2P_CMD_BUSY) || (val & E2P_CMD_TIMEOUT)) 316 if (!(val & E2P_CMD_BUSY) || (val & E2P_CMD_TIMEOUT))
296 break; 317 break;
@@ -313,7 +334,10 @@ static int smsc75xx_eeprom_confirm_not_busy(struct usbnet *dev)
313 334
314 do { 335 do {
315 ret = smsc75xx_read_reg(dev, E2P_CMD, &val); 336 ret = smsc75xx_read_reg(dev, E2P_CMD, &val);
316 check_warn_return(ret, "Error reading E2P_CMD\n"); 337 if (ret < 0) {
338 netdev_warn(dev->net, "Error reading E2P_CMD\n");
339 return ret;
340 }
317 341
318 if (!(val & E2P_CMD_BUSY)) 342 if (!(val & E2P_CMD_BUSY))
319 return 0; 343 return 0;
@@ -341,14 +365,20 @@ static int smsc75xx_read_eeprom(struct usbnet *dev, u32 offset, u32 length,
341 for (i = 0; i < length; i++) { 365 for (i = 0; i < length; i++) {
342 val = E2P_CMD_BUSY | E2P_CMD_READ | (offset & E2P_CMD_ADDR); 366 val = E2P_CMD_BUSY | E2P_CMD_READ | (offset & E2P_CMD_ADDR);
343 ret = smsc75xx_write_reg(dev, E2P_CMD, val); 367 ret = smsc75xx_write_reg(dev, E2P_CMD, val);
344 check_warn_return(ret, "Error writing E2P_CMD\n"); 368 if (ret < 0) {
369 netdev_warn(dev->net, "Error writing E2P_CMD\n");
370 return ret;
371 }
345 372
346 ret = smsc75xx_wait_eeprom(dev); 373 ret = smsc75xx_wait_eeprom(dev);
347 if (ret < 0) 374 if (ret < 0)
348 return ret; 375 return ret;
349 376
350 ret = smsc75xx_read_reg(dev, E2P_DATA, &val); 377 ret = smsc75xx_read_reg(dev, E2P_DATA, &val);
351 check_warn_return(ret, "Error reading E2P_DATA\n"); 378 if (ret < 0) {
379 netdev_warn(dev->net, "Error reading E2P_DATA\n");
380 return ret;
381 }
352 382
353 data[i] = val & 0xFF; 383 data[i] = val & 0xFF;
354 offset++; 384 offset++;
@@ -373,7 +403,10 @@ static int smsc75xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length,
373 /* Issue write/erase enable command */ 403 /* Issue write/erase enable command */
374 val = E2P_CMD_BUSY | E2P_CMD_EWEN; 404 val = E2P_CMD_BUSY | E2P_CMD_EWEN;
375 ret = smsc75xx_write_reg(dev, E2P_CMD, val); 405 ret = smsc75xx_write_reg(dev, E2P_CMD, val);
376 check_warn_return(ret, "Error writing E2P_CMD\n"); 406 if (ret < 0) {
407 netdev_warn(dev->net, "Error writing E2P_CMD\n");
408 return ret;
409 }
377 410
378 ret = smsc75xx_wait_eeprom(dev); 411 ret = smsc75xx_wait_eeprom(dev);
379 if (ret < 0) 412 if (ret < 0)
@@ -384,12 +417,18 @@ static int smsc75xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length,
384 /* Fill data register */ 417 /* Fill data register */
385 val = data[i]; 418 val = data[i];
386 ret = smsc75xx_write_reg(dev, E2P_DATA, val); 419 ret = smsc75xx_write_reg(dev, E2P_DATA, val);
387 check_warn_return(ret, "Error writing E2P_DATA\n"); 420 if (ret < 0) {
421 netdev_warn(dev->net, "Error writing E2P_DATA\n");
422 return ret;
423 }
388 424
389 /* Send "write" command */ 425 /* Send "write" command */
390 val = E2P_CMD_BUSY | E2P_CMD_WRITE | (offset & E2P_CMD_ADDR); 426 val = E2P_CMD_BUSY | E2P_CMD_WRITE | (offset & E2P_CMD_ADDR);
391 ret = smsc75xx_write_reg(dev, E2P_CMD, val); 427 ret = smsc75xx_write_reg(dev, E2P_CMD, val);
392 check_warn_return(ret, "Error writing E2P_CMD\n"); 428 if (ret < 0) {
429 netdev_warn(dev->net, "Error writing E2P_CMD\n");
430 return ret;
431 }
393 432
394 ret = smsc75xx_wait_eeprom(dev); 433 ret = smsc75xx_wait_eeprom(dev);
395 if (ret < 0) 434 if (ret < 0)
@@ -408,7 +447,10 @@ static int smsc75xx_dataport_wait_not_busy(struct usbnet *dev)
408 for (i = 0; i < 100; i++) { 447 for (i = 0; i < 100; i++) {
409 u32 dp_sel; 448 u32 dp_sel;
410 ret = smsc75xx_read_reg(dev, DP_SEL, &dp_sel); 449 ret = smsc75xx_read_reg(dev, DP_SEL, &dp_sel);
411 check_warn_return(ret, "Error reading DP_SEL\n"); 450 if (ret < 0) {
451 netdev_warn(dev->net, "Error reading DP_SEL\n");
452 return ret;
453 }
412 454
413 if (dp_sel & DP_SEL_DPRDY) 455 if (dp_sel & DP_SEL_DPRDY)
414 return 0; 456 return 0;
@@ -431,28 +473,49 @@ static int smsc75xx_dataport_write(struct usbnet *dev, u32 ram_select, u32 addr,
431 mutex_lock(&pdata->dataport_mutex); 473 mutex_lock(&pdata->dataport_mutex);
432 474
433 ret = smsc75xx_dataport_wait_not_busy(dev); 475 ret = smsc75xx_dataport_wait_not_busy(dev);
434 check_warn_goto_done(ret, "smsc75xx_dataport_write busy on entry\n"); 476 if (ret < 0) {
477 netdev_warn(dev->net, "smsc75xx_dataport_write busy on entry\n");
478 goto done;
479 }
435 480
436 ret = smsc75xx_read_reg(dev, DP_SEL, &dp_sel); 481 ret = smsc75xx_read_reg(dev, DP_SEL, &dp_sel);
437 check_warn_goto_done(ret, "Error reading DP_SEL\n"); 482 if (ret < 0) {
483 netdev_warn(dev->net, "Error reading DP_SEL\n");
484 goto done;
485 }
438 486
439 dp_sel &= ~DP_SEL_RSEL; 487 dp_sel &= ~DP_SEL_RSEL;
440 dp_sel |= ram_select; 488 dp_sel |= ram_select;
441 ret = smsc75xx_write_reg(dev, DP_SEL, dp_sel); 489 ret = smsc75xx_write_reg(dev, DP_SEL, dp_sel);
442 check_warn_goto_done(ret, "Error writing DP_SEL\n"); 490 if (ret < 0) {
491 netdev_warn(dev->net, "Error writing DP_SEL\n");
492 goto done;
493 }
443 494
444 for (i = 0; i < length; i++) { 495 for (i = 0; i < length; i++) {
445 ret = smsc75xx_write_reg(dev, DP_ADDR, addr + i); 496 ret = smsc75xx_write_reg(dev, DP_ADDR, addr + i);
446 check_warn_goto_done(ret, "Error writing DP_ADDR\n"); 497 if (ret < 0) {
498 netdev_warn(dev->net, "Error writing DP_ADDR\n");
499 goto done;
500 }
447 501
448 ret = smsc75xx_write_reg(dev, DP_DATA, buf[i]); 502 ret = smsc75xx_write_reg(dev, DP_DATA, buf[i]);
449 check_warn_goto_done(ret, "Error writing DP_DATA\n"); 503 if (ret < 0) {
504 netdev_warn(dev->net, "Error writing DP_DATA\n");
505 goto done;
506 }
450 507
451 ret = smsc75xx_write_reg(dev, DP_CMD, DP_CMD_WRITE); 508 ret = smsc75xx_write_reg(dev, DP_CMD, DP_CMD_WRITE);
452 check_warn_goto_done(ret, "Error writing DP_CMD\n"); 509 if (ret < 0) {
510 netdev_warn(dev->net, "Error writing DP_CMD\n");
511 goto done;
512 }
453 513
454 ret = smsc75xx_dataport_wait_not_busy(dev); 514 ret = smsc75xx_dataport_wait_not_busy(dev);
455 check_warn_goto_done(ret, "smsc75xx_dataport_write timeout\n"); 515 if (ret < 0) {
516 netdev_warn(dev->net, "smsc75xx_dataport_write timeout\n");
517 goto done;
518 }
456 } 519 }
457 520
458done: 521done:
@@ -480,7 +543,8 @@ static void smsc75xx_deferred_multicast_write(struct work_struct *param)
480 DP_SEL_VHF_HASH_LEN, pdata->multicast_hash_table); 543 DP_SEL_VHF_HASH_LEN, pdata->multicast_hash_table);
481 544
482 ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); 545 ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl);
483 check_warn(ret, "Error writing RFE_CRL\n"); 546 if (ret < 0)
547 netdev_warn(dev->net, "Error writing RFE_CRL\n");
484} 548}
485 549
486static void smsc75xx_set_multicast(struct net_device *netdev) 550static void smsc75xx_set_multicast(struct net_device *netdev)
@@ -554,10 +618,16 @@ static int smsc75xx_update_flowcontrol(struct usbnet *dev, u8 duplex,
554 } 618 }
555 619
556 ret = smsc75xx_write_reg(dev, FLOW, flow); 620 ret = smsc75xx_write_reg(dev, FLOW, flow);
557 check_warn_return(ret, "Error writing FLOW\n"); 621 if (ret < 0) {
622 netdev_warn(dev->net, "Error writing FLOW\n");
623 return ret;
624 }
558 625
559 ret = smsc75xx_write_reg(dev, FCT_FLOW, fct_flow); 626 ret = smsc75xx_write_reg(dev, FCT_FLOW, fct_flow);
560 check_warn_return(ret, "Error writing FCT_FLOW\n"); 627 if (ret < 0) {
628 netdev_warn(dev->net, "Error writing FCT_FLOW\n");
629 return ret;
630 }
561 631
562 return 0; 632 return 0;
563} 633}
@@ -574,7 +644,10 @@ static int smsc75xx_link_reset(struct usbnet *dev)
574 PHY_INT_SRC_CLEAR_ALL); 644 PHY_INT_SRC_CLEAR_ALL);
575 645
576 ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL); 646 ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL);
577 check_warn_return(ret, "Error writing INT_STS\n"); 647 if (ret < 0) {
648 netdev_warn(dev->net, "Error writing INT_STS\n");
649 return ret;
650 }
578 651
579 mii_check_media(mii, 1, 1); 652 mii_check_media(mii, 1, 1);
580 mii_ethtool_gset(&dev->mii, &ecmd); 653 mii_ethtool_gset(&dev->mii, &ecmd);
@@ -658,9 +731,10 @@ static int smsc75xx_ethtool_set_wol(struct net_device *net,
658 pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE; 731 pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
659 732
660 ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts); 733 ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts);
661 check_warn_return(ret, "device_set_wakeup_enable error %d\n", ret); 734 if (ret < 0)
735 netdev_warn(dev->net, "device_set_wakeup_enable error %d\n", ret);
662 736
663 return 0; 737 return ret;
664} 738}
665 739
666static const struct ethtool_ops smsc75xx_ethtool_ops = { 740static const struct ethtool_ops smsc75xx_ethtool_ops = {
@@ -713,19 +787,29 @@ static int smsc75xx_set_mac_address(struct usbnet *dev)
713 u32 addr_hi = dev->net->dev_addr[4] | dev->net->dev_addr[5] << 8; 787 u32 addr_hi = dev->net->dev_addr[4] | dev->net->dev_addr[5] << 8;
714 788
715 int ret = smsc75xx_write_reg(dev, RX_ADDRH, addr_hi); 789 int ret = smsc75xx_write_reg(dev, RX_ADDRH, addr_hi);
716 check_warn_return(ret, "Failed to write RX_ADDRH: %d\n", ret); 790 if (ret < 0) {
791 netdev_warn(dev->net, "Failed to write RX_ADDRH: %d\n", ret);
792 return ret;
793 }
717 794
718 ret = smsc75xx_write_reg(dev, RX_ADDRL, addr_lo); 795 ret = smsc75xx_write_reg(dev, RX_ADDRL, addr_lo);
719 check_warn_return(ret, "Failed to write RX_ADDRL: %d\n", ret); 796 if (ret < 0) {
797 netdev_warn(dev->net, "Failed to write RX_ADDRL: %d\n", ret);
798 return ret;
799 }
720 800
721 addr_hi |= ADDR_FILTX_FB_VALID; 801 addr_hi |= ADDR_FILTX_FB_VALID;
722 ret = smsc75xx_write_reg(dev, ADDR_FILTX, addr_hi); 802 ret = smsc75xx_write_reg(dev, ADDR_FILTX, addr_hi);
723 check_warn_return(ret, "Failed to write ADDR_FILTX: %d\n", ret); 803 if (ret < 0) {
804 netdev_warn(dev->net, "Failed to write ADDR_FILTX: %d\n", ret);
805 return ret;
806 }
724 807
725 ret = smsc75xx_write_reg(dev, ADDR_FILTX + 4, addr_lo); 808 ret = smsc75xx_write_reg(dev, ADDR_FILTX + 4, addr_lo);
726 check_warn_return(ret, "Failed to write ADDR_FILTX+4: %d\n", ret); 809 if (ret < 0)
810 netdev_warn(dev->net, "Failed to write ADDR_FILTX+4: %d\n", ret);
727 811
728 return 0; 812 return ret;
729} 813}
730 814
731static int smsc75xx_phy_initialize(struct usbnet *dev) 815static int smsc75xx_phy_initialize(struct usbnet *dev)
@@ -747,7 +831,10 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
747 do { 831 do {
748 msleep(10); 832 msleep(10);
749 bmcr = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); 833 bmcr = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR);
750 check_warn_return(bmcr, "Error reading MII_BMCR\n"); 834 if (bmcr < 0) {
835 netdev_warn(dev->net, "Error reading MII_BMCR\n");
836 return bmcr;
837 }
751 timeout++; 838 timeout++;
752 } while ((bmcr & BMCR_RESET) && (timeout < 100)); 839 } while ((bmcr & BMCR_RESET) && (timeout < 100));
753 840
@@ -764,7 +851,11 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
764 851
765 /* read and write to clear phy interrupt status */ 852 /* read and write to clear phy interrupt status */
766 ret = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC); 853 ret = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC);
767 check_warn_return(ret, "Error reading PHY_INT_SRC\n"); 854 if (ret < 0) {
855 netdev_warn(dev->net, "Error reading PHY_INT_SRC\n");
856 return ret;
857 }
858
768 smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_SRC, 0xffff); 859 smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_SRC, 0xffff);
769 860
770 smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK, 861 smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK,
@@ -782,14 +873,20 @@ static int smsc75xx_set_rx_max_frame_length(struct usbnet *dev, int size)
782 bool rxenabled; 873 bool rxenabled;
783 874
784 ret = smsc75xx_read_reg(dev, MAC_RX, &buf); 875 ret = smsc75xx_read_reg(dev, MAC_RX, &buf);
785 check_warn_return(ret, "Failed to read MAC_RX: %d\n", ret); 876 if (ret < 0) {
877 netdev_warn(dev->net, "Failed to read MAC_RX: %d\n", ret);
878 return ret;
879 }
786 880
787 rxenabled = ((buf & MAC_RX_RXEN) != 0); 881 rxenabled = ((buf & MAC_RX_RXEN) != 0);
788 882
789 if (rxenabled) { 883 if (rxenabled) {
790 buf &= ~MAC_RX_RXEN; 884 buf &= ~MAC_RX_RXEN;
791 ret = smsc75xx_write_reg(dev, MAC_RX, buf); 885 ret = smsc75xx_write_reg(dev, MAC_RX, buf);
792 check_warn_return(ret, "Failed to write MAC_RX: %d\n", ret); 886 if (ret < 0) {
887 netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret);
888 return ret;
889 }
793 } 890 }
794 891
795 /* add 4 to size for FCS */ 892 /* add 4 to size for FCS */
@@ -797,12 +894,18 @@ static int smsc75xx_set_rx_max_frame_length(struct usbnet *dev, int size)
797 buf |= (((size + 4) << MAC_RX_MAX_SIZE_SHIFT) & MAC_RX_MAX_SIZE); 894 buf |= (((size + 4) << MAC_RX_MAX_SIZE_SHIFT) & MAC_RX_MAX_SIZE);
798 895
799 ret = smsc75xx_write_reg(dev, MAC_RX, buf); 896 ret = smsc75xx_write_reg(dev, MAC_RX, buf);
800 check_warn_return(ret, "Failed to write MAC_RX: %d\n", ret); 897 if (ret < 0) {
898 netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret);
899 return ret;
900 }
801 901
802 if (rxenabled) { 902 if (rxenabled) {
803 buf |= MAC_RX_RXEN; 903 buf |= MAC_RX_RXEN;
804 ret = smsc75xx_write_reg(dev, MAC_RX, buf); 904 ret = smsc75xx_write_reg(dev, MAC_RX, buf);
805 check_warn_return(ret, "Failed to write MAC_RX: %d\n", ret); 905 if (ret < 0) {
906 netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret);
907 return ret;
908 }
806 } 909 }
807 910
808 return 0; 911 return 0;
@@ -813,7 +916,10 @@ static int smsc75xx_change_mtu(struct net_device *netdev, int new_mtu)
813 struct usbnet *dev = netdev_priv(netdev); 916 struct usbnet *dev = netdev_priv(netdev);
814 917
815 int ret = smsc75xx_set_rx_max_frame_length(dev, new_mtu); 918 int ret = smsc75xx_set_rx_max_frame_length(dev, new_mtu);
816 check_warn_return(ret, "Failed to set mac rx frame length\n"); 919 if (ret < 0) {
920 netdev_warn(dev->net, "Failed to set mac rx frame length\n");
921 return ret;
922 }
817 923
818 return usbnet_change_mtu(netdev, new_mtu); 924 return usbnet_change_mtu(netdev, new_mtu);
819} 925}
@@ -838,9 +944,10 @@ static int smsc75xx_set_features(struct net_device *netdev,
838 /* it's racing here! */ 944 /* it's racing here! */
839 945
840 ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); 946 ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl);
841 check_warn_return(ret, "Error writing RFE_CTL\n"); 947 if (ret < 0)
948 netdev_warn(dev->net, "Error writing RFE_CTL\n");
842 949
843 return 0; 950 return ret;
844} 951}
845 952
846static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm) 953static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm)
@@ -853,7 +960,10 @@ static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm)
853 960
854 ret = __smsc75xx_read_reg(dev, PMT_CTL, &buf, in_pm); 961 ret = __smsc75xx_read_reg(dev, PMT_CTL, &buf, in_pm);
855 962
856 check_warn_return(ret, "Failed to read PMT_CTL: %d\n", ret); 963 if (ret < 0) {
964 netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret);
965 return ret;
966 }
857 967
858 if (buf & PMT_CTL_DEV_RDY) 968 if (buf & PMT_CTL_DEV_RDY)
859 return 0; 969 return 0;
@@ -875,21 +985,33 @@ static int smsc75xx_reset(struct usbnet *dev)
875 netif_dbg(dev, ifup, dev->net, "entering smsc75xx_reset\n"); 985 netif_dbg(dev, ifup, dev->net, "entering smsc75xx_reset\n");
876 986
877 ret = smsc75xx_wait_ready(dev, 0); 987 ret = smsc75xx_wait_ready(dev, 0);
878 check_warn_return(ret, "device not ready in smsc75xx_reset\n"); 988 if (ret < 0) {
989 netdev_warn(dev->net, "device not ready in smsc75xx_reset\n");
990 return ret;
991 }
879 992
880 ret = smsc75xx_read_reg(dev, HW_CFG, &buf); 993 ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
881 check_warn_return(ret, "Failed to read HW_CFG: %d\n", ret); 994 if (ret < 0) {
995 netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
996 return ret;
997 }
882 998
883 buf |= HW_CFG_LRST; 999 buf |= HW_CFG_LRST;
884 1000
885 ret = smsc75xx_write_reg(dev, HW_CFG, buf); 1001 ret = smsc75xx_write_reg(dev, HW_CFG, buf);
886 check_warn_return(ret, "Failed to write HW_CFG: %d\n", ret); 1002 if (ret < 0) {
1003 netdev_warn(dev->net, "Failed to write HW_CFG: %d\n", ret);
1004 return ret;
1005 }
887 1006
888 timeout = 0; 1007 timeout = 0;
889 do { 1008 do {
890 msleep(10); 1009 msleep(10);
891 ret = smsc75xx_read_reg(dev, HW_CFG, &buf); 1010 ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
892 check_warn_return(ret, "Failed to read HW_CFG: %d\n", ret); 1011 if (ret < 0) {
1012 netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
1013 return ret;
1014 }
893 timeout++; 1015 timeout++;
894 } while ((buf & HW_CFG_LRST) && (timeout < 100)); 1016 } while ((buf & HW_CFG_LRST) && (timeout < 100));
895 1017
@@ -901,18 +1023,27 @@ static int smsc75xx_reset(struct usbnet *dev)
901 netif_dbg(dev, ifup, dev->net, "Lite reset complete, resetting PHY\n"); 1023 netif_dbg(dev, ifup, dev->net, "Lite reset complete, resetting PHY\n");
902 1024
903 ret = smsc75xx_read_reg(dev, PMT_CTL, &buf); 1025 ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
904 check_warn_return(ret, "Failed to read PMT_CTL: %d\n", ret); 1026 if (ret < 0) {
1027 netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret);
1028 return ret;
1029 }
905 1030
906 buf |= PMT_CTL_PHY_RST; 1031 buf |= PMT_CTL_PHY_RST;
907 1032
908 ret = smsc75xx_write_reg(dev, PMT_CTL, buf); 1033 ret = smsc75xx_write_reg(dev, PMT_CTL, buf);
909 check_warn_return(ret, "Failed to write PMT_CTL: %d\n", ret); 1034 if (ret < 0) {
1035 netdev_warn(dev->net, "Failed to write PMT_CTL: %d\n", ret);
1036 return ret;
1037 }
910 1038
911 timeout = 0; 1039 timeout = 0;
912 do { 1040 do {
913 msleep(10); 1041 msleep(10);
914 ret = smsc75xx_read_reg(dev, PMT_CTL, &buf); 1042 ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
915 check_warn_return(ret, "Failed to read PMT_CTL: %d\n", ret); 1043 if (ret < 0) {
1044 netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret);
1045 return ret;
1046 }
916 timeout++; 1047 timeout++;
917 } while ((buf & PMT_CTL_PHY_RST) && (timeout < 100)); 1048 } while ((buf & PMT_CTL_PHY_RST) && (timeout < 100));
918 1049
@@ -926,13 +1057,19 @@ static int smsc75xx_reset(struct usbnet *dev)
926 smsc75xx_init_mac_address(dev); 1057 smsc75xx_init_mac_address(dev);
927 1058
928 ret = smsc75xx_set_mac_address(dev); 1059 ret = smsc75xx_set_mac_address(dev);
929 check_warn_return(ret, "Failed to set mac address\n"); 1060 if (ret < 0) {
1061 netdev_warn(dev->net, "Failed to set mac address\n");
1062 return ret;
1063 }
930 1064
931 netif_dbg(dev, ifup, dev->net, "MAC Address: %pM\n", 1065 netif_dbg(dev, ifup, dev->net, "MAC Address: %pM\n",
932 dev->net->dev_addr); 1066 dev->net->dev_addr);
933 1067
934 ret = smsc75xx_read_reg(dev, HW_CFG, &buf); 1068 ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
935 check_warn_return(ret, "Failed to read HW_CFG: %d\n", ret); 1069 if (ret < 0) {
1070 netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
1071 return ret;
1072 }
936 1073
937 netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG : 0x%08x\n", 1074 netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG : 0x%08x\n",
938 buf); 1075 buf);
@@ -940,10 +1077,16 @@ static int smsc75xx_reset(struct usbnet *dev)
940 buf |= HW_CFG_BIR; 1077 buf |= HW_CFG_BIR;
941 1078
942 ret = smsc75xx_write_reg(dev, HW_CFG, buf); 1079 ret = smsc75xx_write_reg(dev, HW_CFG, buf);
943 check_warn_return(ret, "Failed to write HW_CFG: %d\n", ret); 1080 if (ret < 0) {
1081 netdev_warn(dev->net, "Failed to write HW_CFG: %d\n", ret);
1082 return ret;
1083 }
944 1084
945 ret = smsc75xx_read_reg(dev, HW_CFG, &buf); 1085 ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
946 check_warn_return(ret, "Failed to read HW_CFG: %d\n", ret); 1086 if (ret < 0) {
1087 netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
1088 return ret;
1089 }
947 1090
948 netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG after writing HW_CFG_BIR: 0x%08x\n", 1091 netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG after writing HW_CFG_BIR: 0x%08x\n",
949 buf); 1092 buf);
@@ -963,36 +1106,57 @@ static int smsc75xx_reset(struct usbnet *dev)
963 (ulong)dev->rx_urb_size); 1106 (ulong)dev->rx_urb_size);
964 1107
965 ret = smsc75xx_write_reg(dev, BURST_CAP, buf); 1108 ret = smsc75xx_write_reg(dev, BURST_CAP, buf);
966 check_warn_return(ret, "Failed to write BURST_CAP: %d\n", ret); 1109 if (ret < 0) {
1110 netdev_warn(dev->net, "Failed to write BURST_CAP: %d\n", ret);
1111 return ret;
1112 }
967 1113
968 ret = smsc75xx_read_reg(dev, BURST_CAP, &buf); 1114 ret = smsc75xx_read_reg(dev, BURST_CAP, &buf);
969 check_warn_return(ret, "Failed to read BURST_CAP: %d\n", ret); 1115 if (ret < 0) {
1116 netdev_warn(dev->net, "Failed to read BURST_CAP: %d\n", ret);
1117 return ret;
1118 }
970 1119
971 netif_dbg(dev, ifup, dev->net, 1120 netif_dbg(dev, ifup, dev->net,
972 "Read Value from BURST_CAP after writing: 0x%08x\n", buf); 1121 "Read Value from BURST_CAP after writing: 0x%08x\n", buf);
973 1122
974 ret = smsc75xx_write_reg(dev, BULK_IN_DLY, DEFAULT_BULK_IN_DELAY); 1123 ret = smsc75xx_write_reg(dev, BULK_IN_DLY, DEFAULT_BULK_IN_DELAY);
975 check_warn_return(ret, "Failed to write BULK_IN_DLY: %d\n", ret); 1124 if (ret < 0) {
1125 netdev_warn(dev->net, "Failed to write BULK_IN_DLY: %d\n", ret);
1126 return ret;
1127 }
976 1128
977 ret = smsc75xx_read_reg(dev, BULK_IN_DLY, &buf); 1129 ret = smsc75xx_read_reg(dev, BULK_IN_DLY, &buf);
978 check_warn_return(ret, "Failed to read BULK_IN_DLY: %d\n", ret); 1130 if (ret < 0) {
1131 netdev_warn(dev->net, "Failed to read BULK_IN_DLY: %d\n", ret);
1132 return ret;
1133 }
979 1134
980 netif_dbg(dev, ifup, dev->net, 1135 netif_dbg(dev, ifup, dev->net,
981 "Read Value from BULK_IN_DLY after writing: 0x%08x\n", buf); 1136 "Read Value from BULK_IN_DLY after writing: 0x%08x\n", buf);
982 1137
983 if (turbo_mode) { 1138 if (turbo_mode) {
984 ret = smsc75xx_read_reg(dev, HW_CFG, &buf); 1139 ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
985 check_warn_return(ret, "Failed to read HW_CFG: %d\n", ret); 1140 if (ret < 0) {
1141 netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
1142 return ret;
1143 }
986 1144
987 netif_dbg(dev, ifup, dev->net, "HW_CFG: 0x%08x\n", buf); 1145 netif_dbg(dev, ifup, dev->net, "HW_CFG: 0x%08x\n", buf);
988 1146
989 buf |= (HW_CFG_MEF | HW_CFG_BCE); 1147 buf |= (HW_CFG_MEF | HW_CFG_BCE);
990 1148
991 ret = smsc75xx_write_reg(dev, HW_CFG, buf); 1149 ret = smsc75xx_write_reg(dev, HW_CFG, buf);
992 check_warn_return(ret, "Failed to write HW_CFG: %d\n", ret); 1150 if (ret < 0) {
1151 netdev_warn(dev->net, "Failed to write HW_CFG: %d\n", ret);
1152 return ret;
1153 }
993 1154
994 ret = smsc75xx_read_reg(dev, HW_CFG, &buf); 1155 ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
995 check_warn_return(ret, "Failed to read HW_CFG: %d\n", ret); 1156 if (ret < 0) {
1157 netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
1158 return ret;
1159 }
996 1160
997 netif_dbg(dev, ifup, dev->net, "HW_CFG: 0x%08x\n", buf); 1161 netif_dbg(dev, ifup, dev->net, "HW_CFG: 0x%08x\n", buf);
998 } 1162 }
@@ -1000,58 +1164,92 @@ static int smsc75xx_reset(struct usbnet *dev)
1000 /* set FIFO sizes */ 1164 /* set FIFO sizes */
1001 buf = (MAX_RX_FIFO_SIZE - 512) / 512; 1165 buf = (MAX_RX_FIFO_SIZE - 512) / 512;
1002 ret = smsc75xx_write_reg(dev, FCT_RX_FIFO_END, buf); 1166 ret = smsc75xx_write_reg(dev, FCT_RX_FIFO_END, buf);
1003 check_warn_return(ret, "Failed to write FCT_RX_FIFO_END: %d\n", ret); 1167 if (ret < 0) {
1168 netdev_warn(dev->net, "Failed to write FCT_RX_FIFO_END: %d\n", ret);
1169 return ret;
1170 }
1004 1171
1005 netif_dbg(dev, ifup, dev->net, "FCT_RX_FIFO_END set to 0x%08x\n", buf); 1172 netif_dbg(dev, ifup, dev->net, "FCT_RX_FIFO_END set to 0x%08x\n", buf);
1006 1173
1007 buf = (MAX_TX_FIFO_SIZE - 512) / 512; 1174 buf = (MAX_TX_FIFO_SIZE - 512) / 512;
1008 ret = smsc75xx_write_reg(dev, FCT_TX_FIFO_END, buf); 1175 ret = smsc75xx_write_reg(dev, FCT_TX_FIFO_END, buf);
1009 check_warn_return(ret, "Failed to write FCT_TX_FIFO_END: %d\n", ret); 1176 if (ret < 0) {
1177 netdev_warn(dev->net, "Failed to write FCT_TX_FIFO_END: %d\n", ret);
1178 return ret;
1179 }
1010 1180
1011 netif_dbg(dev, ifup, dev->net, "FCT_TX_FIFO_END set to 0x%08x\n", buf); 1181 netif_dbg(dev, ifup, dev->net, "FCT_TX_FIFO_END set to 0x%08x\n", buf);
1012 1182
1013 ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL); 1183 ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL);
1014 check_warn_return(ret, "Failed to write INT_STS: %d\n", ret); 1184 if (ret < 0) {
1185 netdev_warn(dev->net, "Failed to write INT_STS: %d\n", ret);
1186 return ret;
1187 }
1015 1188
1016 ret = smsc75xx_read_reg(dev, ID_REV, &buf); 1189 ret = smsc75xx_read_reg(dev, ID_REV, &buf);
1017 check_warn_return(ret, "Failed to read ID_REV: %d\n", ret); 1190 if (ret < 0) {
1191 netdev_warn(dev->net, "Failed to read ID_REV: %d\n", ret);
1192 return ret;
1193 }
1018 1194
1019 netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", buf); 1195 netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", buf);
1020 1196
1021 ret = smsc75xx_read_reg(dev, E2P_CMD, &buf); 1197 ret = smsc75xx_read_reg(dev, E2P_CMD, &buf);
1022 check_warn_return(ret, "Failed to read E2P_CMD: %d\n", ret); 1198 if (ret < 0) {
1199 netdev_warn(dev->net, "Failed to read E2P_CMD: %d\n", ret);
1200 return ret;
1201 }
1023 1202
1024 /* only set default GPIO/LED settings if no EEPROM is detected */ 1203 /* only set default GPIO/LED settings if no EEPROM is detected */
1025 if (!(buf & E2P_CMD_LOADED)) { 1204 if (!(buf & E2P_CMD_LOADED)) {
1026 ret = smsc75xx_read_reg(dev, LED_GPIO_CFG, &buf); 1205 ret = smsc75xx_read_reg(dev, LED_GPIO_CFG, &buf);
1027 check_warn_return(ret, "Failed to read LED_GPIO_CFG: %d\n", 1206 if (ret < 0) {
1028 ret); 1207 netdev_warn(dev->net, "Failed to read LED_GPIO_CFG: %d\n", ret);
1208 return ret;
1209 }
1029 1210
1030 buf &= ~(LED_GPIO_CFG_LED2_FUN_SEL | LED_GPIO_CFG_LED10_FUN_SEL); 1211 buf &= ~(LED_GPIO_CFG_LED2_FUN_SEL | LED_GPIO_CFG_LED10_FUN_SEL);
1031 buf |= LED_GPIO_CFG_LEDGPIO_EN | LED_GPIO_CFG_LED2_FUN_SEL; 1212 buf |= LED_GPIO_CFG_LEDGPIO_EN | LED_GPIO_CFG_LED2_FUN_SEL;
1032 1213
1033 ret = smsc75xx_write_reg(dev, LED_GPIO_CFG, buf); 1214 ret = smsc75xx_write_reg(dev, LED_GPIO_CFG, buf);
1034 check_warn_return(ret, "Failed to write LED_GPIO_CFG: %d\n", 1215 if (ret < 0) {
1035 ret); 1216 netdev_warn(dev->net, "Failed to write LED_GPIO_CFG: %d\n", ret);
1217 return ret;
1218 }
1036 } 1219 }
1037 1220
1038 ret = smsc75xx_write_reg(dev, FLOW, 0); 1221 ret = smsc75xx_write_reg(dev, FLOW, 0);
1039 check_warn_return(ret, "Failed to write FLOW: %d\n", ret); 1222 if (ret < 0) {
1223 netdev_warn(dev->net, "Failed to write FLOW: %d\n", ret);
1224 return ret;
1225 }
1040 1226
1041 ret = smsc75xx_write_reg(dev, FCT_FLOW, 0); 1227 ret = smsc75xx_write_reg(dev, FCT_FLOW, 0);
1042 check_warn_return(ret, "Failed to write FCT_FLOW: %d\n", ret); 1228 if (ret < 0) {
1229 netdev_warn(dev->net, "Failed to write FCT_FLOW: %d\n", ret);
1230 return ret;
1231 }
1043 1232
1044 /* Don't need rfe_ctl_lock during initialisation */ 1233 /* Don't need rfe_ctl_lock during initialisation */
1045 ret = smsc75xx_read_reg(dev, RFE_CTL, &pdata->rfe_ctl); 1234 ret = smsc75xx_read_reg(dev, RFE_CTL, &pdata->rfe_ctl);
1046 check_warn_return(ret, "Failed to read RFE_CTL: %d\n", ret); 1235 if (ret < 0) {
1236 netdev_warn(dev->net, "Failed to read RFE_CTL: %d\n", ret);
1237 return ret;
1238 }
1047 1239
1048 pdata->rfe_ctl |= RFE_CTL_AB | RFE_CTL_DPF; 1240 pdata->rfe_ctl |= RFE_CTL_AB | RFE_CTL_DPF;
1049 1241
1050 ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); 1242 ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl);
1051 check_warn_return(ret, "Failed to write RFE_CTL: %d\n", ret); 1243 if (ret < 0) {
1244 netdev_warn(dev->net, "Failed to write RFE_CTL: %d\n", ret);
1245 return ret;
1246 }
1052 1247
1053 ret = smsc75xx_read_reg(dev, RFE_CTL, &pdata->rfe_ctl); 1248 ret = smsc75xx_read_reg(dev, RFE_CTL, &pdata->rfe_ctl);
1054 check_warn_return(ret, "Failed to read RFE_CTL: %d\n", ret); 1249 if (ret < 0) {
1250 netdev_warn(dev->net, "Failed to read RFE_CTL: %d\n", ret);
1251 return ret;
1252 }
1055 1253
1056 netif_dbg(dev, ifup, dev->net, "RFE_CTL set to 0x%08x\n", 1254 netif_dbg(dev, ifup, dev->net, "RFE_CTL set to 0x%08x\n",
1057 pdata->rfe_ctl); 1255 pdata->rfe_ctl);
@@ -1062,65 +1260,107 @@ static int smsc75xx_reset(struct usbnet *dev)
1062 smsc75xx_set_multicast(dev->net); 1260 smsc75xx_set_multicast(dev->net);
1063 1261
1064 ret = smsc75xx_phy_initialize(dev); 1262 ret = smsc75xx_phy_initialize(dev);
1065 check_warn_return(ret, "Failed to initialize PHY: %d\n", ret); 1263 if (ret < 0) {
1264 netdev_warn(dev->net, "Failed to initialize PHY: %d\n", ret);
1265 return ret;
1266 }
1066 1267
1067 ret = smsc75xx_read_reg(dev, INT_EP_CTL, &buf); 1268 ret = smsc75xx_read_reg(dev, INT_EP_CTL, &buf);
1068 check_warn_return(ret, "Failed to read INT_EP_CTL: %d\n", ret); 1269 if (ret < 0) {
1270 netdev_warn(dev->net, "Failed to read INT_EP_CTL: %d\n", ret);
1271 return ret;
1272 }
1069 1273
1070 /* enable PHY interrupts */ 1274 /* enable PHY interrupts */
1071 buf |= INT_ENP_PHY_INT; 1275 buf |= INT_ENP_PHY_INT;
1072 1276
1073 ret = smsc75xx_write_reg(dev, INT_EP_CTL, buf); 1277 ret = smsc75xx_write_reg(dev, INT_EP_CTL, buf);
1074 check_warn_return(ret, "Failed to write INT_EP_CTL: %d\n", ret); 1278 if (ret < 0) {
1279 netdev_warn(dev->net, "Failed to write INT_EP_CTL: %d\n", ret);
1280 return ret;
1281 }
1075 1282
1076 /* allow mac to detect speed and duplex from phy */ 1283 /* allow mac to detect speed and duplex from phy */
1077 ret = smsc75xx_read_reg(dev, MAC_CR, &buf); 1284 ret = smsc75xx_read_reg(dev, MAC_CR, &buf);
1078 check_warn_return(ret, "Failed to read MAC_CR: %d\n", ret); 1285 if (ret < 0) {
1286 netdev_warn(dev->net, "Failed to read MAC_CR: %d\n", ret);
1287 return ret;
1288 }
1079 1289
1080 buf |= (MAC_CR_ADD | MAC_CR_ASD); 1290 buf |= (MAC_CR_ADD | MAC_CR_ASD);
1081 ret = smsc75xx_write_reg(dev, MAC_CR, buf); 1291 ret = smsc75xx_write_reg(dev, MAC_CR, buf);
1082 check_warn_return(ret, "Failed to write MAC_CR: %d\n", ret); 1292 if (ret < 0) {
1293 netdev_warn(dev->net, "Failed to write MAC_CR: %d\n", ret);
1294 return ret;
1295 }
1083 1296
1084 ret = smsc75xx_read_reg(dev, MAC_TX, &buf); 1297 ret = smsc75xx_read_reg(dev, MAC_TX, &buf);
1085 check_warn_return(ret, "Failed to read MAC_TX: %d\n", ret); 1298 if (ret < 0) {
1299 netdev_warn(dev->net, "Failed to read MAC_TX: %d\n", ret);
1300 return ret;
1301 }
1086 1302
1087 buf |= MAC_TX_TXEN; 1303 buf |= MAC_TX_TXEN;
1088 1304
1089 ret = smsc75xx_write_reg(dev, MAC_TX, buf); 1305 ret = smsc75xx_write_reg(dev, MAC_TX, buf);
1090 check_warn_return(ret, "Failed to write MAC_TX: %d\n", ret); 1306 if (ret < 0) {
1307 netdev_warn(dev->net, "Failed to write MAC_TX: %d\n", ret);
1308 return ret;
1309 }
1091 1310
1092 netif_dbg(dev, ifup, dev->net, "MAC_TX set to 0x%08x\n", buf); 1311 netif_dbg(dev, ifup, dev->net, "MAC_TX set to 0x%08x\n", buf);
1093 1312
1094 ret = smsc75xx_read_reg(dev, FCT_TX_CTL, &buf); 1313 ret = smsc75xx_read_reg(dev, FCT_TX_CTL, &buf);
1095 check_warn_return(ret, "Failed to read FCT_TX_CTL: %d\n", ret); 1314 if (ret < 0) {
1315 netdev_warn(dev->net, "Failed to read FCT_TX_CTL: %d\n", ret);
1316 return ret;
1317 }
1096 1318
1097 buf |= FCT_TX_CTL_EN; 1319 buf |= FCT_TX_CTL_EN;
1098 1320
1099 ret = smsc75xx_write_reg(dev, FCT_TX_CTL, buf); 1321 ret = smsc75xx_write_reg(dev, FCT_TX_CTL, buf);
1100 check_warn_return(ret, "Failed to write FCT_TX_CTL: %d\n", ret); 1322 if (ret < 0) {
1323 netdev_warn(dev->net, "Failed to write FCT_TX_CTL: %d\n", ret);
1324 return ret;
1325 }
1101 1326
1102 netif_dbg(dev, ifup, dev->net, "FCT_TX_CTL set to 0x%08x\n", buf); 1327 netif_dbg(dev, ifup, dev->net, "FCT_TX_CTL set to 0x%08x\n", buf);
1103 1328
1104 ret = smsc75xx_set_rx_max_frame_length(dev, 1514); 1329 ret = smsc75xx_set_rx_max_frame_length(dev, 1514);
1105 check_warn_return(ret, "Failed to set max rx frame length\n"); 1330 if (ret < 0) {
1331 netdev_warn(dev->net, "Failed to set max rx frame length\n");
1332 return ret;
1333 }
1106 1334
1107 ret = smsc75xx_read_reg(dev, MAC_RX, &buf); 1335 ret = smsc75xx_read_reg(dev, MAC_RX, &buf);
1108 check_warn_return(ret, "Failed to read MAC_RX: %d\n", ret); 1336 if (ret < 0) {
1337 netdev_warn(dev->net, "Failed to read MAC_RX: %d\n", ret);
1338 return ret;
1339 }
1109 1340
1110 buf |= MAC_RX_RXEN; 1341 buf |= MAC_RX_RXEN;
1111 1342
1112 ret = smsc75xx_write_reg(dev, MAC_RX, buf); 1343 ret = smsc75xx_write_reg(dev, MAC_RX, buf);
1113 check_warn_return(ret, "Failed to write MAC_RX: %d\n", ret); 1344 if (ret < 0) {
1345 netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret);
1346 return ret;
1347 }
1114 1348
1115 netif_dbg(dev, ifup, dev->net, "MAC_RX set to 0x%08x\n", buf); 1349 netif_dbg(dev, ifup, dev->net, "MAC_RX set to 0x%08x\n", buf);
1116 1350
1117 ret = smsc75xx_read_reg(dev, FCT_RX_CTL, &buf); 1351 ret = smsc75xx_read_reg(dev, FCT_RX_CTL, &buf);
1118 check_warn_return(ret, "Failed to read FCT_RX_CTL: %d\n", ret); 1352 if (ret < 0) {
1353 netdev_warn(dev->net, "Failed to read FCT_RX_CTL: %d\n", ret);
1354 return ret;
1355 }
1119 1356
1120 buf |= FCT_RX_CTL_EN; 1357 buf |= FCT_RX_CTL_EN;
1121 1358
1122 ret = smsc75xx_write_reg(dev, FCT_RX_CTL, buf); 1359 ret = smsc75xx_write_reg(dev, FCT_RX_CTL, buf);
1123 check_warn_return(ret, "Failed to write FCT_RX_CTL: %d\n", ret); 1360 if (ret < 0) {
1361 netdev_warn(dev->net, "Failed to write FCT_RX_CTL: %d\n", ret);
1362 return ret;
1363 }
1124 1364
1125 netif_dbg(dev, ifup, dev->net, "FCT_RX_CTL set to 0x%08x\n", buf); 1365 netif_dbg(dev, ifup, dev->net, "FCT_RX_CTL set to 0x%08x\n", buf);
1126 1366
@@ -1149,7 +1389,10 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
1149 printk(KERN_INFO SMSC_CHIPNAME " v" SMSC_DRIVER_VERSION "\n"); 1389 printk(KERN_INFO SMSC_CHIPNAME " v" SMSC_DRIVER_VERSION "\n");
1150 1390
1151 ret = usbnet_get_endpoints(dev, intf); 1391 ret = usbnet_get_endpoints(dev, intf);
1152 check_warn_return(ret, "usbnet_get_endpoints failed: %d\n", ret); 1392 if (ret < 0) {
1393 netdev_warn(dev->net, "usbnet_get_endpoints failed: %d\n", ret);
1394 return ret;
1395 }
1153 1396
1154 dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc75xx_priv), 1397 dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc75xx_priv),
1155 GFP_KERNEL); 1398 GFP_KERNEL);
@@ -1181,7 +1424,10 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
1181 1424
1182 /* Init all registers */ 1425 /* Init all registers */
1183 ret = smsc75xx_reset(dev); 1426 ret = smsc75xx_reset(dev);
1184 check_warn_return(ret, "smsc75xx_reset error %d\n", ret); 1427 if (ret < 0) {
1428 netdev_warn(dev->net, "smsc75xx_reset error %d\n", ret);
1429 return ret;
1430 }
1185 1431
1186 dev->net->netdev_ops = &smsc75xx_netdev_ops; 1432 dev->net->netdev_ops = &smsc75xx_netdev_ops;
1187 dev->net->ethtool_ops = &smsc75xx_ethtool_ops; 1433 dev->net->ethtool_ops = &smsc75xx_ethtool_ops;
@@ -1215,19 +1461,34 @@ static int smsc75xx_write_wuff(struct usbnet *dev, int filter, u32 wuf_cfg,
1215 int ret; 1461 int ret;
1216 1462
1217 ret = smsc75xx_write_reg(dev, cfg_base, wuf_cfg); 1463 ret = smsc75xx_write_reg(dev, cfg_base, wuf_cfg);
1218 check_warn_return(ret, "Error writing WUF_CFGX\n"); 1464 if (ret < 0) {
1465 netdev_warn(dev->net, "Error writing WUF_CFGX\n");
1466 return ret;
1467 }
1219 1468
1220 ret = smsc75xx_write_reg(dev, mask_base, wuf_mask1); 1469 ret = smsc75xx_write_reg(dev, mask_base, wuf_mask1);
1221 check_warn_return(ret, "Error writing WUF_MASKX\n"); 1470 if (ret < 0) {
1471 netdev_warn(dev->net, "Error writing WUF_MASKX\n");
1472 return ret;
1473 }
1222 1474
1223 ret = smsc75xx_write_reg(dev, mask_base + 4, 0); 1475 ret = smsc75xx_write_reg(dev, mask_base + 4, 0);
1224 check_warn_return(ret, "Error writing WUF_MASKX\n"); 1476 if (ret < 0) {
1477 netdev_warn(dev->net, "Error writing WUF_MASKX\n");
1478 return ret;
1479 }
1225 1480
1226 ret = smsc75xx_write_reg(dev, mask_base + 8, 0); 1481 ret = smsc75xx_write_reg(dev, mask_base + 8, 0);
1227 check_warn_return(ret, "Error writing WUF_MASKX\n"); 1482 if (ret < 0) {
1483 netdev_warn(dev->net, "Error writing WUF_MASKX\n");
1484 return ret;
1485 }
1228 1486
1229 ret = smsc75xx_write_reg(dev, mask_base + 12, 0); 1487 ret = smsc75xx_write_reg(dev, mask_base + 12, 0);
1230 check_warn_return(ret, "Error writing WUF_MASKX\n"); 1488 if (ret < 0) {
1489 netdev_warn(dev->net, "Error writing WUF_MASKX\n");
1490 return ret;
1491 }
1231 1492
1232 return 0; 1493 return 0;
1233} 1494}
@@ -1239,13 +1500,19 @@ static int smsc75xx_enter_suspend0(struct usbnet *dev)
1239 int ret; 1500 int ret;
1240 1501
1241 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); 1502 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1242 check_warn_return(ret, "Error reading PMT_CTL\n"); 1503 if (ret < 0) {
1504 netdev_warn(dev->net, "Error reading PMT_CTL\n");
1505 return ret;
1506 }
1243 1507
1244 val &= (~(PMT_CTL_SUS_MODE | PMT_CTL_PHY_RST)); 1508 val &= (~(PMT_CTL_SUS_MODE | PMT_CTL_PHY_RST));
1245 val |= PMT_CTL_SUS_MODE_0 | PMT_CTL_WOL_EN | PMT_CTL_WUPS; 1509 val |= PMT_CTL_SUS_MODE_0 | PMT_CTL_WOL_EN | PMT_CTL_WUPS;
1246 1510
1247 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); 1511 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1248 check_warn_return(ret, "Error writing PMT_CTL\n"); 1512 if (ret < 0) {
1513 netdev_warn(dev->net, "Error writing PMT_CTL\n");
1514 return ret;
1515 }
1249 1516
1250 pdata->suspend_flags |= SUSPEND_SUSPEND0; 1517 pdata->suspend_flags |= SUSPEND_SUSPEND0;
1251 1518
@@ -1259,20 +1526,29 @@ static int smsc75xx_enter_suspend1(struct usbnet *dev)
1259 int ret; 1526 int ret;
1260 1527
1261 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); 1528 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1262 check_warn_return(ret, "Error reading PMT_CTL\n"); 1529 if (ret < 0) {
1530 netdev_warn(dev->net, "Error reading PMT_CTL\n");
1531 return ret;
1532 }
1263 1533
1264 val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST); 1534 val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST);
1265 val |= PMT_CTL_SUS_MODE_1; 1535 val |= PMT_CTL_SUS_MODE_1;
1266 1536
1267 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); 1537 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1268 check_warn_return(ret, "Error writing PMT_CTL\n"); 1538 if (ret < 0) {
1539 netdev_warn(dev->net, "Error writing PMT_CTL\n");
1540 return ret;
1541 }
1269 1542
1270 /* clear wol status, enable energy detection */ 1543 /* clear wol status, enable energy detection */
1271 val &= ~PMT_CTL_WUPS; 1544 val &= ~PMT_CTL_WUPS;
1272 val |= (PMT_CTL_WUPS_ED | PMT_CTL_ED_EN); 1545 val |= (PMT_CTL_WUPS_ED | PMT_CTL_ED_EN);
1273 1546
1274 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); 1547 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1275 check_warn_return(ret, "Error writing PMT_CTL\n"); 1548 if (ret < 0) {
1549 netdev_warn(dev->net, "Error writing PMT_CTL\n");
1550 return ret;
1551 }
1276 1552
1277 pdata->suspend_flags |= SUSPEND_SUSPEND1; 1553 pdata->suspend_flags |= SUSPEND_SUSPEND1;
1278 1554
@@ -1286,13 +1562,19 @@ static int smsc75xx_enter_suspend2(struct usbnet *dev)
1286 int ret; 1562 int ret;
1287 1563
1288 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); 1564 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1289 check_warn_return(ret, "Error reading PMT_CTL\n"); 1565 if (ret < 0) {
1566 netdev_warn(dev->net, "Error reading PMT_CTL\n");
1567 return ret;
1568 }
1290 1569
1291 val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST); 1570 val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST);
1292 val |= PMT_CTL_SUS_MODE_2; 1571 val |= PMT_CTL_SUS_MODE_2;
1293 1572
1294 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); 1573 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1295 check_warn_return(ret, "Error writing PMT_CTL\n"); 1574 if (ret < 0) {
1575 netdev_warn(dev->net, "Error writing PMT_CTL\n");
1576 return ret;
1577 }
1296 1578
1297 pdata->suspend_flags |= SUSPEND_SUSPEND2; 1579 pdata->suspend_flags |= SUSPEND_SUSPEND2;
1298 1580
@@ -1306,7 +1588,10 @@ static int smsc75xx_enter_suspend3(struct usbnet *dev)
1306 int ret; 1588 int ret;
1307 1589
1308 ret = smsc75xx_read_reg_nopm(dev, FCT_RX_CTL, &val); 1590 ret = smsc75xx_read_reg_nopm(dev, FCT_RX_CTL, &val);
1309 check_warn_return(ret, "Error reading FCT_RX_CTL\n"); 1591 if (ret < 0) {
1592 netdev_warn(dev->net, "Error reading FCT_RX_CTL\n");
1593 return ret;
1594 }
1310 1595
1311 if (val & FCT_RX_CTL_RXUSED) { 1596 if (val & FCT_RX_CTL_RXUSED) {
1312 netdev_dbg(dev->net, "rx fifo not empty in autosuspend\n"); 1597 netdev_dbg(dev->net, "rx fifo not empty in autosuspend\n");
@@ -1314,20 +1599,29 @@ static int smsc75xx_enter_suspend3(struct usbnet *dev)
1314 } 1599 }
1315 1600
1316 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); 1601 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1317 check_warn_return(ret, "Error reading PMT_CTL\n"); 1602 if (ret < 0) {
1603 netdev_warn(dev->net, "Error reading PMT_CTL\n");
1604 return ret;
1605 }
1318 1606
1319 val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST); 1607 val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST);
1320 val |= PMT_CTL_SUS_MODE_3 | PMT_CTL_RES_CLR_WKP_EN; 1608 val |= PMT_CTL_SUS_MODE_3 | PMT_CTL_RES_CLR_WKP_EN;
1321 1609
1322 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); 1610 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1323 check_warn_return(ret, "Error writing PMT_CTL\n"); 1611 if (ret < 0) {
1612 netdev_warn(dev->net, "Error writing PMT_CTL\n");
1613 return ret;
1614 }
1324 1615
1325 /* clear wol status */ 1616 /* clear wol status */
1326 val &= ~PMT_CTL_WUPS; 1617 val &= ~PMT_CTL_WUPS;
1327 val |= PMT_CTL_WUPS_WOL; 1618 val |= PMT_CTL_WUPS_WOL;
1328 1619
1329 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); 1620 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1330 check_warn_return(ret, "Error writing PMT_CTL\n"); 1621 if (ret < 0) {
1622 netdev_warn(dev->net, "Error writing PMT_CTL\n");
1623 return ret;
1624 }
1331 1625
1332 pdata->suspend_flags |= SUSPEND_SUSPEND3; 1626 pdata->suspend_flags |= SUSPEND_SUSPEND3;
1333 1627
@@ -1343,11 +1637,17 @@ static int smsc75xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask)
1343 1637
1344 /* read to clear */ 1638 /* read to clear */
1345 ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_SRC); 1639 ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_SRC);
1346 check_warn_return(ret, "Error reading PHY_INT_SRC\n"); 1640 if (ret < 0) {
1641 netdev_warn(dev->net, "Error reading PHY_INT_SRC\n");
1642 return ret;
1643 }
1347 1644
1348 /* enable interrupt source */ 1645 /* enable interrupt source */
1349 ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_MASK); 1646 ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_MASK);
1350 check_warn_return(ret, "Error reading PHY_INT_MASK\n"); 1647 if (ret < 0) {
1648 netdev_warn(dev->net, "Error reading PHY_INT_MASK\n");
1649 return ret;
1650 }
1351 1651
1352 ret |= mask; 1652 ret |= mask;
1353 1653
@@ -1363,10 +1663,16 @@ static int smsc75xx_link_ok_nopm(struct usbnet *dev)
1363 1663
1364 /* first, a dummy read, needed to latch some MII phys */ 1664 /* first, a dummy read, needed to latch some MII phys */
1365 ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); 1665 ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR);
1366 check_warn_return(ret, "Error reading MII_BMSR\n"); 1666 if (ret < 0) {
1667 netdev_warn(dev->net, "Error reading MII_BMSR\n");
1668 return ret;
1669 }
1367 1670
1368 ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); 1671 ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR);
1369 check_warn_return(ret, "Error reading MII_BMSR\n"); 1672 if (ret < 0) {
1673 netdev_warn(dev->net, "Error reading MII_BMSR\n");
1674 return ret;
1675 }
1370 1676
1371 return !!(ret & BMSR_LSTATUS); 1677 return !!(ret & BMSR_LSTATUS);
1372} 1678}
@@ -1388,7 +1694,10 @@ static int smsc75xx_autosuspend(struct usbnet *dev, u32 link_up)
1388 /* enable PHY wakeup events for if cable is attached */ 1694 /* enable PHY wakeup events for if cable is attached */
1389 ret = smsc75xx_enable_phy_wakeup_interrupts(dev, 1695 ret = smsc75xx_enable_phy_wakeup_interrupts(dev,
1390 PHY_INT_MASK_ANEG_COMP); 1696 PHY_INT_MASK_ANEG_COMP);
1391 check_warn_return(ret, "error enabling PHY wakeup ints\n"); 1697 if (ret < 0) {
1698 netdev_warn(dev->net, "error enabling PHY wakeup ints\n");
1699 return ret;
1700 }
1392 1701
1393 netdev_info(dev->net, "entering SUSPEND1 mode\n"); 1702 netdev_info(dev->net, "entering SUSPEND1 mode\n");
1394 return smsc75xx_enter_suspend1(dev); 1703 return smsc75xx_enter_suspend1(dev);
@@ -1397,7 +1706,10 @@ static int smsc75xx_autosuspend(struct usbnet *dev, u32 link_up)
1397 /* enable PHY wakeup events so we remote wakeup if cable is pulled */ 1706 /* enable PHY wakeup events so we remote wakeup if cable is pulled */
1398 ret = smsc75xx_enable_phy_wakeup_interrupts(dev, 1707 ret = smsc75xx_enable_phy_wakeup_interrupts(dev,
1399 PHY_INT_MASK_LINK_DOWN); 1708 PHY_INT_MASK_LINK_DOWN);
1400 check_warn_return(ret, "error enabling PHY wakeup ints\n"); 1709 if (ret < 0) {
1710 netdev_warn(dev->net, "error enabling PHY wakeup ints\n");
1711 return ret;
1712 }
1401 1713
1402 netdev_dbg(dev->net, "autosuspend entering SUSPEND3\n"); 1714 netdev_dbg(dev->net, "autosuspend entering SUSPEND3\n");
1403 return smsc75xx_enter_suspend3(dev); 1715 return smsc75xx_enter_suspend3(dev);
@@ -1411,7 +1723,10 @@ static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
1411 int ret; 1723 int ret;
1412 1724
1413 ret = usbnet_suspend(intf, message); 1725 ret = usbnet_suspend(intf, message);
1414 check_warn_return(ret, "usbnet_suspend error\n"); 1726 if (ret < 0) {
1727 netdev_warn(dev->net, "usbnet_suspend error\n");
1728 return ret;
1729 }
1415 1730
1416 if (pdata->suspend_flags) { 1731 if (pdata->suspend_flags) {
1417 netdev_warn(dev->net, "error during last resume\n"); 1732 netdev_warn(dev->net, "error during last resume\n");
@@ -1436,20 +1751,32 @@ static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
1436 1751
1437 /* disable energy detect (link up) & wake up events */ 1752 /* disable energy detect (link up) & wake up events */
1438 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); 1753 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1439 check_warn_goto_done(ret, "Error reading WUCSR\n"); 1754 if (ret < 0) {
1755 netdev_warn(dev->net, "Error reading WUCSR\n");
1756 goto done;
1757 }
1440 1758
1441 val &= ~(WUCSR_MPEN | WUCSR_WUEN); 1759 val &= ~(WUCSR_MPEN | WUCSR_WUEN);
1442 1760
1443 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); 1761 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1444 check_warn_goto_done(ret, "Error writing WUCSR\n"); 1762 if (ret < 0) {
1763 netdev_warn(dev->net, "Error writing WUCSR\n");
1764 goto done;
1765 }
1445 1766
1446 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); 1767 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1447 check_warn_goto_done(ret, "Error reading PMT_CTL\n"); 1768 if (ret < 0) {
1769 netdev_warn(dev->net, "Error reading PMT_CTL\n");
1770 goto done;
1771 }
1448 1772
1449 val &= ~(PMT_CTL_ED_EN | PMT_CTL_WOL_EN); 1773 val &= ~(PMT_CTL_ED_EN | PMT_CTL_WOL_EN);
1450 1774
1451 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); 1775 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1452 check_warn_goto_done(ret, "Error writing PMT_CTL\n"); 1776 if (ret < 0) {
1777 netdev_warn(dev->net, "Error writing PMT_CTL\n");
1778 goto done;
1779 }
1453 1780
1454 ret = smsc75xx_enter_suspend2(dev); 1781 ret = smsc75xx_enter_suspend2(dev);
1455 goto done; 1782 goto done;
@@ -1458,7 +1785,10 @@ static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
1458 if (pdata->wolopts & WAKE_PHY) { 1785 if (pdata->wolopts & WAKE_PHY) {
1459 ret = smsc75xx_enable_phy_wakeup_interrupts(dev, 1786 ret = smsc75xx_enable_phy_wakeup_interrupts(dev,
1460 (PHY_INT_MASK_ANEG_COMP | PHY_INT_MASK_LINK_DOWN)); 1787 (PHY_INT_MASK_ANEG_COMP | PHY_INT_MASK_LINK_DOWN));
1461 check_warn_goto_done(ret, "error enabling PHY wakeup ints\n"); 1788 if (ret < 0) {
1789 netdev_warn(dev->net, "error enabling PHY wakeup ints\n");
1790 goto done;
1791 }
1462 1792
1463 /* if link is down then configure EDPD and enter SUSPEND1, 1793 /* if link is down then configure EDPD and enter SUSPEND1,
1464 * otherwise enter SUSPEND0 below 1794 * otherwise enter SUSPEND0 below
@@ -1470,7 +1800,10 @@ static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
1470 /* enable energy detect power-down mode */ 1800 /* enable energy detect power-down mode */
1471 ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, 1801 ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id,
1472 PHY_MODE_CTRL_STS); 1802 PHY_MODE_CTRL_STS);
1473 check_warn_goto_done(ret, "Error reading PHY_MODE_CTRL_STS\n"); 1803 if (ret < 0) {
1804 netdev_warn(dev->net, "Error reading PHY_MODE_CTRL_STS\n");
1805 goto done;
1806 }
1474 1807
1475 ret |= MODE_CTRL_STS_EDPWRDOWN; 1808 ret |= MODE_CTRL_STS_EDPWRDOWN;
1476 1809
@@ -1489,7 +1822,10 @@ static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
1489 /* disable all filters */ 1822 /* disable all filters */
1490 for (i = 0; i < WUF_NUM; i++) { 1823 for (i = 0; i < WUF_NUM; i++) {
1491 ret = smsc75xx_write_reg_nopm(dev, WUF_CFGX + i * 4, 0); 1824 ret = smsc75xx_write_reg_nopm(dev, WUF_CFGX + i * 4, 0);
1492 check_warn_goto_done(ret, "Error writing WUF_CFGX\n"); 1825 if (ret < 0) {
1826 netdev_warn(dev->net, "Error writing WUF_CFGX\n");
1827 goto done;
1828 }
1493 } 1829 }
1494 1830
1495 if (pdata->wolopts & WAKE_MCAST) { 1831 if (pdata->wolopts & WAKE_MCAST) {
@@ -1499,7 +1835,10 @@ static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
1499 val = WUF_CFGX_EN | WUF_CFGX_ATYPE_MULTICAST 1835 val = WUF_CFGX_EN | WUF_CFGX_ATYPE_MULTICAST
1500 | smsc_crc(mcast, 3); 1836 | smsc_crc(mcast, 3);
1501 ret = smsc75xx_write_wuff(dev, filter++, val, 0x0007); 1837 ret = smsc75xx_write_wuff(dev, filter++, val, 0x0007);
1502 check_warn_goto_done(ret, "Error writing wakeup filter\n"); 1838 if (ret < 0) {
1839 netdev_warn(dev->net, "Error writing wakeup filter\n");
1840 goto done;
1841 }
1503 } 1842 }
1504 1843
1505 if (pdata->wolopts & WAKE_ARP) { 1844 if (pdata->wolopts & WAKE_ARP) {
@@ -1509,102 +1848,159 @@ static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
1509 val = WUF_CFGX_EN | WUF_CFGX_ATYPE_ALL | (0x0C << 16) 1848 val = WUF_CFGX_EN | WUF_CFGX_ATYPE_ALL | (0x0C << 16)
1510 | smsc_crc(arp, 2); 1849 | smsc_crc(arp, 2);
1511 ret = smsc75xx_write_wuff(dev, filter++, val, 0x0003); 1850 ret = smsc75xx_write_wuff(dev, filter++, val, 0x0003);
1512 check_warn_goto_done(ret, "Error writing wakeup filter\n"); 1851 if (ret < 0) {
1852 netdev_warn(dev->net, "Error writing wakeup filter\n");
1853 goto done;
1854 }
1513 } 1855 }
1514 1856
1515 /* clear any pending pattern match packet status */ 1857 /* clear any pending pattern match packet status */
1516 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); 1858 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1517 check_warn_goto_done(ret, "Error reading WUCSR\n"); 1859 if (ret < 0) {
1860 netdev_warn(dev->net, "Error reading WUCSR\n");
1861 goto done;
1862 }
1518 1863
1519 val |= WUCSR_WUFR; 1864 val |= WUCSR_WUFR;
1520 1865
1521 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); 1866 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1522 check_warn_goto_done(ret, "Error writing WUCSR\n"); 1867 if (ret < 0) {
1868 netdev_warn(dev->net, "Error writing WUCSR\n");
1869 goto done;
1870 }
1523 1871
1524 netdev_info(dev->net, "enabling packet match detection\n"); 1872 netdev_info(dev->net, "enabling packet match detection\n");
1525 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); 1873 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1526 check_warn_goto_done(ret, "Error reading WUCSR\n"); 1874 if (ret < 0) {
1875 netdev_warn(dev->net, "Error reading WUCSR\n");
1876 goto done;
1877 }
1527 1878
1528 val |= WUCSR_WUEN; 1879 val |= WUCSR_WUEN;
1529 1880
1530 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); 1881 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1531 check_warn_goto_done(ret, "Error writing WUCSR\n"); 1882 if (ret < 0) {
1883 netdev_warn(dev->net, "Error writing WUCSR\n");
1884 goto done;
1885 }
1532 } else { 1886 } else {
1533 netdev_info(dev->net, "disabling packet match detection\n"); 1887 netdev_info(dev->net, "disabling packet match detection\n");
1534 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); 1888 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1535 check_warn_goto_done(ret, "Error reading WUCSR\n"); 1889 if (ret < 0) {
1890 netdev_warn(dev->net, "Error reading WUCSR\n");
1891 goto done;
1892 }
1536 1893
1537 val &= ~WUCSR_WUEN; 1894 val &= ~WUCSR_WUEN;
1538 1895
1539 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); 1896 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1540 check_warn_goto_done(ret, "Error writing WUCSR\n"); 1897 if (ret < 0) {
1898 netdev_warn(dev->net, "Error writing WUCSR\n");
1899 goto done;
1900 }
1541 } 1901 }
1542 1902
1543 /* disable magic, bcast & unicast wakeup sources */ 1903 /* disable magic, bcast & unicast wakeup sources */
1544 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); 1904 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1545 check_warn_goto_done(ret, "Error reading WUCSR\n"); 1905 if (ret < 0) {
1906 netdev_warn(dev->net, "Error reading WUCSR\n");
1907 goto done;
1908 }
1546 1909
1547 val &= ~(WUCSR_MPEN | WUCSR_BCST_EN | WUCSR_PFDA_EN); 1910 val &= ~(WUCSR_MPEN | WUCSR_BCST_EN | WUCSR_PFDA_EN);
1548 1911
1549 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); 1912 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1550 check_warn_goto_done(ret, "Error writing WUCSR\n"); 1913 if (ret < 0) {
1914 netdev_warn(dev->net, "Error writing WUCSR\n");
1915 goto done;
1916 }
1551 1917
1552 if (pdata->wolopts & WAKE_PHY) { 1918 if (pdata->wolopts & WAKE_PHY) {
1553 netdev_info(dev->net, "enabling PHY wakeup\n"); 1919 netdev_info(dev->net, "enabling PHY wakeup\n");
1554 1920
1555 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); 1921 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1556 check_warn_goto_done(ret, "Error reading PMT_CTL\n"); 1922 if (ret < 0) {
1923 netdev_warn(dev->net, "Error reading PMT_CTL\n");
1924 goto done;
1925 }
1557 1926
1558 /* clear wol status, enable energy detection */ 1927 /* clear wol status, enable energy detection */
1559 val &= ~PMT_CTL_WUPS; 1928 val &= ~PMT_CTL_WUPS;
1560 val |= (PMT_CTL_WUPS_ED | PMT_CTL_ED_EN); 1929 val |= (PMT_CTL_WUPS_ED | PMT_CTL_ED_EN);
1561 1930
1562 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); 1931 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1563 check_warn_goto_done(ret, "Error writing PMT_CTL\n"); 1932 if (ret < 0) {
1933 netdev_warn(dev->net, "Error writing PMT_CTL\n");
1934 goto done;
1935 }
1564 } 1936 }
1565 1937
1566 if (pdata->wolopts & WAKE_MAGIC) { 1938 if (pdata->wolopts & WAKE_MAGIC) {
1567 netdev_info(dev->net, "enabling magic packet wakeup\n"); 1939 netdev_info(dev->net, "enabling magic packet wakeup\n");
1568 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); 1940 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1569 check_warn_goto_done(ret, "Error reading WUCSR\n"); 1941 if (ret < 0) {
1942 netdev_warn(dev->net, "Error reading WUCSR\n");
1943 goto done;
1944 }
1570 1945
1571 /* clear any pending magic packet status */ 1946 /* clear any pending magic packet status */
1572 val |= WUCSR_MPR | WUCSR_MPEN; 1947 val |= WUCSR_MPR | WUCSR_MPEN;
1573 1948
1574 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); 1949 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1575 check_warn_goto_done(ret, "Error writing WUCSR\n"); 1950 if (ret < 0) {
1951 netdev_warn(dev->net, "Error writing WUCSR\n");
1952 goto done;
1953 }
1576 } 1954 }
1577 1955
1578 if (pdata->wolopts & WAKE_BCAST) { 1956 if (pdata->wolopts & WAKE_BCAST) {
1579 netdev_info(dev->net, "enabling broadcast detection\n"); 1957 netdev_info(dev->net, "enabling broadcast detection\n");
1580 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); 1958 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1581 check_warn_goto_done(ret, "Error reading WUCSR\n"); 1959 if (ret < 0) {
1960 netdev_warn(dev->net, "Error reading WUCSR\n");
1961 goto done;
1962 }
1582 1963
1583 val |= WUCSR_BCAST_FR | WUCSR_BCST_EN; 1964 val |= WUCSR_BCAST_FR | WUCSR_BCST_EN;
1584 1965
1585 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); 1966 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1586 check_warn_goto_done(ret, "Error writing WUCSR\n"); 1967 if (ret < 0) {
1968 netdev_warn(dev->net, "Error writing WUCSR\n");
1969 goto done;
1970 }
1587 } 1971 }
1588 1972
1589 if (pdata->wolopts & WAKE_UCAST) { 1973 if (pdata->wolopts & WAKE_UCAST) {
1590 netdev_info(dev->net, "enabling unicast detection\n"); 1974 netdev_info(dev->net, "enabling unicast detection\n");
1591 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); 1975 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1592 check_warn_goto_done(ret, "Error reading WUCSR\n"); 1976 if (ret < 0) {
1977 netdev_warn(dev->net, "Error reading WUCSR\n");
1978 goto done;
1979 }
1593 1980
1594 val |= WUCSR_WUFR | WUCSR_PFDA_EN; 1981 val |= WUCSR_WUFR | WUCSR_PFDA_EN;
1595 1982
1596 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); 1983 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1597 check_warn_goto_done(ret, "Error writing WUCSR\n"); 1984 if (ret < 0) {
1985 netdev_warn(dev->net, "Error writing WUCSR\n");
1986 goto done;
1987 }
1598 } 1988 }
1599 1989
1600 /* enable receiver to enable frame reception */ 1990 /* enable receiver to enable frame reception */
1601 ret = smsc75xx_read_reg_nopm(dev, MAC_RX, &val); 1991 ret = smsc75xx_read_reg_nopm(dev, MAC_RX, &val);
1602 check_warn_goto_done(ret, "Failed to read MAC_RX: %d\n", ret); 1992 if (ret < 0) {
1993 netdev_warn(dev->net, "Failed to read MAC_RX: %d\n", ret);
1994 goto done;
1995 }
1603 1996
1604 val |= MAC_RX_RXEN; 1997 val |= MAC_RX_RXEN;
1605 1998
1606 ret = smsc75xx_write_reg_nopm(dev, MAC_RX, val); 1999 ret = smsc75xx_write_reg_nopm(dev, MAC_RX, val);
1607 check_warn_goto_done(ret, "Failed to write MAC_RX: %d\n", ret); 2000 if (ret < 0) {
2001 netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret);
2002 goto done;
2003 }
1608 2004
1609 /* some wol options are enabled, so enter SUSPEND0 */ 2005 /* some wol options are enabled, so enter SUSPEND0 */
1610 netdev_info(dev->net, "entering SUSPEND0 mode\n"); 2006 netdev_info(dev->net, "entering SUSPEND0 mode\n");
@@ -1632,39 +2028,60 @@ static int smsc75xx_resume(struct usb_interface *intf)
1632 if (suspend_flags & SUSPEND_ALLMODES) { 2028 if (suspend_flags & SUSPEND_ALLMODES) {
1633 /* Disable wakeup sources */ 2029 /* Disable wakeup sources */
1634 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); 2030 ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val);
1635 check_warn_return(ret, "Error reading WUCSR\n"); 2031 if (ret < 0) {
2032 netdev_warn(dev->net, "Error reading WUCSR\n");
2033 return ret;
2034 }
1636 2035
1637 val &= ~(WUCSR_WUEN | WUCSR_MPEN | WUCSR_PFDA_EN 2036 val &= ~(WUCSR_WUEN | WUCSR_MPEN | WUCSR_PFDA_EN
1638 | WUCSR_BCST_EN); 2037 | WUCSR_BCST_EN);
1639 2038
1640 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); 2039 ret = smsc75xx_write_reg_nopm(dev, WUCSR, val);
1641 check_warn_return(ret, "Error writing WUCSR\n"); 2040 if (ret < 0) {
2041 netdev_warn(dev->net, "Error writing WUCSR\n");
2042 return ret;
2043 }
1642 2044
1643 /* clear wake-up status */ 2045 /* clear wake-up status */
1644 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); 2046 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1645 check_warn_return(ret, "Error reading PMT_CTL\n"); 2047 if (ret < 0) {
2048 netdev_warn(dev->net, "Error reading PMT_CTL\n");
2049 return ret;
2050 }
1646 2051
1647 val &= ~PMT_CTL_WOL_EN; 2052 val &= ~PMT_CTL_WOL_EN;
1648 val |= PMT_CTL_WUPS; 2053 val |= PMT_CTL_WUPS;
1649 2054
1650 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); 2055 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1651 check_warn_return(ret, "Error writing PMT_CTL\n"); 2056 if (ret < 0) {
2057 netdev_warn(dev->net, "Error writing PMT_CTL\n");
2058 return ret;
2059 }
1652 } 2060 }
1653 2061
1654 if (suspend_flags & SUSPEND_SUSPEND2) { 2062 if (suspend_flags & SUSPEND_SUSPEND2) {
1655 netdev_info(dev->net, "resuming from SUSPEND2\n"); 2063 netdev_info(dev->net, "resuming from SUSPEND2\n");
1656 2064
1657 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); 2065 ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val);
1658 check_warn_return(ret, "Error reading PMT_CTL\n"); 2066 if (ret < 0) {
2067 netdev_warn(dev->net, "Error reading PMT_CTL\n");
2068 return ret;
2069 }
1659 2070
1660 val |= PMT_CTL_PHY_PWRUP; 2071 val |= PMT_CTL_PHY_PWRUP;
1661 2072
1662 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); 2073 ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val);
1663 check_warn_return(ret, "Error writing PMT_CTL\n"); 2074 if (ret < 0) {
2075 netdev_warn(dev->net, "Error writing PMT_CTL\n");
2076 return ret;
2077 }
1664 } 2078 }
1665 2079
1666 ret = smsc75xx_wait_ready(dev, 1); 2080 ret = smsc75xx_wait_ready(dev, 1);
1667 check_warn_return(ret, "device not ready in smsc75xx_resume\n"); 2081 if (ret < 0) {
2082 netdev_warn(dev->net, "device not ready in smsc75xx_resume\n");
2083 return ret;
2084 }
1668 2085
1669 return usbnet_resume(intf); 2086 return usbnet_resume(intf);
1670} 2087}