aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/smsc911x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/smsc911x.c')
-rw-r--r--drivers/net/smsc911x.c65
1 files changed, 27 insertions, 38 deletions
diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index f9cdcbcb77d4..cbf520d38eac 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -41,7 +41,6 @@
41#include <linux/netdevice.h> 41#include <linux/netdevice.h>
42#include <linux/platform_device.h> 42#include <linux/platform_device.h>
43#include <linux/sched.h> 43#include <linux/sched.h>
44#include <linux/slab.h>
45#include <linux/timer.h> 44#include <linux/timer.h>
46#include <linux/bug.h> 45#include <linux/bug.h>
47#include <linux/bitops.h> 46#include <linux/bitops.h>
@@ -748,8 +747,8 @@ static void smsc911x_phy_adjust_link(struct net_device *dev)
748 * usage is 10/100 indicator */ 747 * usage is 10/100 indicator */
749 pdata->gpio_setting = smsc911x_reg_read(pdata, 748 pdata->gpio_setting = smsc911x_reg_read(pdata,
750 GPIO_CFG); 749 GPIO_CFG);
751 if ((pdata->gpio_setting & GPIO_CFG_LED1_EN_) 750 if ((pdata->gpio_setting & GPIO_CFG_LED1_EN_) &&
752 && (!pdata->using_extphy)) { 751 (!pdata->using_extphy)) {
753 /* Force 10/100 LED off, after saving 752 /* Force 10/100 LED off, after saving
754 * orginal GPIO configuration */ 753 * orginal GPIO configuration */
755 pdata->gpio_orig_setting = pdata->gpio_setting; 754 pdata->gpio_orig_setting = pdata->gpio_setting;
@@ -770,29 +769,25 @@ static int smsc911x_mii_probe(struct net_device *dev)
770{ 769{
771 struct smsc911x_data *pdata = netdev_priv(dev); 770 struct smsc911x_data *pdata = netdev_priv(dev);
772 struct phy_device *phydev = NULL; 771 struct phy_device *phydev = NULL;
773 int phy_addr; 772 int ret;
774 773
775 /* find the first phy */ 774 /* find the first phy */
776 for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) { 775 phydev = phy_find_first(pdata->mii_bus);
777 if (pdata->mii_bus->phy_map[phy_addr]) {
778 phydev = pdata->mii_bus->phy_map[phy_addr];
779 SMSC_TRACE(PROBE, "PHY %d: addr %d, phy_id 0x%08X",
780 phy_addr, phydev->addr, phydev->phy_id);
781 break;
782 }
783 }
784
785 if (!phydev) { 776 if (!phydev) {
786 pr_err("%s: no PHY found\n", dev->name); 777 pr_err("%s: no PHY found\n", dev->name);
787 return -ENODEV; 778 return -ENODEV;
788 } 779 }
789 780
790 phydev = phy_connect(dev, dev_name(&phydev->dev), 781 SMSC_TRACE(PROBE, "PHY %d: addr %d, phy_id 0x%08X",
791 &smsc911x_phy_adjust_link, 0, pdata->config.phy_interface); 782 phy_addr, phydev->addr, phydev->phy_id);
783
784 ret = phy_connect_direct(dev, phydev,
785 &smsc911x_phy_adjust_link, 0,
786 pdata->config.phy_interface);
792 787
793 if (IS_ERR(phydev)) { 788 if (ret) {
794 pr_err("%s: Could not attach to PHY\n", dev->name); 789 pr_err("%s: Could not attach to PHY\n", dev->name);
795 return PTR_ERR(phydev); 790 return ret;
796 } 791 }
797 792
798 pr_info("%s: attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n", 793 pr_info("%s: attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
@@ -816,7 +811,7 @@ static int smsc911x_mii_probe(struct net_device *dev)
816 SMSC_TRACE(HW, "Passed Loop Back Test"); 811 SMSC_TRACE(HW, "Passed Loop Back Test");
817#endif /* USE_PHY_WORK_AROUND */ 812#endif /* USE_PHY_WORK_AROUND */
818 813
819 SMSC_TRACE(HW, "phy initialised succesfully"); 814 SMSC_TRACE(HW, "phy initialised successfully");
820 return 0; 815 return 0;
821} 816}
822 817
@@ -1383,33 +1378,24 @@ static void smsc911x_set_multicast_list(struct net_device *dev)
1383 pdata->clear_bits_mask = (MAC_CR_PRMS_ | MAC_CR_HPFILT_); 1378 pdata->clear_bits_mask = (MAC_CR_PRMS_ | MAC_CR_HPFILT_);
1384 pdata->hashhi = 0; 1379 pdata->hashhi = 0;
1385 pdata->hashlo = 0; 1380 pdata->hashlo = 0;
1386 } else if (dev->mc_count > 0) { 1381 } else if (!netdev_mc_empty(dev)) {
1387 /* Enabling specific multicast addresses */ 1382 /* Enabling specific multicast addresses */
1388 unsigned int hash_high = 0; 1383 unsigned int hash_high = 0;
1389 unsigned int hash_low = 0; 1384 unsigned int hash_low = 0;
1390 unsigned int count = 0; 1385 struct dev_mc_list *mc_list;
1391 struct dev_mc_list *mc_list = dev->mc_list;
1392 1386
1393 pdata->set_bits_mask = MAC_CR_HPFILT_; 1387 pdata->set_bits_mask = MAC_CR_HPFILT_;
1394 pdata->clear_bits_mask = (MAC_CR_PRMS_ | MAC_CR_MCPAS_); 1388 pdata->clear_bits_mask = (MAC_CR_PRMS_ | MAC_CR_MCPAS_);
1395 1389
1396 while (mc_list) { 1390 netdev_for_each_mc_addr(mc_list, dev) {
1397 count++; 1391 unsigned int bitnum = smsc911x_hash(mc_list->dmi_addr);
1398 if ((mc_list->dmi_addrlen) == ETH_ALEN) { 1392 unsigned int mask = 0x01 << (bitnum & 0x1F);
1399 unsigned int bitnum = 1393
1400 smsc911x_hash(mc_list->dmi_addr); 1394 if (bitnum & 0x20)
1401 unsigned int mask = 0x01 << (bitnum & 0x1F); 1395 hash_high |= mask;
1402 if (bitnum & 0x20) 1396 else
1403 hash_high |= mask; 1397 hash_low |= mask;
1404 else
1405 hash_low |= mask;
1406 } else {
1407 SMSC_WARNING(DRV, "dmi_addrlen != 6");
1408 }
1409 mc_list = mc_list->next;
1410 } 1398 }
1411 if (count != (unsigned int)dev->mc_count)
1412 SMSC_WARNING(DRV, "mc_count != dev->mc_count");
1413 1399
1414 pdata->hashhi = hash_high; 1400 pdata->hashhi = hash_high;
1415 pdata->hashlo = hash_low; 1401 pdata->hashlo = hash_low;
@@ -2071,6 +2057,9 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
2071 if (is_valid_ether_addr(dev->dev_addr)) { 2057 if (is_valid_ether_addr(dev->dev_addr)) {
2072 smsc911x_set_hw_mac_address(pdata, dev->dev_addr); 2058 smsc911x_set_hw_mac_address(pdata, dev->dev_addr);
2073 SMSC_TRACE(PROBE, "MAC Address is specified by configuration"); 2059 SMSC_TRACE(PROBE, "MAC Address is specified by configuration");
2060 } else if (is_valid_ether_addr(pdata->config.mac)) {
2061 memcpy(dev->dev_addr, pdata->config.mac, 6);
2062 SMSC_TRACE(PROBE, "MAC Address specified by platform data");
2074 } else { 2063 } else {
2075 /* Try reading mac address from device. if EEPROM is present 2064 /* Try reading mac address from device. if EEPROM is present
2076 * it will already have been set */ 2065 * it will already have been set */
@@ -2151,7 +2140,7 @@ static int smsc911x_resume(struct device *dev)
2151 return (to == 0) ? -EIO : 0; 2140 return (to == 0) ? -EIO : 0;
2152} 2141}
2153 2142
2154static struct dev_pm_ops smsc911x_pm_ops = { 2143static const struct dev_pm_ops smsc911x_pm_ops = {
2155 .suspend = smsc911x_suspend, 2144 .suspend = smsc911x_suspend,
2156 .resume = smsc911x_resume, 2145 .resume = smsc911x_resume,
2157}; 2146};