Commit dfcc16c9 authored by Jason A. Donenfeld's avatar Jason A. Donenfeld Committed by David S. Miller

ioc3-eth: store pointer to net_device for priviate area

Computing the alignment manually for going from priv to pub is probably
not such a good idea, and in general the assumption that going from priv
to pub is possible trivially could change, so rather than relying on
that, we change things to just store a pointer to pub. This was sugested
by DaveM in [1].

[1] http://www.spinics.net/lists/netdev/msg443992.htmlSigned-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 521ea952
...@@ -90,17 +90,13 @@ struct ioc3_private { ...@@ -90,17 +90,13 @@ struct ioc3_private {
spinlock_t ioc3_lock; spinlock_t ioc3_lock;
struct mii_if_info mii; struct mii_if_info mii;
struct net_device *dev;
struct pci_dev *pdev; struct pci_dev *pdev;
/* Members used by autonegotiation */ /* Members used by autonegotiation */
struct timer_list ioc3_timer; struct timer_list ioc3_timer;
}; };
static inline struct net_device *priv_netdev(struct ioc3_private *dev)
{
return (void *)dev - ((sizeof(struct net_device) + 31) & ~31);
}
static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
static void ioc3_set_multicast_list(struct net_device *dev); static void ioc3_set_multicast_list(struct net_device *dev);
static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev); static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev);
...@@ -427,7 +423,7 @@ static void ioc3_get_eaddr_nic(struct ioc3_private *ip) ...@@ -427,7 +423,7 @@ static void ioc3_get_eaddr_nic(struct ioc3_private *ip)
nic[i] = nic_read_byte(ioc3); nic[i] = nic_read_byte(ioc3);
for (i = 2; i < 8; i++) for (i = 2; i < 8; i++)
priv_netdev(ip)->dev_addr[i - 2] = nic[i]; ip->dev->dev_addr[i - 2] = nic[i];
} }
/* /*
...@@ -439,7 +435,7 @@ static void ioc3_get_eaddr(struct ioc3_private *ip) ...@@ -439,7 +435,7 @@ static void ioc3_get_eaddr(struct ioc3_private *ip)
{ {
ioc3_get_eaddr_nic(ip); ioc3_get_eaddr_nic(ip);
printk("Ethernet address is %pM.\n", priv_netdev(ip)->dev_addr); printk("Ethernet address is %pM.\n", ip->dev->dev_addr);
} }
static void __ioc3_set_mac_address(struct net_device *dev) static void __ioc3_set_mac_address(struct net_device *dev)
...@@ -790,13 +786,12 @@ static void ioc3_timer(unsigned long data) ...@@ -790,13 +786,12 @@ static void ioc3_timer(unsigned long data)
*/ */
static int ioc3_mii_init(struct ioc3_private *ip) static int ioc3_mii_init(struct ioc3_private *ip)
{ {
struct net_device *dev = priv_netdev(ip);
int i, found = 0, res = 0; int i, found = 0, res = 0;
int ioc3_phy_workaround = 1; int ioc3_phy_workaround = 1;
u16 word; u16 word;
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
word = ioc3_mdio_read(dev, i, MII_PHYSID1); word = ioc3_mdio_read(ip->dev, i, MII_PHYSID1);
if (word != 0xffff && word != 0x0000) { if (word != 0xffff && word != 0x0000) {
found = 1; found = 1;
...@@ -1276,6 +1271,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1276,6 +1271,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
ip = netdev_priv(dev); ip = netdev_priv(dev);
ip->dev = dev;
dev->irq = pdev->irq; dev->irq = pdev->irq;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment