diff options
author | David Decotigny <decot@google.com> | 2011-04-27 14:32:38 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-29 17:01:30 -0400 |
commit | 8ae6daca85c8bbd6a32c382db5e2a2a989f8bed2 (patch) | |
tree | 0c85476c2af6568c3d3a73a960d582d2f91a1256 /drivers/net/usb/asix.c | |
parent | 36504605432996590f889e33d47e2d9c581f7569 (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/asix.c')
-rw-r--r-- | drivers/net/usb/asix.c | 28 |
1 files changed, 15 insertions, 13 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) | |||
847 | static int ax88172_link_reset(struct usbnet *dev) | 847 | static 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 = { | |||
947 | static int ax88772_link_reset(struct usbnet *dev) | 947 | static 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) | |||
1173 | static int ax88178_link_reset(struct usbnet *dev) | 1173 | static 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 | } |