Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging-p80211: Kill directly reference of netdev->priv

In this driver, netdev's private data is wlandevice_t. And the
wlandev(type of wlandevice_t) is exist before netdev be allocated. So
use netdev->ml_priv to point to the private data.

I am not sure whether I should consider the kernel version older than
2.3.38. Because in those kernels, netdevice_t is "structure dev"
instead of "structure net_device" and of course "dev->ml_priv" will
cause compile error. But before my patch, in function wlan_setup(),
there is a ether_setup(net_device) which already broke kernels which
older than 2.3.38.

Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Wang Chen and committed by
David S. Miller
979123d5 ad660e2f

+39 -39
+10 -10
drivers/staging/wlan-ng/p80211netdev.c
··· 244 244 static struct net_device_stats* 245 245 p80211knetdev_get_stats(netdevice_t *netdev) 246 246 { 247 - wlandevice_t *wlandev = (wlandevice_t*)netdev->priv; 247 + wlandevice_t *wlandev = netdev->ml_priv; 248 248 DBFENTER; 249 249 250 250 /* TODO: review the MIB stats for items that correspond to ··· 272 272 static int p80211knetdev_open( netdevice_t *netdev ) 273 273 { 274 274 int result = 0; /* success */ 275 - wlandevice_t *wlandev = (wlandevice_t*)(netdev->priv); 275 + wlandevice_t *wlandev = netdev->ml_priv; 276 276 277 277 DBFENTER; 278 278 ··· 315 315 static int p80211knetdev_stop( netdevice_t *netdev ) 316 316 { 317 317 int result = 0; 318 - wlandevice_t *wlandev = (wlandevice_t*)(netdev->priv); 318 + wlandevice_t *wlandev = netdev->ml_priv; 319 319 320 320 DBFENTER; 321 321 ··· 460 460 { 461 461 int result = 0; 462 462 int txresult = -1; 463 - wlandevice_t *wlandev = (wlandevice_t*)netdev->priv; 463 + wlandevice_t *wlandev = netdev->ml_priv; 464 464 p80211_hdr_t p80211_hdr; 465 465 p80211_metawep_t p80211_wep; 466 466 ··· 603 603 ----------------------------------------------------------------*/ 604 604 static void p80211knetdev_set_multicast_list(netdevice_t *dev) 605 605 { 606 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 606 + wlandevice_t *wlandev = dev->ml_priv; 607 607 608 608 DBFENTER; 609 609 ··· 696 696 { 697 697 int result = 0; 698 698 p80211ioctl_req_t *req = (p80211ioctl_req_t*)ifr; 699 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 699 + wlandevice_t *wlandev = dev->ml_priv; 700 700 UINT8 *msgbuf; 701 701 DBFENTER; 702 702 ··· 812 812 dot11req.msgcode = DIDmsg_dot11req_mibset; 813 813 dot11req.msglen = sizeof(p80211msg_dot11req_mibset_t); 814 814 memcpy(dot11req.devname, 815 - ((wlandevice_t*)(dev->priv))->name, 815 + ((wlandevice_t *)dev->ml_priv)->name, 816 816 WLAN_DEVNAMELEN_MAX - 1); 817 817 818 818 /* Set up the mibattribute argument */ ··· 833 833 resultcode->data = 0; 834 834 835 835 /* now fire the request */ 836 - result = p80211req_dorequest(dev->priv, (UINT8*)&dot11req); 836 + result = p80211req_dorequest(dev->ml_priv, (UINT8 *)&dot11req); 837 837 838 838 /* If the request wasn't successful, report an error and don't 839 839 * change the netdev address ··· 917 917 memset( dev, 0, sizeof(netdevice_t)); 918 918 ether_setup(dev); 919 919 wlandev->netdev = dev; 920 - dev->priv = wlandev; 920 + dev->ml_priv = wlandev; 921 921 dev->hard_start_xmit = p80211knetdev_hard_start_xmit; 922 922 dev->get_stats = p80211knetdev_get_stats; 923 923 #ifdef HAVE_PRIVATE_IOCTL ··· 1487 1487 1488 1488 static void p80211knetdev_tx_timeout( netdevice_t *netdev) 1489 1489 { 1490 - wlandevice_t *wlandev = (wlandevice_t*)netdev->priv; 1490 + wlandevice_t *wlandev = netdev->ml_priv; 1491 1491 DBFENTER; 1492 1492 1493 1493 if (wlandev->tx_timeout) {
+29 -29
drivers/staging/wlan-ng/p80211wext.c
··· 218 218 struct iw_statistics* p80211wext_get_wireless_stats (netdevice_t *dev) 219 219 { 220 220 p80211msg_lnxreq_commsquality_t quality; 221 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 221 + wlandevice_t *wlandev = dev->ml_priv; 222 222 struct iw_statistics* wstats = &wlandev->wstats; 223 223 int retval; 224 224 ··· 301 301 struct iw_request_info *info, 302 302 struct iw_freq *freq, char *extra) 303 303 { 304 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 304 + wlandevice_t *wlandev = dev->ml_priv; 305 305 p80211item_uint32_t mibitem; 306 306 p80211msg_dot11req_mibset_t msg; 307 307 int result; ··· 339 339 struct iw_request_info *info, 340 340 struct iw_freq *freq, char *extra) 341 341 { 342 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 342 + wlandevice_t *wlandev = dev->ml_priv; 343 343 p80211item_uint32_t mibitem; 344 344 p80211msg_dot11req_mibset_t msg; 345 345 int result; ··· 380 380 struct iw_request_info *info, 381 381 __u32 *mode, char *extra) 382 382 { 383 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 383 + wlandevice_t *wlandev = dev->ml_priv; 384 384 385 385 DBFENTER; 386 386 ··· 407 407 struct iw_request_info *info, 408 408 __u32 *mode, char *extra) 409 409 { 410 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 410 + wlandevice_t *wlandev = dev->ml_priv; 411 411 p80211item_uint32_t mibitem; 412 412 p80211msg_dot11req_mibset_t msg; 413 413 int result; ··· 550 550 struct sockaddr *ap_addr, char *extra) 551 551 { 552 552 553 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 553 + wlandevice_t *wlandev = dev->ml_priv; 554 554 555 555 DBFENTER; 556 556 ··· 566 566 struct iw_request_info *info, 567 567 struct iw_point *erq, char *key) 568 568 { 569 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 569 + wlandevice_t *wlandev = dev->ml_priv; 570 570 int err = 0; 571 571 int i; 572 572 ··· 607 607 struct iw_request_info *info, 608 608 struct iw_point *erq, char *key) 609 609 { 610 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 610 + wlandevice_t *wlandev = dev->ml_priv; 611 611 p80211msg_dot11req_mibset_t msg; 612 612 p80211item_pstr32_t pstr; 613 613 ··· 736 736 struct iw_request_info *info, 737 737 struct iw_point *data, char *essid) 738 738 { 739 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 739 + wlandevice_t *wlandev = dev->ml_priv; 740 740 741 741 DBFENTER; 742 742 ··· 762 762 struct iw_request_info *info, 763 763 struct iw_point *data, char *essid) 764 764 { 765 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 765 + wlandevice_t *wlandev = dev->ml_priv; 766 766 p80211msg_lnxreq_autojoin_t msg; 767 767 768 768 int result; ··· 816 816 struct iw_request_info *info, 817 817 struct iw_point *data, char *essid) 818 818 { 819 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 819 + wlandevice_t *wlandev = dev->ml_priv; 820 820 int err = 0; 821 821 822 822 DBFENTER; ··· 839 839 struct iw_request_info *info, 840 840 struct iw_param *rrq, char *extra) 841 841 { 842 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 842 + wlandevice_t *wlandev = dev->ml_priv; 843 843 p80211item_uint32_t mibitem; 844 844 p80211msg_dot11req_mibset_t msg; 845 845 int result; ··· 893 893 struct iw_request_info *info, 894 894 struct iw_param *rts, char *extra) 895 895 { 896 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 896 + wlandevice_t *wlandev = dev->ml_priv; 897 897 p80211item_uint32_t mibitem; 898 898 p80211msg_dot11req_mibset_t msg; 899 899 int result; ··· 927 927 struct iw_request_info *info, 928 928 struct iw_param *rts, char *extra) 929 929 { 930 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 930 + wlandevice_t *wlandev = dev->ml_priv; 931 931 p80211item_uint32_t mibitem; 932 932 p80211msg_dot11req_mibset_t msg; 933 933 int result; ··· 964 964 struct iw_request_info *info, 965 965 struct iw_param *frag, char *extra) 966 966 { 967 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 967 + wlandevice_t *wlandev = dev->ml_priv; 968 968 p80211item_uint32_t mibitem; 969 969 p80211msg_dot11req_mibset_t msg; 970 970 int result; ··· 997 997 struct iw_request_info *info, 998 998 struct iw_param *frag, char *extra) 999 999 { 1000 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1000 + wlandevice_t *wlandev = dev->ml_priv; 1001 1001 p80211item_uint32_t mibitem; 1002 1002 p80211msg_dot11req_mibset_t msg; 1003 1003 int result; ··· 1047 1047 struct iw_request_info *info, 1048 1048 struct iw_param *rrq, char *extra) 1049 1049 { 1050 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1050 + wlandevice_t *wlandev = dev->ml_priv; 1051 1051 p80211item_uint32_t mibitem; 1052 1052 p80211msg_dot11req_mibset_t msg; 1053 1053 int result; ··· 1126 1126 struct iw_request_info *info, 1127 1127 struct iw_param *rrq, char *extra) 1128 1128 { 1129 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1129 + wlandevice_t *wlandev = dev->ml_priv; 1130 1130 p80211item_uint32_t mibitem; 1131 1131 p80211msg_dot11req_mibset_t msg; 1132 1132 int result; ··· 1198 1198 struct iw_request_info *info, 1199 1199 struct iw_param *rrq, char *extra) 1200 1200 { 1201 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1201 + wlandevice_t *wlandev = dev->ml_priv; 1202 1202 p80211item_uint32_t mibitem; 1203 1203 p80211msg_dot11req_mibset_t msg; 1204 1204 int result; ··· 1243 1243 struct iw_request_info *info, 1244 1244 struct iw_param *rrq, char *extra) 1245 1245 { 1246 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1246 + wlandevice_t *wlandev = dev->ml_priv; 1247 1247 p80211item_uint32_t mibitem; 1248 1248 p80211msg_dot11req_mibset_t msg; 1249 1249 int result; ··· 1281 1281 struct iw_request_info *info, 1282 1282 struct iw_point *srq, char *extra) 1283 1283 { 1284 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1284 + wlandevice_t *wlandev = dev->ml_priv; 1285 1285 struct sockaddr address[IW_MAX_SPY]; 1286 1286 int number = srq->length; 1287 1287 int i; ··· 1317 1317 struct iw_request_info *info, 1318 1318 struct iw_point *srq, char *extra) 1319 1319 { 1320 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1320 + wlandevice_t *wlandev = dev->ml_priv; 1321 1321 1322 1322 struct sockaddr address[IW_MAX_SPY]; 1323 1323 struct iw_quality spy_stat[IW_MAX_SPY]; ··· 1378 1378 struct iw_request_info *info, 1379 1379 struct iw_point *srq, char *extra) 1380 1380 { 1381 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1381 + wlandevice_t *wlandev = dev->ml_priv; 1382 1382 p80211msg_dot11req_scan_t msg; 1383 1383 int result; 1384 1384 int err = 0; ··· 1501 1501 struct iw_request_info *info, 1502 1502 struct iw_point *srq, char *extra) 1503 1503 { 1504 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1504 + wlandevice_t *wlandev = dev->ml_priv; 1505 1505 p80211msg_dot11req_scan_results_t msg; 1506 1506 int result = 0; 1507 1507 int err = 0; ··· 1551 1551 struct iw_request_info *info, 1552 1552 union iwreq_data *wrqu, char *extra) 1553 1553 { 1554 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1554 + wlandevice_t *wlandev = dev->ml_priv; 1555 1555 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 1556 1556 p80211msg_dot11req_mibset_t msg; 1557 1557 p80211item_pstr32_t *pstr; ··· 1627 1627 union iwreq_data *wrqu, char *extra) 1628 1628 1629 1629 { 1630 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1630 + wlandevice_t *wlandev = dev->ml_priv; 1631 1631 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 1632 1632 1633 1633 struct iw_point *encoding = &wrqu->encoding; ··· 1682 1682 struct iw_request_info *info, 1683 1683 union iwreq_data *wrqu, char *extra) 1684 1684 { 1685 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1685 + wlandevice_t *wlandev = dev->ml_priv; 1686 1686 struct iw_param *param = &wrqu->param; 1687 1687 int result =0; 1688 1688 ··· 1734 1734 struct iw_request_info *info, 1735 1735 union iwreq_data *wrqu, char *extra) 1736 1736 { 1737 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1737 + wlandevice_t *wlandev = dev->ml_priv; 1738 1738 struct iw_param *param = &wrqu->param; 1739 1739 int result =0; 1740 1740 ··· 1868 1868 /* wireless extensions' ioctls */ 1869 1869 int p80211wext_support_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd) 1870 1870 { 1871 - wlandevice_t *wlandev = (wlandevice_t*)dev->priv; 1871 + wlandevice_t *wlandev = dev->ml_priv; 1872 1872 1873 1873 #if WIRELESS_EXT < 13 1874 1874 struct iwreq *iwr = (struct iwreq*)ifr;