aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorDavid Decotigny <decot@google.com>2011-04-27 14:32:38 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-29 17:01:30 -0400
commit8ae6daca85c8bbd6a32c382db5e2a2a989f8bed2 (patch)
tree0c85476c2af6568c3d3a73a960d582d2f91a1256 /drivers/net/usb
parent36504605432996590f889e33d47e2d9c581f7569 (diff)
ethtool: Call ethtool's get/set_settings callbacks with cleaned data
This makes sure that when a driver calls the ethtool's get/set_settings() callback of another driver, the data passed to it is clean. This guarantees that speed_hi will be zeroed correctly if the called callback doesn't explicitely set it: we are sure we don't get a corrupted speed from the underlying driver. We also take care of setting the cmd field appropriately (ETHTOOL_GSET/SSET). This applies to dev_ethtool_get_settings(), which now makes sure it sets up that ethtool command parameter correctly before passing it to drivers. This also means that whoever calls dev_ethtool_get_settings() does not have to clean the ethtool command parameter. This function also becomes an exported symbol instead of an inline. All drivers visible to make allyesconfig under x86_64 have been updated. Signed-off-by: David Decotigny <decot@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/asix.c28
-rw-r--r--drivers/net/usb/dm9601.c6
-rw-r--r--drivers/net/usb/smsc75xx.c7
-rw-r--r--drivers/net/usb/smsc95xx.c7
4 files changed, 26 insertions, 22 deletions
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 6140b56cce53..6998aa6b7bb7 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -847,7 +847,7 @@ static void ax88172_set_multicast(struct net_device *net)
847static int ax88172_link_reset(struct usbnet *dev) 847static int ax88172_link_reset(struct usbnet *dev)
848{ 848{
849 u8 mode; 849 u8 mode;
850 struct ethtool_cmd ecmd; 850 struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
851 851
852 mii_check_media(&dev->mii, 1, 1); 852 mii_check_media(&dev->mii, 1, 1);
853 mii_ethtool_gset(&dev->mii, &ecmd); 853 mii_ethtool_gset(&dev->mii, &ecmd);
@@ -856,8 +856,8 @@ static int ax88172_link_reset(struct usbnet *dev)
856 if (ecmd.duplex != DUPLEX_FULL) 856 if (ecmd.duplex != DUPLEX_FULL)
857 mode |= ~AX88172_MEDIUM_FD; 857 mode |= ~AX88172_MEDIUM_FD;
858 858
859 netdev_dbg(dev->net, "ax88172_link_reset() speed: %d duplex: %d setting mode to 0x%04x\n", 859 netdev_dbg(dev->net, "ax88172_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n",
860 ecmd.speed, ecmd.duplex, mode); 860 ethtool_cmd_speed(&ecmd), ecmd.duplex, mode);
861 861
862 asix_write_medium_mode(dev, mode); 862 asix_write_medium_mode(dev, mode);
863 863
@@ -947,20 +947,20 @@ static const struct ethtool_ops ax88772_ethtool_ops = {
947static int ax88772_link_reset(struct usbnet *dev) 947static int ax88772_link_reset(struct usbnet *dev)
948{ 948{
949 u16 mode; 949 u16 mode;
950 struct ethtool_cmd ecmd; 950 struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
951 951
952 mii_check_media(&dev->mii, 1, 1); 952 mii_check_media(&dev->mii, 1, 1);
953 mii_ethtool_gset(&dev->mii, &ecmd); 953 mii_ethtool_gset(&dev->mii, &ecmd);
954 mode = AX88772_MEDIUM_DEFAULT; 954 mode = AX88772_MEDIUM_DEFAULT;
955 955
956 if (ecmd.speed != SPEED_100) 956 if (ethtool_cmd_speed(&ecmd) != SPEED_100)
957 mode &= ~AX_MEDIUM_PS; 957 mode &= ~AX_MEDIUM_PS;
958 958
959 if (ecmd.duplex != DUPLEX_FULL) 959 if (ecmd.duplex != DUPLEX_FULL)
960 mode &= ~AX_MEDIUM_FD; 960 mode &= ~AX_MEDIUM_FD;
961 961
962 netdev_dbg(dev->net, "ax88772_link_reset() speed: %d duplex: %d setting mode to 0x%04x\n", 962 netdev_dbg(dev->net, "ax88772_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n",
963 ecmd.speed, ecmd.duplex, mode); 963 ethtool_cmd_speed(&ecmd), ecmd.duplex, mode);
964 964
965 asix_write_medium_mode(dev, mode); 965 asix_write_medium_mode(dev, mode);
966 966
@@ -1173,18 +1173,20 @@ static int marvell_led_status(struct usbnet *dev, u16 speed)
1173static int ax88178_link_reset(struct usbnet *dev) 1173static int ax88178_link_reset(struct usbnet *dev)
1174{ 1174{
1175 u16 mode; 1175 u16 mode;
1176 struct ethtool_cmd ecmd; 1176 struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
1177 struct asix_data *data = (struct asix_data *)&dev->data; 1177 struct asix_data *data = (struct asix_data *)&dev->data;
1178 u32 speed;
1178 1179
1179 netdev_dbg(dev->net, "ax88178_link_reset()\n"); 1180 netdev_dbg(dev->net, "ax88178_link_reset()\n");
1180 1181
1181 mii_check_media(&dev->mii, 1, 1); 1182 mii_check_media(&dev->mii, 1, 1);
1182 mii_ethtool_gset(&dev->mii, &ecmd); 1183 mii_ethtool_gset(&dev->mii, &ecmd);
1183 mode = AX88178_MEDIUM_DEFAULT; 1184 mode = AX88178_MEDIUM_DEFAULT;
1185 speed = ethtool_cmd_speed(&ecmd);
1184 1186
1185 if (ecmd.speed == SPEED_1000) 1187 if (speed == SPEED_1000)
1186 mode |= AX_MEDIUM_GM; 1188 mode |= AX_MEDIUM_GM;
1187 else if (ecmd.speed == SPEED_100) 1189 else if (speed == SPEED_100)
1188 mode |= AX_MEDIUM_PS; 1190 mode |= AX_MEDIUM_PS;
1189 else 1191 else
1190 mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM); 1192 mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM);
@@ -1196,13 +1198,13 @@ static int ax88178_link_reset(struct usbnet *dev)
1196 else 1198 else
1197 mode &= ~AX_MEDIUM_FD; 1199 mode &= ~AX_MEDIUM_FD;
1198 1200
1199 netdev_dbg(dev->net, "ax88178_link_reset() speed: %d duplex: %d setting mode to 0x%04x\n", 1201 netdev_dbg(dev->net, "ax88178_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n",
1200 ecmd.speed, ecmd.duplex, mode); 1202 speed, ecmd.duplex, mode);
1201 1203
1202 asix_write_medium_mode(dev, mode); 1204 asix_write_medium_mode(dev, mode);
1203 1205
1204 if (data->phymode == PHY_MODE_MARVELL && data->ledmode) 1206 if (data->phymode == PHY_MODE_MARVELL && data->ledmode)
1205 marvell_led_status(dev, ecmd.speed); 1207 marvell_led_status(dev, speed);
1206 1208
1207 return 0; 1209 return 0;
1208} 1210}
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 5002f5be47be..1d93133e9b74 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -599,13 +599,13 @@ static void dm9601_status(struct usbnet *dev, struct urb *urb)
599 599
600static int dm9601_link_reset(struct usbnet *dev) 600static int dm9601_link_reset(struct usbnet *dev)
601{ 601{
602 struct ethtool_cmd ecmd; 602 struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
603 603
604 mii_check_media(&dev->mii, 1, 1); 604 mii_check_media(&dev->mii, 1, 1);
605 mii_ethtool_gset(&dev->mii, &ecmd); 605 mii_ethtool_gset(&dev->mii, &ecmd);
606 606
607 netdev_dbg(dev->net, "link_reset() speed: %d duplex: %d\n", 607 netdev_dbg(dev->net, "link_reset() speed: %u duplex: %d\n",
608 ecmd.speed, ecmd.duplex); 608 ethtool_cmd_speed(&ecmd), ecmd.duplex);
609 609
610 return 0; 610 return 0;
611} 611}
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 860a20c938b4..15b3d6888ae9 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -503,7 +503,7 @@ static int smsc75xx_update_flowcontrol(struct usbnet *dev, u8 duplex,
503static int smsc75xx_link_reset(struct usbnet *dev) 503static int smsc75xx_link_reset(struct usbnet *dev)
504{ 504{
505 struct mii_if_info *mii = &dev->mii; 505 struct mii_if_info *mii = &dev->mii;
506 struct ethtool_cmd ecmd; 506 struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
507 u16 lcladv, rmtadv; 507 u16 lcladv, rmtadv;
508 int ret; 508 int ret;
509 509
@@ -519,8 +519,9 @@ static int smsc75xx_link_reset(struct usbnet *dev)
519 lcladv = smsc75xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE); 519 lcladv = smsc75xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE);
520 rmtadv = smsc75xx_mdio_read(dev->net, mii->phy_id, MII_LPA); 520 rmtadv = smsc75xx_mdio_read(dev->net, mii->phy_id, MII_LPA);
521 521
522 netif_dbg(dev, link, dev->net, "speed: %d duplex: %d lcladv: %04x" 522 netif_dbg(dev, link, dev->net, "speed: %u duplex: %d lcladv: %04x"
523 " rmtadv: %04x", ecmd.speed, ecmd.duplex, lcladv, rmtadv); 523 " rmtadv: %04x", ethtool_cmd_speed(&ecmd),
524 ecmd.duplex, lcladv, rmtadv);
524 525
525 return smsc75xx_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv); 526 return smsc75xx_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv);
526} 527}
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 24f4b3739dd2..b374a9997908 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -457,7 +457,7 @@ static int smsc95xx_link_reset(struct usbnet *dev)
457{ 457{
458 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); 458 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
459 struct mii_if_info *mii = &dev->mii; 459 struct mii_if_info *mii = &dev->mii;
460 struct ethtool_cmd ecmd; 460 struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
461 unsigned long flags; 461 unsigned long flags;
462 u16 lcladv, rmtadv; 462 u16 lcladv, rmtadv;
463 u32 intdata; 463 u32 intdata;
@@ -472,8 +472,9 @@ static int smsc95xx_link_reset(struct usbnet *dev)
472 lcladv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE); 472 lcladv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE);
473 rmtadv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_LPA); 473 rmtadv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_LPA);
474 474
475 netif_dbg(dev, link, dev->net, "speed: %d duplex: %d lcladv: %04x rmtadv: %04x\n", 475 netif_dbg(dev, link, dev->net,
476 ecmd.speed, ecmd.duplex, lcladv, rmtadv); 476 "speed: %u duplex: %d lcladv: %04x rmtadv: %04x\n",
477 ethtool_cmd_speed(&ecmd), ecmd.duplex, lcladv, rmtadv);
477 478
478 spin_lock_irqsave(&pdata->mac_cr_lock, flags); 479 spin_lock_irqsave(&pdata->mac_cr_lock, flags);
479 if (ecmd.duplex != DUPLEX_FULL) { 480 if (ecmd.duplex != DUPLEX_FULL) {