natsemi: stop using net_device.{base_addr, irq}.
It's useless to check mem_start on a newly allocated device. Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Cc: Tim Hockin <thockin@hockin.org>
This commit is contained in:
parent
b5a80837b7
commit
d710ce1357
|
@ -547,6 +547,7 @@ struct netdev_private {
|
||||||
struct sk_buff *tx_skbuff[TX_RING_SIZE];
|
struct sk_buff *tx_skbuff[TX_RING_SIZE];
|
||||||
dma_addr_t tx_dma[TX_RING_SIZE];
|
dma_addr_t tx_dma[TX_RING_SIZE];
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
void __iomem *ioaddr;
|
||||||
struct napi_struct napi;
|
struct napi_struct napi;
|
||||||
/* Media monitoring timer */
|
/* Media monitoring timer */
|
||||||
struct timer_list timer;
|
struct timer_list timer;
|
||||||
|
@ -699,7 +700,9 @@ static ssize_t natsemi_set_dspcfg_workaround(struct device *dev,
|
||||||
|
|
||||||
static inline void __iomem *ns_ioaddr(struct net_device *dev)
|
static inline void __iomem *ns_ioaddr(struct net_device *dev)
|
||||||
{
|
{
|
||||||
return (void __iomem *) dev->base_addr;
|
struct netdev_private *np = netdev_priv(dev);
|
||||||
|
|
||||||
|
return np->ioaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void natsemi_irq_enable(struct net_device *dev)
|
static inline void natsemi_irq_enable(struct net_device *dev)
|
||||||
|
@ -863,10 +866,9 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
|
||||||
/* Store MAC Address in perm_addr */
|
/* Store MAC Address in perm_addr */
|
||||||
memcpy(dev->perm_addr, dev->dev_addr, ETH_ALEN);
|
memcpy(dev->perm_addr, dev->dev_addr, ETH_ALEN);
|
||||||
|
|
||||||
dev->base_addr = (unsigned long __force) ioaddr;
|
|
||||||
dev->irq = irq;
|
|
||||||
|
|
||||||
np = netdev_priv(dev);
|
np = netdev_priv(dev);
|
||||||
|
np->ioaddr = ioaddr;
|
||||||
|
|
||||||
netif_napi_add(dev, &np->napi, natsemi_poll, 64);
|
netif_napi_add(dev, &np->napi, natsemi_poll, 64);
|
||||||
np->dev = dev;
|
np->dev = dev;
|
||||||
|
|
||||||
|
@ -914,9 +916,6 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
|
||||||
}
|
}
|
||||||
|
|
||||||
option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
|
option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
|
||||||
if (dev->mem_start)
|
|
||||||
option = dev->mem_start;
|
|
||||||
|
|
||||||
/* The lower four bits are the media type. */
|
/* The lower four bits are the media type. */
|
||||||
if (option) {
|
if (option) {
|
||||||
if (option & 0x200)
|
if (option & 0x200)
|
||||||
|
@ -1532,20 +1531,21 @@ static int netdev_open(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct netdev_private *np = netdev_priv(dev);
|
struct netdev_private *np = netdev_priv(dev);
|
||||||
void __iomem * ioaddr = ns_ioaddr(dev);
|
void __iomem * ioaddr = ns_ioaddr(dev);
|
||||||
|
const int irq = np->pci_dev->irq;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Reset the chip, just in case. */
|
/* Reset the chip, just in case. */
|
||||||
natsemi_reset(dev);
|
natsemi_reset(dev);
|
||||||
|
|
||||||
i = request_irq(dev->irq, intr_handler, IRQF_SHARED, dev->name, dev);
|
i = request_irq(irq, intr_handler, IRQF_SHARED, dev->name, dev);
|
||||||
if (i) return i;
|
if (i) return i;
|
||||||
|
|
||||||
if (netif_msg_ifup(np))
|
if (netif_msg_ifup(np))
|
||||||
printk(KERN_DEBUG "%s: netdev_open() irq %d.\n",
|
printk(KERN_DEBUG "%s: netdev_open() irq %d.\n",
|
||||||
dev->name, dev->irq);
|
dev->name, irq);
|
||||||
i = alloc_ring(dev);
|
i = alloc_ring(dev);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
free_irq(dev->irq, dev);
|
free_irq(irq, dev);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
napi_enable(&np->napi);
|
napi_enable(&np->napi);
|
||||||
|
@ -1794,6 +1794,7 @@ static void netdev_timer(unsigned long data)
|
||||||
struct netdev_private *np = netdev_priv(dev);
|
struct netdev_private *np = netdev_priv(dev);
|
||||||
void __iomem * ioaddr = ns_ioaddr(dev);
|
void __iomem * ioaddr = ns_ioaddr(dev);
|
||||||
int next_tick = NATSEMI_TIMER_FREQ;
|
int next_tick = NATSEMI_TIMER_FREQ;
|
||||||
|
const int irq = np->pci_dev->irq;
|
||||||
|
|
||||||
if (netif_msg_timer(np)) {
|
if (netif_msg_timer(np)) {
|
||||||
/* DO NOT read the IntrStatus register,
|
/* DO NOT read the IntrStatus register,
|
||||||
|
@ -1817,14 +1818,14 @@ static void netdev_timer(unsigned long data)
|
||||||
if (netif_msg_drv(np))
|
if (netif_msg_drv(np))
|
||||||
printk(KERN_NOTICE "%s: possible phy reset: "
|
printk(KERN_NOTICE "%s: possible phy reset: "
|
||||||
"re-initializing\n", dev->name);
|
"re-initializing\n", dev->name);
|
||||||
disable_irq(dev->irq);
|
disable_irq(irq);
|
||||||
spin_lock_irq(&np->lock);
|
spin_lock_irq(&np->lock);
|
||||||
natsemi_stop_rxtx(dev);
|
natsemi_stop_rxtx(dev);
|
||||||
dump_ring(dev);
|
dump_ring(dev);
|
||||||
reinit_ring(dev);
|
reinit_ring(dev);
|
||||||
init_registers(dev);
|
init_registers(dev);
|
||||||
spin_unlock_irq(&np->lock);
|
spin_unlock_irq(&np->lock);
|
||||||
enable_irq(dev->irq);
|
enable_irq(irq);
|
||||||
} else {
|
} else {
|
||||||
/* hurry back */
|
/* hurry back */
|
||||||
next_tick = HZ;
|
next_tick = HZ;
|
||||||
|
@ -1841,10 +1842,10 @@ static void netdev_timer(unsigned long data)
|
||||||
spin_unlock_irq(&np->lock);
|
spin_unlock_irq(&np->lock);
|
||||||
}
|
}
|
||||||
if (np->oom) {
|
if (np->oom) {
|
||||||
disable_irq(dev->irq);
|
disable_irq(irq);
|
||||||
np->oom = 0;
|
np->oom = 0;
|
||||||
refill_rx(dev);
|
refill_rx(dev);
|
||||||
enable_irq(dev->irq);
|
enable_irq(irq);
|
||||||
if (!np->oom) {
|
if (!np->oom) {
|
||||||
writel(RxOn, ioaddr + ChipCmd);
|
writel(RxOn, ioaddr + ChipCmd);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1885,8 +1886,9 @@ static void ns_tx_timeout(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct netdev_private *np = netdev_priv(dev);
|
struct netdev_private *np = netdev_priv(dev);
|
||||||
void __iomem * ioaddr = ns_ioaddr(dev);
|
void __iomem * ioaddr = ns_ioaddr(dev);
|
||||||
|
const int irq = np->pci_dev->irq;
|
||||||
|
|
||||||
disable_irq(dev->irq);
|
disable_irq(irq);
|
||||||
spin_lock_irq(&np->lock);
|
spin_lock_irq(&np->lock);
|
||||||
if (!np->hands_off) {
|
if (!np->hands_off) {
|
||||||
if (netif_msg_tx_err(np))
|
if (netif_msg_tx_err(np))
|
||||||
|
@ -1905,7 +1907,7 @@ static void ns_tx_timeout(struct net_device *dev)
|
||||||
dev->name);
|
dev->name);
|
||||||
}
|
}
|
||||||
spin_unlock_irq(&np->lock);
|
spin_unlock_irq(&np->lock);
|
||||||
enable_irq(dev->irq);
|
enable_irq(irq);
|
||||||
|
|
||||||
dev->trans_start = jiffies; /* prevent tx timeout */
|
dev->trans_start = jiffies; /* prevent tx timeout */
|
||||||
dev->stats.tx_errors++;
|
dev->stats.tx_errors++;
|
||||||
|
@ -2470,9 +2472,12 @@ static struct net_device_stats *get_stats(struct net_device *dev)
|
||||||
#ifdef CONFIG_NET_POLL_CONTROLLER
|
#ifdef CONFIG_NET_POLL_CONTROLLER
|
||||||
static void natsemi_poll_controller(struct net_device *dev)
|
static void natsemi_poll_controller(struct net_device *dev)
|
||||||
{
|
{
|
||||||
disable_irq(dev->irq);
|
struct netdev_private *np = netdev_priv(dev);
|
||||||
intr_handler(dev->irq, dev);
|
const int irq = np->pci_dev->irq;
|
||||||
enable_irq(dev->irq);
|
|
||||||
|
disable_irq(irq);
|
||||||
|
intr_handler(irq, dev);
|
||||||
|
enable_irq(irq);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2523,8 +2528,9 @@ static int natsemi_change_mtu(struct net_device *dev, int new_mtu)
|
||||||
if (netif_running(dev)) {
|
if (netif_running(dev)) {
|
||||||
struct netdev_private *np = netdev_priv(dev);
|
struct netdev_private *np = netdev_priv(dev);
|
||||||
void __iomem * ioaddr = ns_ioaddr(dev);
|
void __iomem * ioaddr = ns_ioaddr(dev);
|
||||||
|
const int irq = np->pci_dev->irq;
|
||||||
|
|
||||||
disable_irq(dev->irq);
|
disable_irq(irq);
|
||||||
spin_lock(&np->lock);
|
spin_lock(&np->lock);
|
||||||
/* stop engines */
|
/* stop engines */
|
||||||
natsemi_stop_rxtx(dev);
|
natsemi_stop_rxtx(dev);
|
||||||
|
@ -2537,7 +2543,7 @@ static int natsemi_change_mtu(struct net_device *dev, int new_mtu)
|
||||||
/* restart engines */
|
/* restart engines */
|
||||||
writel(RxOn | TxOn, ioaddr + ChipCmd);
|
writel(RxOn | TxOn, ioaddr + ChipCmd);
|
||||||
spin_unlock(&np->lock);
|
spin_unlock(&np->lock);
|
||||||
enable_irq(dev->irq);
|
enable_irq(irq);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3135,6 +3141,7 @@ static int netdev_close(struct net_device *dev)
|
||||||
{
|
{
|
||||||
void __iomem * ioaddr = ns_ioaddr(dev);
|
void __iomem * ioaddr = ns_ioaddr(dev);
|
||||||
struct netdev_private *np = netdev_priv(dev);
|
struct netdev_private *np = netdev_priv(dev);
|
||||||
|
const int irq = np->pci_dev->irq;
|
||||||
|
|
||||||
if (netif_msg_ifdown(np))
|
if (netif_msg_ifdown(np))
|
||||||
printk(KERN_DEBUG
|
printk(KERN_DEBUG
|
||||||
|
@ -3156,14 +3163,14 @@ static int netdev_close(struct net_device *dev)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
del_timer_sync(&np->timer);
|
del_timer_sync(&np->timer);
|
||||||
disable_irq(dev->irq);
|
disable_irq(irq);
|
||||||
spin_lock_irq(&np->lock);
|
spin_lock_irq(&np->lock);
|
||||||
natsemi_irq_disable(dev);
|
natsemi_irq_disable(dev);
|
||||||
np->hands_off = 1;
|
np->hands_off = 1;
|
||||||
spin_unlock_irq(&np->lock);
|
spin_unlock_irq(&np->lock);
|
||||||
enable_irq(dev->irq);
|
enable_irq(irq);
|
||||||
|
|
||||||
free_irq(dev->irq, dev);
|
free_irq(irq, dev);
|
||||||
|
|
||||||
/* Interrupt disabled, interrupt handler released,
|
/* Interrupt disabled, interrupt handler released,
|
||||||
* queue stopped, timer deleted, rtnl_lock held
|
* queue stopped, timer deleted, rtnl_lock held
|
||||||
|
@ -3256,9 +3263,11 @@ static int natsemi_suspend (struct pci_dev *pdev, pm_message_t state)
|
||||||
|
|
||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
if (netif_running (dev)) {
|
if (netif_running (dev)) {
|
||||||
|
const int irq = np->pci_dev->irq;
|
||||||
|
|
||||||
del_timer_sync(&np->timer);
|
del_timer_sync(&np->timer);
|
||||||
|
|
||||||
disable_irq(dev->irq);
|
disable_irq(irq);
|
||||||
spin_lock_irq(&np->lock);
|
spin_lock_irq(&np->lock);
|
||||||
|
|
||||||
natsemi_irq_disable(dev);
|
natsemi_irq_disable(dev);
|
||||||
|
@ -3267,7 +3276,7 @@ static int natsemi_suspend (struct pci_dev *pdev, pm_message_t state)
|
||||||
netif_stop_queue(dev);
|
netif_stop_queue(dev);
|
||||||
|
|
||||||
spin_unlock_irq(&np->lock);
|
spin_unlock_irq(&np->lock);
|
||||||
enable_irq(dev->irq);
|
enable_irq(irq);
|
||||||
|
|
||||||
napi_disable(&np->napi);
|
napi_disable(&np->napi);
|
||||||
|
|
||||||
|
@ -3307,6 +3316,8 @@ static int natsemi_resume (struct pci_dev *pdev)
|
||||||
if (netif_device_present(dev))
|
if (netif_device_present(dev))
|
||||||
goto out;
|
goto out;
|
||||||
if (netif_running(dev)) {
|
if (netif_running(dev)) {
|
||||||
|
const int irq = np->pci_dev->irq;
|
||||||
|
|
||||||
BUG_ON(!np->hands_off);
|
BUG_ON(!np->hands_off);
|
||||||
ret = pci_enable_device(pdev);
|
ret = pci_enable_device(pdev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -3320,13 +3331,13 @@ static int natsemi_resume (struct pci_dev *pdev)
|
||||||
|
|
||||||
natsemi_reset(dev);
|
natsemi_reset(dev);
|
||||||
init_ring(dev);
|
init_ring(dev);
|
||||||
disable_irq(dev->irq);
|
disable_irq(irq);
|
||||||
spin_lock_irq(&np->lock);
|
spin_lock_irq(&np->lock);
|
||||||
np->hands_off = 0;
|
np->hands_off = 0;
|
||||||
init_registers(dev);
|
init_registers(dev);
|
||||||
netif_device_attach(dev);
|
netif_device_attach(dev);
|
||||||
spin_unlock_irq(&np->lock);
|
spin_unlock_irq(&np->lock);
|
||||||
enable_irq(dev->irq);
|
enable_irq(irq);
|
||||||
|
|
||||||
mod_timer(&np->timer, round_jiffies(jiffies + 1*HZ));
|
mod_timer(&np->timer, round_jiffies(jiffies + 1*HZ));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue