diff options
author | John W. Linville <linville@tuxdriver.com> | 2008-10-31 14:13:12 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-11-21 11:06:02 -0500 |
commit | 3d29b0c33d431ecc69ec778f8c236d382f59a85f (patch) | |
tree | b11d062b298f72d76234259bc54e925439b5c2cf /drivers/net/wireless/zd1201.c | |
parent | 9d2f4720971c00852a3fc8278a76f1a5e9add5c7 (diff) |
netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv()
We have some reasons to kill netdev->priv:
1. netdev->priv is equal to netdev_priv().
2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
netdev_priv() is more flexible than netdev->priv.
But we cann't kill netdev->priv, because so many drivers reference to it
directly.
OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
and I want to kill netdev->priv later, I decided to convert all the direct
reference of netdev->priv first.
(Original patch posted by Wang Chen <wangchen@cn.fujitsu.com> w/ above
changelog but using dev->ml_priv. That doesn't seem appropriate
to me for this driver, so I've revamped it to use netdev_priv()
instead. -- JWL)
Reviewed-by: Wang Chen <wangchen@cn.fujitsu.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/zd1201.c')
-rw-r--r-- | drivers/net/wireless/zd1201.c | 115 |
1 files changed, 56 insertions, 59 deletions
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c index 1134e2fb1890..3404807b3e12 100644 --- a/drivers/net/wireless/zd1201.c +++ b/drivers/net/wireless/zd1201.c | |||
@@ -743,7 +743,7 @@ static int zd1201_join(struct zd1201 *zd, char *essid, int essidlen) | |||
743 | 743 | ||
744 | static int zd1201_net_open(struct net_device *dev) | 744 | static int zd1201_net_open(struct net_device *dev) |
745 | { | 745 | { |
746 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 746 | struct zd1201 *zd = netdev_priv(dev); |
747 | 747 | ||
748 | /* Start MAC with wildcard if no essid set */ | 748 | /* Start MAC with wildcard if no essid set */ |
749 | if (!zd->mac_enabled) | 749 | if (!zd->mac_enabled) |
@@ -781,7 +781,7 @@ static int zd1201_net_stop(struct net_device *dev) | |||
781 | */ | 781 | */ |
782 | static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | 782 | static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) |
783 | { | 783 | { |
784 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 784 | struct zd1201 *zd = netdev_priv(dev); |
785 | unsigned char *txbuf = zd->txdata; | 785 | unsigned char *txbuf = zd->txdata; |
786 | int txbuflen, pad = 0, err; | 786 | int txbuflen, pad = 0, err; |
787 | struct urb *urb = zd->tx_urb; | 787 | struct urb *urb = zd->tx_urb; |
@@ -831,7 +831,7 @@ static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
831 | 831 | ||
832 | static void zd1201_tx_timeout(struct net_device *dev) | 832 | static void zd1201_tx_timeout(struct net_device *dev) |
833 | { | 833 | { |
834 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 834 | struct zd1201 *zd = netdev_priv(dev); |
835 | 835 | ||
836 | if (!zd) | 836 | if (!zd) |
837 | return; | 837 | return; |
@@ -846,7 +846,7 @@ static void zd1201_tx_timeout(struct net_device *dev) | |||
846 | static int zd1201_set_mac_address(struct net_device *dev, void *p) | 846 | static int zd1201_set_mac_address(struct net_device *dev, void *p) |
847 | { | 847 | { |
848 | struct sockaddr *addr = p; | 848 | struct sockaddr *addr = p; |
849 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 849 | struct zd1201 *zd = netdev_priv(dev); |
850 | int err; | 850 | int err; |
851 | 851 | ||
852 | if (!zd) | 852 | if (!zd) |
@@ -863,21 +863,21 @@ static int zd1201_set_mac_address(struct net_device *dev, void *p) | |||
863 | 863 | ||
864 | static struct net_device_stats *zd1201_get_stats(struct net_device *dev) | 864 | static struct net_device_stats *zd1201_get_stats(struct net_device *dev) |
865 | { | 865 | { |
866 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 866 | struct zd1201 *zd = netdev_priv(dev); |
867 | 867 | ||
868 | return &zd->stats; | 868 | return &zd->stats; |
869 | } | 869 | } |
870 | 870 | ||
871 | static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev) | 871 | static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev) |
872 | { | 872 | { |
873 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 873 | struct zd1201 *zd = netdev_priv(dev); |
874 | 874 | ||
875 | return &zd->iwstats; | 875 | return &zd->iwstats; |
876 | } | 876 | } |
877 | 877 | ||
878 | static void zd1201_set_multicast(struct net_device *dev) | 878 | static void zd1201_set_multicast(struct net_device *dev) |
879 | { | 879 | { |
880 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 880 | struct zd1201 *zd = netdev_priv(dev); |
881 | struct dev_mc_list *mc = dev->mc_list; | 881 | struct dev_mc_list *mc = dev->mc_list; |
882 | unsigned char reqbuf[ETH_ALEN*ZD1201_MAXMULTI]; | 882 | unsigned char reqbuf[ETH_ALEN*ZD1201_MAXMULTI]; |
883 | int i; | 883 | int i; |
@@ -897,7 +897,7 @@ static void zd1201_set_multicast(struct net_device *dev) | |||
897 | static int zd1201_config_commit(struct net_device *dev, | 897 | static int zd1201_config_commit(struct net_device *dev, |
898 | struct iw_request_info *info, struct iw_point *data, char *essid) | 898 | struct iw_request_info *info, struct iw_point *data, char *essid) |
899 | { | 899 | { |
900 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 900 | struct zd1201 *zd = netdev_priv(dev); |
901 | 901 | ||
902 | return zd1201_mac_reset(zd); | 902 | return zd1201_mac_reset(zd); |
903 | } | 903 | } |
@@ -912,7 +912,7 @@ static int zd1201_get_name(struct net_device *dev, | |||
912 | static int zd1201_set_freq(struct net_device *dev, | 912 | static int zd1201_set_freq(struct net_device *dev, |
913 | struct iw_request_info *info, struct iw_freq *freq, char *extra) | 913 | struct iw_request_info *info, struct iw_freq *freq, char *extra) |
914 | { | 914 | { |
915 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 915 | struct zd1201 *zd = netdev_priv(dev); |
916 | short channel = 0; | 916 | short channel = 0; |
917 | int err; | 917 | int err; |
918 | 918 | ||
@@ -937,7 +937,7 @@ static int zd1201_set_freq(struct net_device *dev, | |||
937 | static int zd1201_get_freq(struct net_device *dev, | 937 | static int zd1201_get_freq(struct net_device *dev, |
938 | struct iw_request_info *info, struct iw_freq *freq, char *extra) | 938 | struct iw_request_info *info, struct iw_freq *freq, char *extra) |
939 | { | 939 | { |
940 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 940 | struct zd1201 *zd = netdev_priv(dev); |
941 | short channel; | 941 | short channel; |
942 | int err; | 942 | int err; |
943 | 943 | ||
@@ -953,7 +953,7 @@ static int zd1201_get_freq(struct net_device *dev, | |||
953 | static int zd1201_set_mode(struct net_device *dev, | 953 | static int zd1201_set_mode(struct net_device *dev, |
954 | struct iw_request_info *info, __u32 *mode, char *extra) | 954 | struct iw_request_info *info, __u32 *mode, char *extra) |
955 | { | 955 | { |
956 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 956 | struct zd1201 *zd = netdev_priv(dev); |
957 | short porttype, monitor = 0; | 957 | short porttype, monitor = 0; |
958 | unsigned char buffer[IW_ESSID_MAX_SIZE+2]; | 958 | unsigned char buffer[IW_ESSID_MAX_SIZE+2]; |
959 | int err; | 959 | int err; |
@@ -1015,7 +1015,7 @@ static int zd1201_set_mode(struct net_device *dev, | |||
1015 | static int zd1201_get_mode(struct net_device *dev, | 1015 | static int zd1201_get_mode(struct net_device *dev, |
1016 | struct iw_request_info *info, __u32 *mode, char *extra) | 1016 | struct iw_request_info *info, __u32 *mode, char *extra) |
1017 | { | 1017 | { |
1018 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1018 | struct zd1201 *zd = netdev_priv(dev); |
1019 | short porttype; | 1019 | short porttype; |
1020 | int err; | 1020 | int err; |
1021 | 1021 | ||
@@ -1091,7 +1091,7 @@ static int zd1201_get_range(struct net_device *dev, | |||
1091 | static int zd1201_get_wap(struct net_device *dev, | 1091 | static int zd1201_get_wap(struct net_device *dev, |
1092 | struct iw_request_info *info, struct sockaddr *ap_addr, char *extra) | 1092 | struct iw_request_info *info, struct sockaddr *ap_addr, char *extra) |
1093 | { | 1093 | { |
1094 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1094 | struct zd1201 *zd = netdev_priv(dev); |
1095 | unsigned char buffer[6]; | 1095 | unsigned char buffer[6]; |
1096 | 1096 | ||
1097 | if (!zd1201_getconfig(zd, ZD1201_RID_COMMSQUALITY, buffer, 6)) { | 1097 | if (!zd1201_getconfig(zd, ZD1201_RID_COMMSQUALITY, buffer, 6)) { |
@@ -1119,7 +1119,7 @@ static int zd1201_set_scan(struct net_device *dev, | |||
1119 | static int zd1201_get_scan(struct net_device *dev, | 1119 | static int zd1201_get_scan(struct net_device *dev, |
1120 | struct iw_request_info *info, struct iw_point *srq, char *extra) | 1120 | struct iw_request_info *info, struct iw_point *srq, char *extra) |
1121 | { | 1121 | { |
1122 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1122 | struct zd1201 *zd = netdev_priv(dev); |
1123 | int err, i, j, enabled_save; | 1123 | int err, i, j, enabled_save; |
1124 | struct iw_event iwe; | 1124 | struct iw_event iwe; |
1125 | char *cev = extra; | 1125 | char *cev = extra; |
@@ -1211,7 +1211,7 @@ static int zd1201_get_scan(struct net_device *dev, | |||
1211 | static int zd1201_set_essid(struct net_device *dev, | 1211 | static int zd1201_set_essid(struct net_device *dev, |
1212 | struct iw_request_info *info, struct iw_point *data, char *essid) | 1212 | struct iw_request_info *info, struct iw_point *data, char *essid) |
1213 | { | 1213 | { |
1214 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1214 | struct zd1201 *zd = netdev_priv(dev); |
1215 | 1215 | ||
1216 | if (data->length > IW_ESSID_MAX_SIZE) | 1216 | if (data->length > IW_ESSID_MAX_SIZE) |
1217 | return -EINVAL; | 1217 | return -EINVAL; |
@@ -1226,7 +1226,7 @@ static int zd1201_set_essid(struct net_device *dev, | |||
1226 | static int zd1201_get_essid(struct net_device *dev, | 1226 | static int zd1201_get_essid(struct net_device *dev, |
1227 | struct iw_request_info *info, struct iw_point *data, char *essid) | 1227 | struct iw_request_info *info, struct iw_point *data, char *essid) |
1228 | { | 1228 | { |
1229 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1229 | struct zd1201 *zd = netdev_priv(dev); |
1230 | 1230 | ||
1231 | memcpy(essid, zd->essid, zd->essidlen); | 1231 | memcpy(essid, zd->essid, zd->essidlen); |
1232 | data->flags = 1; | 1232 | data->flags = 1; |
@@ -1247,7 +1247,7 @@ static int zd1201_get_nick(struct net_device *dev, struct iw_request_info *info, | |||
1247 | static int zd1201_set_rate(struct net_device *dev, | 1247 | static int zd1201_set_rate(struct net_device *dev, |
1248 | struct iw_request_info *info, struct iw_param *rrq, char *extra) | 1248 | struct iw_request_info *info, struct iw_param *rrq, char *extra) |
1249 | { | 1249 | { |
1250 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1250 | struct zd1201 *zd = netdev_priv(dev); |
1251 | short rate; | 1251 | short rate; |
1252 | int err; | 1252 | int err; |
1253 | 1253 | ||
@@ -1280,7 +1280,7 @@ static int zd1201_set_rate(struct net_device *dev, | |||
1280 | static int zd1201_get_rate(struct net_device *dev, | 1280 | static int zd1201_get_rate(struct net_device *dev, |
1281 | struct iw_request_info *info, struct iw_param *rrq, char *extra) | 1281 | struct iw_request_info *info, struct iw_param *rrq, char *extra) |
1282 | { | 1282 | { |
1283 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1283 | struct zd1201 *zd = netdev_priv(dev); |
1284 | short rate; | 1284 | short rate; |
1285 | int err; | 1285 | int err; |
1286 | 1286 | ||
@@ -1313,7 +1313,7 @@ static int zd1201_get_rate(struct net_device *dev, | |||
1313 | static int zd1201_set_rts(struct net_device *dev, struct iw_request_info *info, | 1313 | static int zd1201_set_rts(struct net_device *dev, struct iw_request_info *info, |
1314 | struct iw_param *rts, char *extra) | 1314 | struct iw_param *rts, char *extra) |
1315 | { | 1315 | { |
1316 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1316 | struct zd1201 *zd = netdev_priv(dev); |
1317 | int err; | 1317 | int err; |
1318 | short val = rts->value; | 1318 | short val = rts->value; |
1319 | 1319 | ||
@@ -1333,7 +1333,7 @@ static int zd1201_set_rts(struct net_device *dev, struct iw_request_info *info, | |||
1333 | static int zd1201_get_rts(struct net_device *dev, struct iw_request_info *info, | 1333 | static int zd1201_get_rts(struct net_device *dev, struct iw_request_info *info, |
1334 | struct iw_param *rts, char *extra) | 1334 | struct iw_param *rts, char *extra) |
1335 | { | 1335 | { |
1336 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1336 | struct zd1201 *zd = netdev_priv(dev); |
1337 | short rtst; | 1337 | short rtst; |
1338 | int err; | 1338 | int err; |
1339 | 1339 | ||
@@ -1350,7 +1350,7 @@ static int zd1201_get_rts(struct net_device *dev, struct iw_request_info *info, | |||
1350 | static int zd1201_set_frag(struct net_device *dev, struct iw_request_info *info, | 1350 | static int zd1201_set_frag(struct net_device *dev, struct iw_request_info *info, |
1351 | struct iw_param *frag, char *extra) | 1351 | struct iw_param *frag, char *extra) |
1352 | { | 1352 | { |
1353 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1353 | struct zd1201 *zd = netdev_priv(dev); |
1354 | int err; | 1354 | int err; |
1355 | short val = frag->value; | 1355 | short val = frag->value; |
1356 | 1356 | ||
@@ -1371,7 +1371,7 @@ static int zd1201_set_frag(struct net_device *dev, struct iw_request_info *info, | |||
1371 | static int zd1201_get_frag(struct net_device *dev, struct iw_request_info *info, | 1371 | static int zd1201_get_frag(struct net_device *dev, struct iw_request_info *info, |
1372 | struct iw_param *frag, char *extra) | 1372 | struct iw_param *frag, char *extra) |
1373 | { | 1373 | { |
1374 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1374 | struct zd1201 *zd = netdev_priv(dev); |
1375 | short fragt; | 1375 | short fragt; |
1376 | int err; | 1376 | int err; |
1377 | 1377 | ||
@@ -1400,7 +1400,7 @@ static int zd1201_get_retry(struct net_device *dev, | |||
1400 | static int zd1201_set_encode(struct net_device *dev, | 1400 | static int zd1201_set_encode(struct net_device *dev, |
1401 | struct iw_request_info *info, struct iw_point *erq, char *key) | 1401 | struct iw_request_info *info, struct iw_point *erq, char *key) |
1402 | { | 1402 | { |
1403 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1403 | struct zd1201 *zd = netdev_priv(dev); |
1404 | short i; | 1404 | short i; |
1405 | int err, rid; | 1405 | int err, rid; |
1406 | 1406 | ||
@@ -1457,7 +1457,7 @@ static int zd1201_set_encode(struct net_device *dev, | |||
1457 | static int zd1201_get_encode(struct net_device *dev, | 1457 | static int zd1201_get_encode(struct net_device *dev, |
1458 | struct iw_request_info *info, struct iw_point *erq, char *key) | 1458 | struct iw_request_info *info, struct iw_point *erq, char *key) |
1459 | { | 1459 | { |
1460 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1460 | struct zd1201 *zd = netdev_priv(dev); |
1461 | short i; | 1461 | short i; |
1462 | int err; | 1462 | int err; |
1463 | 1463 | ||
@@ -1490,7 +1490,7 @@ static int zd1201_get_encode(struct net_device *dev, | |||
1490 | static int zd1201_set_power(struct net_device *dev, | 1490 | static int zd1201_set_power(struct net_device *dev, |
1491 | struct iw_request_info *info, struct iw_param *vwrq, char *extra) | 1491 | struct iw_request_info *info, struct iw_param *vwrq, char *extra) |
1492 | { | 1492 | { |
1493 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1493 | struct zd1201 *zd = netdev_priv(dev); |
1494 | short enabled, duration, level; | 1494 | short enabled, duration, level; |
1495 | int err; | 1495 | int err; |
1496 | 1496 | ||
@@ -1529,7 +1529,7 @@ out: | |||
1529 | static int zd1201_get_power(struct net_device *dev, | 1529 | static int zd1201_get_power(struct net_device *dev, |
1530 | struct iw_request_info *info, struct iw_param *vwrq, char *extra) | 1530 | struct iw_request_info *info, struct iw_param *vwrq, char *extra) |
1531 | { | 1531 | { |
1532 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1532 | struct zd1201 *zd = netdev_priv(dev); |
1533 | short enabled, level, duration; | 1533 | short enabled, level, duration; |
1534 | int err; | 1534 | int err; |
1535 | 1535 | ||
@@ -1616,7 +1616,7 @@ static const iw_handler zd1201_iw_handler[] = | |||
1616 | static int zd1201_set_hostauth(struct net_device *dev, | 1616 | static int zd1201_set_hostauth(struct net_device *dev, |
1617 | struct iw_request_info *info, struct iw_param *rrq, char *extra) | 1617 | struct iw_request_info *info, struct iw_param *rrq, char *extra) |
1618 | { | 1618 | { |
1619 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1619 | struct zd1201 *zd = netdev_priv(dev); |
1620 | 1620 | ||
1621 | if (!zd->ap) | 1621 | if (!zd->ap) |
1622 | return -EOPNOTSUPP; | 1622 | return -EOPNOTSUPP; |
@@ -1627,7 +1627,7 @@ static int zd1201_set_hostauth(struct net_device *dev, | |||
1627 | static int zd1201_get_hostauth(struct net_device *dev, | 1627 | static int zd1201_get_hostauth(struct net_device *dev, |
1628 | struct iw_request_info *info, struct iw_param *rrq, char *extra) | 1628 | struct iw_request_info *info, struct iw_param *rrq, char *extra) |
1629 | { | 1629 | { |
1630 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1630 | struct zd1201 *zd = netdev_priv(dev); |
1631 | short hostauth; | 1631 | short hostauth; |
1632 | int err; | 1632 | int err; |
1633 | 1633 | ||
@@ -1646,7 +1646,7 @@ static int zd1201_get_hostauth(struct net_device *dev, | |||
1646 | static int zd1201_auth_sta(struct net_device *dev, | 1646 | static int zd1201_auth_sta(struct net_device *dev, |
1647 | struct iw_request_info *info, struct sockaddr *sta, char *extra) | 1647 | struct iw_request_info *info, struct sockaddr *sta, char *extra) |
1648 | { | 1648 | { |
1649 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1649 | struct zd1201 *zd = netdev_priv(dev); |
1650 | unsigned char buffer[10]; | 1650 | unsigned char buffer[10]; |
1651 | 1651 | ||
1652 | if (!zd->ap) | 1652 | if (!zd->ap) |
@@ -1662,7 +1662,7 @@ static int zd1201_auth_sta(struct net_device *dev, | |||
1662 | static int zd1201_set_maxassoc(struct net_device *dev, | 1662 | static int zd1201_set_maxassoc(struct net_device *dev, |
1663 | struct iw_request_info *info, struct iw_param *rrq, char *extra) | 1663 | struct iw_request_info *info, struct iw_param *rrq, char *extra) |
1664 | { | 1664 | { |
1665 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1665 | struct zd1201 *zd = netdev_priv(dev); |
1666 | int err; | 1666 | int err; |
1667 | 1667 | ||
1668 | if (!zd->ap) | 1668 | if (!zd->ap) |
@@ -1677,7 +1677,7 @@ static int zd1201_set_maxassoc(struct net_device *dev, | |||
1677 | static int zd1201_get_maxassoc(struct net_device *dev, | 1677 | static int zd1201_get_maxassoc(struct net_device *dev, |
1678 | struct iw_request_info *info, struct iw_param *rrq, char *extra) | 1678 | struct iw_request_info *info, struct iw_param *rrq, char *extra) |
1679 | { | 1679 | { |
1680 | struct zd1201 *zd = (struct zd1201 *)dev->priv; | 1680 | struct zd1201 *zd = netdev_priv(dev); |
1681 | short maxassoc; | 1681 | short maxassoc; |
1682 | int err; | 1682 | int err; |
1683 | 1683 | ||
@@ -1729,6 +1729,7 @@ static int zd1201_probe(struct usb_interface *interface, | |||
1729 | const struct usb_device_id *id) | 1729 | const struct usb_device_id *id) |
1730 | { | 1730 | { |
1731 | struct zd1201 *zd; | 1731 | struct zd1201 *zd; |
1732 | struct net_device *dev; | ||
1732 | struct usb_device *usb; | 1733 | struct usb_device *usb; |
1733 | int err; | 1734 | int err; |
1734 | short porttype; | 1735 | short porttype; |
@@ -1736,9 +1737,12 @@ static int zd1201_probe(struct usb_interface *interface, | |||
1736 | 1737 | ||
1737 | usb = interface_to_usbdev(interface); | 1738 | usb = interface_to_usbdev(interface); |
1738 | 1739 | ||
1739 | zd = kzalloc(sizeof(struct zd1201), GFP_KERNEL); | 1740 | dev = alloc_etherdev(sizeof(*zd)); |
1740 | if (!zd) | 1741 | if (!dev) |
1741 | return -ENOMEM; | 1742 | return -ENOMEM; |
1743 | zd = netdev_priv(dev); | ||
1744 | zd->dev = dev; | ||
1745 | |||
1742 | zd->ap = ap; | 1746 | zd->ap = ap; |
1743 | zd->usb = usb; | 1747 | zd->usb = usb; |
1744 | zd->removed = 0; | 1748 | zd->removed = 0; |
@@ -1773,34 +1777,29 @@ static int zd1201_probe(struct usb_interface *interface, | |||
1773 | if (err) | 1777 | if (err) |
1774 | goto err_start; | 1778 | goto err_start; |
1775 | 1779 | ||
1776 | zd->dev = alloc_etherdev(0); | 1780 | dev->open = zd1201_net_open; |
1777 | if (!zd->dev) | 1781 | dev->stop = zd1201_net_stop; |
1778 | goto err_start; | 1782 | dev->get_stats = zd1201_get_stats; |
1779 | 1783 | dev->wireless_handlers = | |
1780 | zd->dev->priv = zd; | ||
1781 | zd->dev->open = zd1201_net_open; | ||
1782 | zd->dev->stop = zd1201_net_stop; | ||
1783 | zd->dev->get_stats = zd1201_get_stats; | ||
1784 | zd->dev->wireless_handlers = | ||
1785 | (struct iw_handler_def *)&zd1201_iw_handlers; | 1784 | (struct iw_handler_def *)&zd1201_iw_handlers; |
1786 | zd->dev->hard_start_xmit = zd1201_hard_start_xmit; | 1785 | dev->hard_start_xmit = zd1201_hard_start_xmit; |
1787 | zd->dev->watchdog_timeo = ZD1201_TX_TIMEOUT; | 1786 | dev->watchdog_timeo = ZD1201_TX_TIMEOUT; |
1788 | zd->dev->tx_timeout = zd1201_tx_timeout; | 1787 | dev->tx_timeout = zd1201_tx_timeout; |
1789 | zd->dev->set_multicast_list = zd1201_set_multicast; | 1788 | dev->set_multicast_list = zd1201_set_multicast; |
1790 | zd->dev->set_mac_address = zd1201_set_mac_address; | 1789 | dev->set_mac_address = zd1201_set_mac_address; |
1791 | strcpy(zd->dev->name, "wlan%d"); | 1790 | strcpy(dev->name, "wlan%d"); |
1792 | 1791 | ||
1793 | err = zd1201_getconfig(zd, ZD1201_RID_CNFOWNMACADDR, | 1792 | err = zd1201_getconfig(zd, ZD1201_RID_CNFOWNMACADDR, |
1794 | zd->dev->dev_addr, zd->dev->addr_len); | 1793 | dev->dev_addr, dev->addr_len); |
1795 | if (err) | 1794 | if (err) |
1796 | goto err_net; | 1795 | goto err_start; |
1797 | 1796 | ||
1798 | /* Set wildcard essid to match zd->essid */ | 1797 | /* Set wildcard essid to match zd->essid */ |
1799 | *(__le16 *)buf = cpu_to_le16(0); | 1798 | *(__le16 *)buf = cpu_to_le16(0); |
1800 | err = zd1201_setconfig(zd, ZD1201_RID_CNFDESIREDSSID, buf, | 1799 | err = zd1201_setconfig(zd, ZD1201_RID_CNFDESIREDSSID, buf, |
1801 | IW_ESSID_MAX_SIZE+2, 1); | 1800 | IW_ESSID_MAX_SIZE+2, 1); |
1802 | if (err) | 1801 | if (err) |
1803 | goto err_net; | 1802 | goto err_start; |
1804 | 1803 | ||
1805 | if (zd->ap) | 1804 | if (zd->ap) |
1806 | porttype = ZD1201_PORTTYPE_AP; | 1805 | porttype = ZD1201_PORTTYPE_AP; |
@@ -1808,30 +1807,28 @@ static int zd1201_probe(struct usb_interface *interface, | |||
1808 | porttype = ZD1201_PORTTYPE_BSS; | 1807 | porttype = ZD1201_PORTTYPE_BSS; |
1809 | err = zd1201_setconfig16(zd, ZD1201_RID_CNFPORTTYPE, porttype); | 1808 | err = zd1201_setconfig16(zd, ZD1201_RID_CNFPORTTYPE, porttype); |
1810 | if (err) | 1809 | if (err) |
1811 | goto err_net; | 1810 | goto err_start; |
1812 | 1811 | ||
1813 | SET_NETDEV_DEV(zd->dev, &usb->dev); | 1812 | SET_NETDEV_DEV(dev, &usb->dev); |
1814 | 1813 | ||
1815 | err = register_netdev(zd->dev); | 1814 | err = register_netdev(dev); |
1816 | if (err) | 1815 | if (err) |
1817 | goto err_net; | 1816 | goto err_start; |
1818 | dev_info(&usb->dev, "%s: ZD1201 USB Wireless interface\n", | 1817 | dev_info(&usb->dev, "%s: ZD1201 USB Wireless interface\n", |
1819 | zd->dev->name); | 1818 | dev->name); |
1820 | 1819 | ||
1821 | usb_set_intfdata(interface, zd); | 1820 | usb_set_intfdata(interface, zd); |
1822 | zd1201_enable(zd); /* zd1201 likes to startup enabled, */ | 1821 | zd1201_enable(zd); /* zd1201 likes to startup enabled, */ |
1823 | zd1201_disable(zd); /* interfering with all the wifis in range */ | 1822 | zd1201_disable(zd); /* interfering with all the wifis in range */ |
1824 | return 0; | 1823 | return 0; |
1825 | 1824 | ||
1826 | err_net: | ||
1827 | free_netdev(zd->dev); | ||
1828 | err_start: | 1825 | err_start: |
1829 | /* Leave the device in reset state */ | 1826 | /* Leave the device in reset state */ |
1830 | zd1201_docmd(zd, ZD1201_CMDCODE_INIT, 0, 0, 0); | 1827 | zd1201_docmd(zd, ZD1201_CMDCODE_INIT, 0, 0, 0); |
1831 | err_zd: | 1828 | err_zd: |
1832 | usb_free_urb(zd->tx_urb); | 1829 | usb_free_urb(zd->tx_urb); |
1833 | usb_free_urb(zd->rx_urb); | 1830 | usb_free_urb(zd->rx_urb); |
1834 | kfree(zd); | 1831 | free_netdev(dev); |
1835 | return err; | 1832 | return err; |
1836 | } | 1833 | } |
1837 | 1834 | ||