aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/smsc9420.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/smsc9420.c')
-rw-r--r--drivers/net/smsc9420.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/net/smsc9420.c b/drivers/net/smsc9420.c
index 27e017d96966..4e15ae068b3f 100644
--- a/drivers/net/smsc9420.c
+++ b/drivers/net/smsc9420.c
@@ -341,7 +341,7 @@ static int smsc9420_eeprom_send_cmd(struct smsc9420_pdata *pd, u32 op)
341 do { 341 do {
342 msleep(1); 342 msleep(1);
343 e2cmd = smsc9420_reg_read(pd, E2P_CMD); 343 e2cmd = smsc9420_reg_read(pd, E2P_CMD);
344 } while ((e2cmd & E2P_CMD_EPC_BUSY_) && (timeout--)); 344 } while ((e2cmd & E2P_CMD_EPC_BUSY_) && (--timeout));
345 345
346 if (!timeout) { 346 if (!timeout) {
347 smsc_info(HW, "TIMED OUT"); 347 smsc_info(HW, "TIMED OUT");
@@ -413,6 +413,7 @@ static int smsc9420_ethtool_get_eeprom(struct net_device *dev,
413 } 413 }
414 414
415 memcpy(data, &eeprom_data[eeprom->offset], len); 415 memcpy(data, &eeprom_data[eeprom->offset], len);
416 eeprom->magic = SMSC9420_EEPROM_MAGIC;
416 eeprom->len = len; 417 eeprom->len = len;
417 return 0; 418 return 0;
418} 419}
@@ -423,6 +424,9 @@ static int smsc9420_ethtool_set_eeprom(struct net_device *dev,
423 struct smsc9420_pdata *pd = netdev_priv(dev); 424 struct smsc9420_pdata *pd = netdev_priv(dev);
424 int ret; 425 int ret;
425 426
427 if (eeprom->magic != SMSC9420_EEPROM_MAGIC)
428 return -EINVAL;
429
426 smsc9420_eeprom_enable_access(pd); 430 smsc9420_eeprom_enable_access(pd);
427 smsc9420_eeprom_send_cmd(pd, E2P_CMD_EPC_CMD_EWEN_); 431 smsc9420_eeprom_send_cmd(pd, E2P_CMD_EPC_CMD_EWEN_);
428 ret = smsc9420_eeprom_write_location(pd, eeprom->offset, *data); 432 ret = smsc9420_eeprom_write_location(pd, eeprom->offset, *data);
@@ -498,7 +502,7 @@ static void smsc9420_check_mac_address(struct net_device *dev)
498static void smsc9420_stop_tx(struct smsc9420_pdata *pd) 502static void smsc9420_stop_tx(struct smsc9420_pdata *pd)
499{ 503{
500 u32 dmac_control, mac_cr, dma_intr_ena; 504 u32 dmac_control, mac_cr, dma_intr_ena;
501 int timeOut = 1000; 505 int timeout = 1000;
502 506
503 /* disable TX DMAC */ 507 /* disable TX DMAC */
504 dmac_control = smsc9420_reg_read(pd, DMAC_CONTROL); 508 dmac_control = smsc9420_reg_read(pd, DMAC_CONTROL);
@@ -506,13 +510,13 @@ static void smsc9420_stop_tx(struct smsc9420_pdata *pd)
506 smsc9420_reg_write(pd, DMAC_CONTROL, dmac_control); 510 smsc9420_reg_write(pd, DMAC_CONTROL, dmac_control);
507 511
508 /* Wait max 10ms for transmit process to stop */ 512 /* Wait max 10ms for transmit process to stop */
509 while (timeOut--) { 513 while (--timeout) {
510 if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_TS_) 514 if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_TS_)
511 break; 515 break;
512 udelay(10); 516 udelay(10);
513 } 517 }
514 518
515 if (!timeOut) 519 if (!timeout)
516 smsc_warn(IFDOWN, "TX DMAC failed to stop"); 520 smsc_warn(IFDOWN, "TX DMAC failed to stop");
517 521
518 /* ACK Tx DMAC stop bit */ 522 /* ACK Tx DMAC stop bit */
@@ -596,7 +600,7 @@ static void smsc9420_free_rx_ring(struct smsc9420_pdata *pd)
596 600
597static void smsc9420_stop_rx(struct smsc9420_pdata *pd) 601static void smsc9420_stop_rx(struct smsc9420_pdata *pd)
598{ 602{
599 int timeOut = 1000; 603 int timeout = 1000;
600 u32 mac_cr, dmac_control, dma_intr_ena; 604 u32 mac_cr, dmac_control, dma_intr_ena;
601 605
602 /* mask RX DMAC interrupts */ 606 /* mask RX DMAC interrupts */
@@ -617,13 +621,13 @@ static void smsc9420_stop_rx(struct smsc9420_pdata *pd)
617 smsc9420_pci_flush_write(pd); 621 smsc9420_pci_flush_write(pd);
618 622
619 /* wait up to 10ms for receive to stop */ 623 /* wait up to 10ms for receive to stop */
620 while (timeOut--) { 624 while (--timeout) {
621 if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_RS_) 625 if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_RS_)
622 break; 626 break;
623 udelay(10); 627 udelay(10);
624 } 628 }
625 629
626 if (!timeOut) 630 if (!timeout)
627 smsc_warn(IFDOWN, "RX DMAC did not stop! timeout."); 631 smsc_warn(IFDOWN, "RX DMAC did not stop! timeout.");
628 632
629 /* ACK the Rx DMAC stop bit */ 633 /* ACK the Rx DMAC stop bit */
@@ -1378,6 +1382,7 @@ static int smsc9420_open(struct net_device *dev)
1378 1382
1379 /* test the IRQ connection to the ISR */ 1383 /* test the IRQ connection to the ISR */
1380 smsc_dbg(IFUP, "Testing ISR using IRQ %d", dev->irq); 1384 smsc_dbg(IFUP, "Testing ISR using IRQ %d", dev->irq);
1385 pd->software_irq_signal = false;
1381 1386
1382 spin_lock_irqsave(&pd->int_lock, flags); 1387 spin_lock_irqsave(&pd->int_lock, flags);
1383 /* configure interrupt deassertion timer and enable interrupts */ 1388 /* configure interrupt deassertion timer and enable interrupts */
@@ -1393,8 +1398,6 @@ static int smsc9420_open(struct net_device *dev)
1393 smsc9420_pci_flush_write(pd); 1398 smsc9420_pci_flush_write(pd);
1394 1399
1395 timeout = 1000; 1400 timeout = 1000;
1396 pd->software_irq_signal = false;
1397 smp_wmb();
1398 while (timeout--) { 1401 while (timeout--) {
1399 if (pd->software_irq_signal) 1402 if (pd->software_irq_signal)
1400 break; 1403 break;
@@ -1551,6 +1554,7 @@ static const struct net_device_ops smsc9420_netdev_ops = {
1551 .ndo_set_multicast_list = smsc9420_set_multicast_list, 1554 .ndo_set_multicast_list = smsc9420_set_multicast_list,
1552 .ndo_do_ioctl = smsc9420_do_ioctl, 1555 .ndo_do_ioctl = smsc9420_do_ioctl,
1553 .ndo_validate_addr = eth_validate_addr, 1556 .ndo_validate_addr = eth_validate_addr,
1557 .ndo_set_mac_address = eth_mac_addr,
1554#ifdef CONFIG_NET_POLL_CONTROLLER 1558#ifdef CONFIG_NET_POLL_CONTROLLER
1555 .ndo_poll_controller = smsc9420_poll_controller, 1559 .ndo_poll_controller = smsc9420_poll_controller,
1556#endif /* CONFIG_NET_POLL_CONTROLLER */ 1560#endif /* CONFIG_NET_POLL_CONTROLLER */