diff options
author | Divy Le Ray <divy@chelsio.com> | 2007-08-29 22:15:47 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-08-31 07:29:08 -0400 |
commit | 5fbf816fe7d72bfdbf22bfec05b4ec3aa6849f72 (patch) | |
tree | 62f35df3e9078e3f981b9c04176d9a9cb557a53a /drivers/net/cxgb3/cxgb3_main.c | |
parent | 54d0f56e63edb1aa3901ea6389bf7ea5d43d0c22 (diff) |
cxgb3 - Fix dev->priv usage
cxgb3 used netdev_priv() and dev->priv for different purposes.
In 2.6.23, netdev_priv() == dev->priv, cxgb3 needs a fix.
This patch is a partial backport of Dave Miller's changes in the
net-2.6.24 git branch.
Without this fix, cxgb3 crashes on 2.6.23.
Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/cxgb3/cxgb3_main.c')
-rw-r--r-- | drivers/net/cxgb3/cxgb3_main.c | 126 |
1 files changed, 72 insertions, 54 deletions
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index dc5d26988bb3..f3bf1283c9a7 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -358,11 +358,14 @@ static int init_dummy_netdevs(struct adapter *adap) | |||
358 | 358 | ||
359 | for (j = 0; j < pi->nqsets - 1; j++) { | 359 | for (j = 0; j < pi->nqsets - 1; j++) { |
360 | if (!adap->dummy_netdev[dummy_idx]) { | 360 | if (!adap->dummy_netdev[dummy_idx]) { |
361 | nd = alloc_netdev(0, "", ether_setup); | 361 | struct port_info *p; |
362 | |||
363 | nd = alloc_netdev(sizeof(*p), "", ether_setup); | ||
362 | if (!nd) | 364 | if (!nd) |
363 | goto free_all; | 365 | goto free_all; |
364 | 366 | ||
365 | nd->priv = adap; | 367 | p = netdev_priv(nd); |
368 | p->adapter = adap; | ||
366 | nd->weight = 64; | 369 | nd->weight = 64; |
367 | set_bit(__LINK_STATE_START, &nd->state); | 370 | set_bit(__LINK_STATE_START, &nd->state); |
368 | adap->dummy_netdev[dummy_idx] = nd; | 371 | adap->dummy_netdev[dummy_idx] = nd; |
@@ -482,7 +485,8 @@ static ssize_t attr_store(struct device *d, struct device_attribute *attr, | |||
482 | #define CXGB3_SHOW(name, val_expr) \ | 485 | #define CXGB3_SHOW(name, val_expr) \ |
483 | static ssize_t format_##name(struct net_device *dev, char *buf) \ | 486 | static ssize_t format_##name(struct net_device *dev, char *buf) \ |
484 | { \ | 487 | { \ |
485 | struct adapter *adap = dev->priv; \ | 488 | struct port_info *pi = netdev_priv(dev); \ |
489 | struct adapter *adap = pi->adapter; \ | ||
486 | return sprintf(buf, "%u\n", val_expr); \ | 490 | return sprintf(buf, "%u\n", val_expr); \ |
487 | } \ | 491 | } \ |
488 | static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ | 492 | static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ |
@@ -493,7 +497,8 @@ static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ | |||
493 | 497 | ||
494 | static ssize_t set_nfilters(struct net_device *dev, unsigned int val) | 498 | static ssize_t set_nfilters(struct net_device *dev, unsigned int val) |
495 | { | 499 | { |
496 | struct adapter *adap = dev->priv; | 500 | struct port_info *pi = netdev_priv(dev); |
501 | struct adapter *adap = pi->adapter; | ||
497 | int min_tids = is_offload(adap) ? MC5_MIN_TIDS : 0; | 502 | int min_tids = is_offload(adap) ? MC5_MIN_TIDS : 0; |
498 | 503 | ||
499 | if (adap->flags & FULL_INIT_DONE) | 504 | if (adap->flags & FULL_INIT_DONE) |
@@ -515,7 +520,8 @@ static ssize_t store_nfilters(struct device *d, struct device_attribute *attr, | |||
515 | 520 | ||
516 | static ssize_t set_nservers(struct net_device *dev, unsigned int val) | 521 | static ssize_t set_nservers(struct net_device *dev, unsigned int val) |
517 | { | 522 | { |
518 | struct adapter *adap = dev->priv; | 523 | struct port_info *pi = netdev_priv(dev); |
524 | struct adapter *adap = pi->adapter; | ||
519 | 525 | ||
520 | if (adap->flags & FULL_INIT_DONE) | 526 | if (adap->flags & FULL_INIT_DONE) |
521 | return -EBUSY; | 527 | return -EBUSY; |
@@ -556,9 +562,10 @@ static struct attribute_group cxgb3_attr_group = {.attrs = cxgb3_attrs }; | |||
556 | static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr, | 562 | static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr, |
557 | char *buf, int sched) | 563 | char *buf, int sched) |
558 | { | 564 | { |
559 | ssize_t len; | 565 | struct port_info *pi = netdev_priv(to_net_dev(d)); |
566 | struct adapter *adap = pi->adapter; | ||
560 | unsigned int v, addr, bpt, cpt; | 567 | unsigned int v, addr, bpt, cpt; |
561 | struct adapter *adap = to_net_dev(d)->priv; | 568 | ssize_t len; |
562 | 569 | ||
563 | addr = A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2; | 570 | addr = A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2; |
564 | rtnl_lock(); | 571 | rtnl_lock(); |
@@ -581,10 +588,11 @@ static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr, | |||
581 | static ssize_t tm_attr_store(struct device *d, struct device_attribute *attr, | 588 | static ssize_t tm_attr_store(struct device *d, struct device_attribute *attr, |
582 | const char *buf, size_t len, int sched) | 589 | const char *buf, size_t len, int sched) |
583 | { | 590 | { |
591 | struct port_info *pi = netdev_priv(to_net_dev(d)); | ||
592 | struct adapter *adap = pi->adapter; | ||
593 | unsigned int val; | ||
584 | char *endp; | 594 | char *endp; |
585 | ssize_t ret; | 595 | ssize_t ret; |
586 | unsigned int val; | ||
587 | struct adapter *adap = to_net_dev(d)->priv; | ||
588 | 596 | ||
589 | if (!capable(CAP_NET_ADMIN)) | 597 | if (!capable(CAP_NET_ADMIN)) |
590 | return -EPERM; | 598 | return -EPERM; |
@@ -858,8 +866,9 @@ static void schedule_chk_task(struct adapter *adap) | |||
858 | 866 | ||
859 | static int offload_open(struct net_device *dev) | 867 | static int offload_open(struct net_device *dev) |
860 | { | 868 | { |
861 | struct adapter *adapter = dev->priv; | 869 | struct port_info *pi = netdev_priv(dev); |
862 | struct t3cdev *tdev = T3CDEV(dev); | 870 | struct adapter *adapter = pi->adapter; |
871 | struct t3cdev *tdev = dev2t3cdev(dev); | ||
863 | int adap_up = adapter->open_device_map & PORT_MASK; | 872 | int adap_up = adapter->open_device_map & PORT_MASK; |
864 | int err = 0; | 873 | int err = 0; |
865 | 874 | ||
@@ -924,10 +933,10 @@ static int offload_close(struct t3cdev *tdev) | |||
924 | 933 | ||
925 | static int cxgb_open(struct net_device *dev) | 934 | static int cxgb_open(struct net_device *dev) |
926 | { | 935 | { |
927 | int err; | ||
928 | struct adapter *adapter = dev->priv; | ||
929 | struct port_info *pi = netdev_priv(dev); | 936 | struct port_info *pi = netdev_priv(dev); |
937 | struct adapter *adapter = pi->adapter; | ||
930 | int other_ports = adapter->open_device_map & PORT_MASK; | 938 | int other_ports = adapter->open_device_map & PORT_MASK; |
939 | int err; | ||
931 | 940 | ||
932 | if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0) | 941 | if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0) |
933 | return err; | 942 | return err; |
@@ -951,17 +960,17 @@ static int cxgb_open(struct net_device *dev) | |||
951 | 960 | ||
952 | static int cxgb_close(struct net_device *dev) | 961 | static int cxgb_close(struct net_device *dev) |
953 | { | 962 | { |
954 | struct adapter *adapter = dev->priv; | 963 | struct port_info *pi = netdev_priv(dev); |
955 | struct port_info *p = netdev_priv(dev); | 964 | struct adapter *adapter = pi->adapter; |
956 | 965 | ||
957 | t3_port_intr_disable(adapter, p->port_id); | 966 | t3_port_intr_disable(adapter, pi->port_id); |
958 | netif_stop_queue(dev); | 967 | netif_stop_queue(dev); |
959 | p->phy.ops->power_down(&p->phy, 1); | 968 | pi->phy.ops->power_down(&pi->phy, 1); |
960 | netif_carrier_off(dev); | 969 | netif_carrier_off(dev); |
961 | t3_mac_disable(&p->mac, MAC_DIRECTION_TX | MAC_DIRECTION_RX); | 970 | t3_mac_disable(&pi->mac, MAC_DIRECTION_TX | MAC_DIRECTION_RX); |
962 | 971 | ||
963 | spin_lock(&adapter->work_lock); /* sync with update task */ | 972 | spin_lock(&adapter->work_lock); /* sync with update task */ |
964 | clear_bit(p->port_id, &adapter->open_device_map); | 973 | clear_bit(pi->port_id, &adapter->open_device_map); |
965 | spin_unlock(&adapter->work_lock); | 974 | spin_unlock(&adapter->work_lock); |
966 | 975 | ||
967 | if (!(adapter->open_device_map & PORT_MASK)) | 976 | if (!(adapter->open_device_map & PORT_MASK)) |
@@ -976,13 +985,13 @@ static int cxgb_close(struct net_device *dev) | |||
976 | 985 | ||
977 | static struct net_device_stats *cxgb_get_stats(struct net_device *dev) | 986 | static struct net_device_stats *cxgb_get_stats(struct net_device *dev) |
978 | { | 987 | { |
979 | struct adapter *adapter = dev->priv; | 988 | struct port_info *pi = netdev_priv(dev); |
980 | struct port_info *p = netdev_priv(dev); | 989 | struct adapter *adapter = pi->adapter; |
981 | struct net_device_stats *ns = &p->netstats; | 990 | struct net_device_stats *ns = &pi->netstats; |
982 | const struct mac_stats *pstats; | 991 | const struct mac_stats *pstats; |
983 | 992 | ||
984 | spin_lock(&adapter->stats_lock); | 993 | spin_lock(&adapter->stats_lock); |
985 | pstats = t3_mac_update_stats(&p->mac); | 994 | pstats = t3_mac_update_stats(&pi->mac); |
986 | spin_unlock(&adapter->stats_lock); | 995 | spin_unlock(&adapter->stats_lock); |
987 | 996 | ||
988 | ns->tx_bytes = pstats->tx_octets; | 997 | ns->tx_bytes = pstats->tx_octets; |
@@ -1015,14 +1024,16 @@ static struct net_device_stats *cxgb_get_stats(struct net_device *dev) | |||
1015 | 1024 | ||
1016 | static u32 get_msglevel(struct net_device *dev) | 1025 | static u32 get_msglevel(struct net_device *dev) |
1017 | { | 1026 | { |
1018 | struct adapter *adapter = dev->priv; | 1027 | struct port_info *pi = netdev_priv(dev); |
1028 | struct adapter *adapter = pi->adapter; | ||
1019 | 1029 | ||
1020 | return adapter->msg_enable; | 1030 | return adapter->msg_enable; |
1021 | } | 1031 | } |
1022 | 1032 | ||
1023 | static void set_msglevel(struct net_device *dev, u32 val) | 1033 | static void set_msglevel(struct net_device *dev, u32 val) |
1024 | { | 1034 | { |
1025 | struct adapter *adapter = dev->priv; | 1035 | struct port_info *pi = netdev_priv(dev); |
1036 | struct adapter *adapter = pi->adapter; | ||
1026 | 1037 | ||
1027 | adapter->msg_enable = val; | 1038 | adapter->msg_enable = val; |
1028 | } | 1039 | } |
@@ -1096,8 +1107,9 @@ static int get_eeprom_len(struct net_device *dev) | |||
1096 | 1107 | ||
1097 | static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 1108 | static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
1098 | { | 1109 | { |
1110 | struct port_info *pi = netdev_priv(dev); | ||
1111 | struct adapter *adapter = pi->adapter; | ||
1099 | u32 fw_vers = 0; | 1112 | u32 fw_vers = 0; |
1100 | struct adapter *adapter = dev->priv; | ||
1101 | 1113 | ||
1102 | t3_get_fw_version(adapter, &fw_vers); | 1114 | t3_get_fw_version(adapter, &fw_vers); |
1103 | 1115 | ||
@@ -1136,8 +1148,8 @@ static unsigned long collect_sge_port_stats(struct adapter *adapter, | |||
1136 | static void get_stats(struct net_device *dev, struct ethtool_stats *stats, | 1148 | static void get_stats(struct net_device *dev, struct ethtool_stats *stats, |
1137 | u64 *data) | 1149 | u64 *data) |
1138 | { | 1150 | { |
1139 | struct adapter *adapter = dev->priv; | ||
1140 | struct port_info *pi = netdev_priv(dev); | 1151 | struct port_info *pi = netdev_priv(dev); |
1152 | struct adapter *adapter = pi->adapter; | ||
1141 | const struct mac_stats *s; | 1153 | const struct mac_stats *s; |
1142 | 1154 | ||
1143 | spin_lock(&adapter->stats_lock); | 1155 | spin_lock(&adapter->stats_lock); |
@@ -1205,7 +1217,8 @@ static inline void reg_block_dump(struct adapter *ap, void *buf, | |||
1205 | static void get_regs(struct net_device *dev, struct ethtool_regs *regs, | 1217 | static void get_regs(struct net_device *dev, struct ethtool_regs *regs, |
1206 | void *buf) | 1218 | void *buf) |
1207 | { | 1219 | { |
1208 | struct adapter *ap = dev->priv; | 1220 | struct port_info *pi = netdev_priv(dev); |
1221 | struct adapter *ap = pi->adapter; | ||
1209 | 1222 | ||
1210 | /* | 1223 | /* |
1211 | * Version scheme: | 1224 | * Version scheme: |
@@ -1246,8 +1259,9 @@ static int restart_autoneg(struct net_device *dev) | |||
1246 | 1259 | ||
1247 | static int cxgb3_phys_id(struct net_device *dev, u32 data) | 1260 | static int cxgb3_phys_id(struct net_device *dev, u32 data) |
1248 | { | 1261 | { |
1262 | struct port_info *pi = netdev_priv(dev); | ||
1263 | struct adapter *adapter = pi->adapter; | ||
1249 | int i; | 1264 | int i; |
1250 | struct adapter *adapter = dev->priv; | ||
1251 | 1265 | ||
1252 | if (data == 0) | 1266 | if (data == 0) |
1253 | data = 2; | 1267 | data = 2; |
@@ -1408,8 +1422,8 @@ static int set_rx_csum(struct net_device *dev, u32 data) | |||
1408 | 1422 | ||
1409 | static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e) | 1423 | static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e) |
1410 | { | 1424 | { |
1411 | const struct adapter *adapter = dev->priv; | 1425 | struct port_info *pi = netdev_priv(dev); |
1412 | const struct port_info *pi = netdev_priv(dev); | 1426 | struct adapter *adapter = pi->adapter; |
1413 | const struct qset_params *q = &adapter->params.sge.qset[pi->first_qset]; | 1427 | const struct qset_params *q = &adapter->params.sge.qset[pi->first_qset]; |
1414 | 1428 | ||
1415 | e->rx_max_pending = MAX_RX_BUFFERS; | 1429 | e->rx_max_pending = MAX_RX_BUFFERS; |
@@ -1425,10 +1439,10 @@ static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e) | |||
1425 | 1439 | ||
1426 | static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) | 1440 | static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) |
1427 | { | 1441 | { |
1428 | int i; | 1442 | struct port_info *pi = netdev_priv(dev); |
1443 | struct adapter *adapter = pi->adapter; | ||
1429 | struct qset_params *q; | 1444 | struct qset_params *q; |
1430 | struct adapter *adapter = dev->priv; | 1445 | int i; |
1431 | const struct port_info *pi = netdev_priv(dev); | ||
1432 | 1446 | ||
1433 | if (e->rx_pending > MAX_RX_BUFFERS || | 1447 | if (e->rx_pending > MAX_RX_BUFFERS || |
1434 | e->rx_jumbo_pending > MAX_RX_JUMBO_BUFFERS || | 1448 | e->rx_jumbo_pending > MAX_RX_JUMBO_BUFFERS || |
@@ -1457,7 +1471,8 @@ static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) | |||
1457 | 1471 | ||
1458 | static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c) | 1472 | static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c) |
1459 | { | 1473 | { |
1460 | struct adapter *adapter = dev->priv; | 1474 | struct port_info *pi = netdev_priv(dev); |
1475 | struct adapter *adapter = pi->adapter; | ||
1461 | struct qset_params *qsp = &adapter->params.sge.qset[0]; | 1476 | struct qset_params *qsp = &adapter->params.sge.qset[0]; |
1462 | struct sge_qset *qs = &adapter->sge.qs[0]; | 1477 | struct sge_qset *qs = &adapter->sge.qs[0]; |
1463 | 1478 | ||
@@ -1471,7 +1486,8 @@ static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c) | |||
1471 | 1486 | ||
1472 | static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c) | 1487 | static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c) |
1473 | { | 1488 | { |
1474 | struct adapter *adapter = dev->priv; | 1489 | struct port_info *pi = netdev_priv(dev); |
1490 | struct adapter *adapter = pi->adapter; | ||
1475 | struct qset_params *q = adapter->params.sge.qset; | 1491 | struct qset_params *q = adapter->params.sge.qset; |
1476 | 1492 | ||
1477 | c->rx_coalesce_usecs = q->coalesce_usecs; | 1493 | c->rx_coalesce_usecs = q->coalesce_usecs; |
@@ -1481,8 +1497,9 @@ static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c) | |||
1481 | static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e, | 1497 | static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e, |
1482 | u8 * data) | 1498 | u8 * data) |
1483 | { | 1499 | { |
1500 | struct port_info *pi = netdev_priv(dev); | ||
1501 | struct adapter *adapter = pi->adapter; | ||
1484 | int i, err = 0; | 1502 | int i, err = 0; |
1485 | struct adapter *adapter = dev->priv; | ||
1486 | 1503 | ||
1487 | u8 *buf = kmalloc(EEPROMSIZE, GFP_KERNEL); | 1504 | u8 *buf = kmalloc(EEPROMSIZE, GFP_KERNEL); |
1488 | if (!buf) | 1505 | if (!buf) |
@@ -1501,10 +1518,11 @@ static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e, | |||
1501 | static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | 1518 | static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, |
1502 | u8 * data) | 1519 | u8 * data) |
1503 | { | 1520 | { |
1521 | struct port_info *pi = netdev_priv(dev); | ||
1522 | struct adapter *adapter = pi->adapter; | ||
1523 | u32 aligned_offset, aligned_len, *p; | ||
1504 | u8 *buf; | 1524 | u8 *buf; |
1505 | int err = 0; | 1525 | int err = 0; |
1506 | u32 aligned_offset, aligned_len, *p; | ||
1507 | struct adapter *adapter = dev->priv; | ||
1508 | 1526 | ||
1509 | if (eeprom->magic != EEPROM_MAGIC) | 1527 | if (eeprom->magic != EEPROM_MAGIC) |
1510 | return -EINVAL; | 1528 | return -EINVAL; |
@@ -1592,9 +1610,10 @@ static int in_range(int val, int lo, int hi) | |||
1592 | 1610 | ||
1593 | static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) | 1611 | static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) |
1594 | { | 1612 | { |
1595 | int ret; | 1613 | struct port_info *pi = netdev_priv(dev); |
1614 | struct adapter *adapter = pi->adapter; | ||
1596 | u32 cmd; | 1615 | u32 cmd; |
1597 | struct adapter *adapter = dev->priv; | 1616 | int ret; |
1598 | 1617 | ||
1599 | if (copy_from_user(&cmd, useraddr, sizeof(cmd))) | 1618 | if (copy_from_user(&cmd, useraddr, sizeof(cmd))) |
1600 | return -EFAULT; | 1619 | return -EFAULT; |
@@ -1923,10 +1942,10 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) | |||
1923 | 1942 | ||
1924 | static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | 1943 | static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd) |
1925 | { | 1944 | { |
1926 | int ret, mmd; | ||
1927 | struct adapter *adapter = dev->priv; | ||
1928 | struct port_info *pi = netdev_priv(dev); | ||
1929 | struct mii_ioctl_data *data = if_mii(req); | 1945 | struct mii_ioctl_data *data = if_mii(req); |
1946 | struct port_info *pi = netdev_priv(dev); | ||
1947 | struct adapter *adapter = pi->adapter; | ||
1948 | int ret, mmd; | ||
1930 | 1949 | ||
1931 | switch (cmd) { | 1950 | switch (cmd) { |
1932 | case SIOCGMIIPHY: | 1951 | case SIOCGMIIPHY: |
@@ -1994,9 +2013,9 @@ static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
1994 | 2013 | ||
1995 | static int cxgb_change_mtu(struct net_device *dev, int new_mtu) | 2014 | static int cxgb_change_mtu(struct net_device *dev, int new_mtu) |
1996 | { | 2015 | { |
1997 | int ret; | ||
1998 | struct adapter *adapter = dev->priv; | ||
1999 | struct port_info *pi = netdev_priv(dev); | 2016 | struct port_info *pi = netdev_priv(dev); |
2017 | struct adapter *adapter = pi->adapter; | ||
2018 | int ret; | ||
2000 | 2019 | ||
2001 | if (new_mtu < 81) /* accommodate SACK */ | 2020 | if (new_mtu < 81) /* accommodate SACK */ |
2002 | return -EINVAL; | 2021 | return -EINVAL; |
@@ -2013,8 +2032,8 @@ static int cxgb_change_mtu(struct net_device *dev, int new_mtu) | |||
2013 | 2032 | ||
2014 | static int cxgb_set_mac_addr(struct net_device *dev, void *p) | 2033 | static int cxgb_set_mac_addr(struct net_device *dev, void *p) |
2015 | { | 2034 | { |
2016 | struct adapter *adapter = dev->priv; | ||
2017 | struct port_info *pi = netdev_priv(dev); | 2035 | struct port_info *pi = netdev_priv(dev); |
2036 | struct adapter *adapter = pi->adapter; | ||
2018 | struct sockaddr *addr = p; | 2037 | struct sockaddr *addr = p; |
2019 | 2038 | ||
2020 | if (!is_valid_ether_addr(addr->sa_data)) | 2039 | if (!is_valid_ether_addr(addr->sa_data)) |
@@ -2050,8 +2069,8 @@ static void t3_synchronize_rx(struct adapter *adap, const struct port_info *p) | |||
2050 | 2069 | ||
2051 | static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp) | 2070 | static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp) |
2052 | { | 2071 | { |
2053 | struct adapter *adapter = dev->priv; | ||
2054 | struct port_info *pi = netdev_priv(dev); | 2072 | struct port_info *pi = netdev_priv(dev); |
2073 | struct adapter *adapter = pi->adapter; | ||
2055 | 2074 | ||
2056 | pi->vlan_grp = grp; | 2075 | pi->vlan_grp = grp; |
2057 | if (adapter->params.rev > 0) | 2076 | if (adapter->params.rev > 0) |
@@ -2070,8 +2089,8 @@ static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp) | |||
2070 | #ifdef CONFIG_NET_POLL_CONTROLLER | 2089 | #ifdef CONFIG_NET_POLL_CONTROLLER |
2071 | static void cxgb_netpoll(struct net_device *dev) | 2090 | static void cxgb_netpoll(struct net_device *dev) |
2072 | { | 2091 | { |
2073 | struct adapter *adapter = dev->priv; | ||
2074 | struct port_info *pi = netdev_priv(dev); | 2092 | struct port_info *pi = netdev_priv(dev); |
2093 | struct adapter *adapter = pi->adapter; | ||
2075 | int qidx; | 2094 | int qidx; |
2076 | 2095 | ||
2077 | for (qidx = pi->first_qset; qidx < pi->first_qset + pi->nqsets; qidx++) { | 2096 | for (qidx = pi->first_qset; qidx < pi->first_qset + pi->nqsets; qidx++) { |
@@ -2433,6 +2452,7 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
2433 | 2452 | ||
2434 | adapter->port[i] = netdev; | 2453 | adapter->port[i] = netdev; |
2435 | pi = netdev_priv(netdev); | 2454 | pi = netdev_priv(netdev); |
2455 | pi->adapter = adapter; | ||
2436 | pi->rx_csum_offload = 1; | 2456 | pi->rx_csum_offload = 1; |
2437 | pi->nqsets = 1; | 2457 | pi->nqsets = 1; |
2438 | pi->first_qset = i; | 2458 | pi->first_qset = i; |
@@ -2442,7 +2462,6 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
2442 | netdev->irq = pdev->irq; | 2462 | netdev->irq = pdev->irq; |
2443 | netdev->mem_start = mmio_start; | 2463 | netdev->mem_start = mmio_start; |
2444 | netdev->mem_end = mmio_start + mmio_len - 1; | 2464 | netdev->mem_end = mmio_start + mmio_len - 1; |
2445 | netdev->priv = adapter; | ||
2446 | netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO; | 2465 | netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO; |
2447 | netdev->features |= NETIF_F_LLTX; | 2466 | netdev->features |= NETIF_F_LLTX; |
2448 | if (pci_using_dac) | 2467 | if (pci_using_dac) |
@@ -2467,7 +2486,7 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
2467 | SET_ETHTOOL_OPS(netdev, &cxgb_ethtool_ops); | 2486 | SET_ETHTOOL_OPS(netdev, &cxgb_ethtool_ops); |
2468 | } | 2487 | } |
2469 | 2488 | ||
2470 | pci_set_drvdata(pdev, adapter->port[0]); | 2489 | pci_set_drvdata(pdev, adapter); |
2471 | if (t3_prep_adapter(adapter, ai, 1) < 0) { | 2490 | if (t3_prep_adapter(adapter, ai, 1) < 0) { |
2472 | err = -ENODEV; | 2491 | err = -ENODEV; |
2473 | goto out_free_dev; | 2492 | goto out_free_dev; |
@@ -2547,11 +2566,10 @@ out_release_regions: | |||
2547 | 2566 | ||
2548 | static void __devexit remove_one(struct pci_dev *pdev) | 2567 | static void __devexit remove_one(struct pci_dev *pdev) |
2549 | { | 2568 | { |
2550 | struct net_device *dev = pci_get_drvdata(pdev); | 2569 | struct adapter *adapter = pci_get_drvdata(pdev); |
2551 | 2570 | ||
2552 | if (dev) { | 2571 | if (adapter) { |
2553 | int i; | 2572 | int i; |
2554 | struct adapter *adapter = dev->priv; | ||
2555 | 2573 | ||
2556 | t3_sge_stop(adapter); | 2574 | t3_sge_stop(adapter); |
2557 | sysfs_remove_group(&adapter->port[0]->dev.kobj, | 2575 | sysfs_remove_group(&adapter->port[0]->dev.kobj, |