From cd228d5458186f66bc36c4884f4f26ed955c5945 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 12 Nov 2007 18:07:31 -0800 Subject: [PPP]: Remove ptr comparisons to 0 fix sparse warnings "Using plain integer as NULL pointer" Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- drivers/net/ppp_async.c | 34 ++++++------- drivers/net/ppp_generic.c | 126 +++++++++++++++++++++++----------------------- drivers/net/ppp_synctty.c | 27 +++++----- 3 files changed, 94 insertions(+), 93 deletions(-) (limited to 'drivers') diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c index 8d278c87ba48..f023d5b67e6e 100644 --- a/drivers/net/ppp_async.c +++ b/drivers/net/ppp_async.c @@ -160,7 +160,7 @@ ppp_asynctty_open(struct tty_struct *tty) err = -ENOMEM; ap = kzalloc(sizeof(*ap), GFP_KERNEL); - if (ap == 0) + if (!ap) goto out; /* initialize the asyncppp structure */ @@ -215,7 +215,7 @@ ppp_asynctty_close(struct tty_struct *tty) ap = tty->disc_data; tty->disc_data = NULL; write_unlock_irq(&disc_data_lock); - if (ap == 0) + if (!ap) return; /* @@ -230,10 +230,10 @@ ppp_asynctty_close(struct tty_struct *tty) tasklet_kill(&ap->tsk); ppp_unregister_channel(&ap->chan); - if (ap->rpkt != 0) + if (ap->rpkt) kfree_skb(ap->rpkt); skb_queue_purge(&ap->rqueue); - if (ap->tpkt != 0) + if (ap->tpkt) kfree_skb(ap->tpkt); kfree(ap); } @@ -285,13 +285,13 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file, int err, val; int __user *p = (int __user *)arg; - if (ap == 0) + if (!ap) return -ENXIO; err = -EFAULT; switch (cmd) { case PPPIOCGCHAN: err = -ENXIO; - if (ap == 0) + if (!ap) break; err = -EFAULT; if (put_user(ppp_channel_index(&ap->chan), p)) @@ -301,7 +301,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file, case PPPIOCGUNIT: err = -ENXIO; - if (ap == 0) + if (!ap) break; err = -EFAULT; if (put_user(ppp_unit_number(&ap->chan), p)) @@ -350,7 +350,7 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf, struct asyncppp *ap = ap_get(tty); unsigned long flags; - if (ap == 0) + if (!ap) return; spin_lock_irqsave(&ap->recv_lock, flags); ppp_async_input(ap, buf, cflags, count); @@ -369,7 +369,7 @@ ppp_asynctty_wakeup(struct tty_struct *tty) struct asyncppp *ap = ap_get(tty); clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); - if (ap == 0) + if (!ap) return; set_bit(XMIT_WAKEUP, &ap->xmit_flags); tasklet_schedule(&ap->tsk); @@ -684,7 +684,7 @@ ppp_async_push(struct asyncppp *ap) tty_stuffed = 1; continue; } - if (ap->optr >= ap->olim && ap->tpkt != 0) { + if (ap->optr >= ap->olim && ap->tpkt) { if (ppp_async_encode(ap)) { /* finished processing ap->tpkt */ clear_bit(XMIT_FULL, &ap->xmit_flags); @@ -704,7 +704,7 @@ ppp_async_push(struct asyncppp *ap) clear_bit(XMIT_BUSY, &ap->xmit_flags); /* any more work to do? if not, exit the loop */ if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags) - || (!tty_stuffed && ap->tpkt != 0))) + || (!tty_stuffed && ap->tpkt))) break; /* more work to do, see if we can do it now */ if (test_and_set_bit(XMIT_BUSY, &ap->xmit_flags)) @@ -715,7 +715,7 @@ ppp_async_push(struct asyncppp *ap) flush: clear_bit(XMIT_BUSY, &ap->xmit_flags); - if (ap->tpkt != 0) { + if (ap->tpkt) { kfree_skb(ap->tpkt); ap->tpkt = NULL; clear_bit(XMIT_FULL, &ap->xmit_flags); @@ -848,7 +848,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf, s = 0; for (i = 0; i < count; ++i) { c = buf[i]; - if (flags != 0 && flags[i] != 0) + if (flags && flags[i] != 0) continue; s |= (c & 0x80)? SC_RCV_B7_1: SC_RCV_B7_0; c = ((c >> 4) ^ c) & 0xf; @@ -865,7 +865,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf, n = scan_ordinary(ap, buf, count); f = 0; - if (flags != 0 && (ap->state & SC_TOSS) == 0) { + if (flags && (ap->state & SC_TOSS) == 0) { /* check the flags to see if any char had an error */ for (j = 0; j < n; ++j) if ((f = flags[j]) != 0) @@ -878,9 +878,9 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf, } else if (n > 0 && (ap->state & SC_TOSS) == 0) { /* stuff the chars in the skb */ skb = ap->rpkt; - if (skb == 0) { + if (!skb) { skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2); - if (skb == 0) + if (!skb) goto nomem; ap->rpkt = skb; } @@ -927,7 +927,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf, ++n; buf += n; - if (flags != 0) + if (flags) flags += n; count -= n; } diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index 4b49d0e8c7eb..4f690378bb77 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c @@ -367,7 +367,7 @@ static int ppp_release(struct inode *inode, struct file *file) struct ppp_file *pf = file->private_data; struct ppp *ppp; - if (pf != 0) { + if (pf) { file->private_data = NULL; if (pf->kind == INTERFACE) { ppp = PF_TO_PPP(pf); @@ -398,7 +398,7 @@ static ssize_t ppp_read(struct file *file, char __user *buf, ret = count; - if (pf == 0) + if (!pf) return -ENXIO; add_wait_queue(&pf->rwait, &wait); for (;;) { @@ -431,7 +431,7 @@ static ssize_t ppp_read(struct file *file, char __user *buf, set_current_state(TASK_RUNNING); remove_wait_queue(&pf->rwait, &wait); - if (skb == 0) + if (!skb) goto out; ret = -EOVERFLOW; @@ -455,11 +455,11 @@ static ssize_t ppp_write(struct file *file, const char __user *buf, struct sk_buff *skb; ssize_t ret; - if (pf == 0) + if (!pf) return -ENXIO; ret = -ENOMEM; skb = alloc_skb(count + pf->hdrlen, GFP_KERNEL); - if (skb == 0) + if (!skb) goto out; skb_reserve(skb, pf->hdrlen); ret = -EFAULT; @@ -491,11 +491,11 @@ static unsigned int ppp_poll(struct file *file, poll_table *wait) struct ppp_file *pf = file->private_data; unsigned int mask; - if (pf == 0) + if (!pf) return 0; poll_wait(file, &pf->rwait, wait); mask = POLLOUT | POLLWRNORM; - if (skb_peek(&pf->rq) != 0) + if (skb_peek(&pf->rq)) mask |= POLLIN | POLLRDNORM; if (pf->dead) mask |= POLLHUP; @@ -559,7 +559,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file, void __user *argp = (void __user *)arg; int __user *p = argp; - if (pf == 0) + if (!pf) return ppp_unattached_ioctl(pf, file, cmd, arg); if (cmd == PPPIOCDETACH) { @@ -689,13 +689,13 @@ static int ppp_ioctl(struct inode *inode, struct file *file, val &= 0xffff; } vj = slhc_init(val2+1, val+1); - if (vj == 0) { + if (!vj) { printk(KERN_ERR "PPP: no memory (VJ compressor)\n"); err = -ENOMEM; break; } ppp_lock(ppp); - if (ppp->vj != 0) + if (ppp->vj) slhc_free(ppp->vj); ppp->vj = vj; ppp_unlock(ppp); @@ -786,7 +786,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file, if (get_user(unit, p)) break; ppp = ppp_create_interface(unit, &err); - if (ppp == 0) + if (!ppp) break; file->private_data = &ppp->file; ppp->owner = file; @@ -803,7 +803,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file, mutex_lock(&all_ppp_mutex); err = -ENXIO; ppp = ppp_find_unit(unit); - if (ppp != 0) { + if (ppp) { atomic_inc(&ppp->file.refcnt); file->private_data = &ppp->file; err = 0; @@ -817,7 +817,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file, spin_lock_bh(&all_channels_lock); err = -ENXIO; chan = ppp_find_channel(unit); - if (chan != 0) { + if (chan) { atomic_inc(&chan->file.refcnt); file->private_data = &chan->file; err = 0; @@ -946,9 +946,9 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) case SIOCGPPPCSTATS: memset(&cstats, 0, sizeof(cstats)); - if (ppp->xc_state != 0) + if (ppp->xc_state) ppp->xcomp->comp_stat(ppp->xc_state, &cstats.c); - if (ppp->rc_state != 0) + if (ppp->rc_state) ppp->rcomp->decomp_stat(ppp->rc_state, &cstats.d); if (copy_to_user(addr, &cstats, sizeof(cstats))) break; @@ -993,14 +993,14 @@ ppp_xmit_process(struct ppp *ppp) struct sk_buff *skb; ppp_xmit_lock(ppp); - if (ppp->dev != 0) { + if (ppp->dev) { ppp_push(ppp); - while (ppp->xmit_pending == 0 - && (skb = skb_dequeue(&ppp->file.xq)) != 0) + while (!ppp->xmit_pending + && (skb = skb_dequeue(&ppp->file.xq))) ppp_send_frame(ppp, skb); /* If there's no work left to do, tell the core net code that we can accept some more. */ - if (ppp->xmit_pending == 0 && skb_peek(&ppp->file.xq) == 0) + if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq)) netif_wake_queue(ppp->dev); } ppp_xmit_unlock(ppp); @@ -1100,12 +1100,12 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb) switch (proto) { case PPP_IP: - if (ppp->vj == 0 || (ppp->flags & SC_COMP_TCP) == 0) + if (!ppp->vj || (ppp->flags & SC_COMP_TCP) == 0) break; /* try to do VJ TCP header compression */ new_skb = alloc_skb(skb->len + ppp->dev->hard_header_len - 2, GFP_ATOMIC); - if (new_skb == 0) { + if (!new_skb) { printk(KERN_ERR "PPP: no memory (VJ comp pkt)\n"); goto drop; } @@ -1140,7 +1140,7 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb) } /* try to do packet compression */ - if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state != 0 + if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state && proto != PPP_LCP && proto != PPP_CCP) { if (!(ppp->flags & SC_CCP_UP) && (ppp->flags & SC_MUST_COMP)) { if (net_ratelimit()) @@ -1185,7 +1185,7 @@ ppp_push(struct ppp *ppp) struct channel *pch; struct sk_buff *skb = ppp->xmit_pending; - if (skb == 0) + if (!skb) return; list = &ppp->channels; @@ -1355,7 +1355,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb) if (flen == len && nfree == 0) bits |= E; frag = alloc_skb(flen + hdrlen + (flen == 0), GFP_ATOMIC); - if (frag == 0) + if (!frag) goto noskb; q = skb_put(frag, flen + hdrlen); @@ -1425,7 +1425,7 @@ ppp_channel_push(struct channel *pch) struct ppp *ppp; spin_lock_bh(&pch->downl); - if (pch->chan != 0) { + if (pch->chan) { while (!skb_queue_empty(&pch->file.xq)) { skb = skb_dequeue(&pch->file.xq); if (!pch->chan->ops->start_xmit(pch->chan, skb)) { @@ -1443,7 +1443,7 @@ ppp_channel_push(struct channel *pch) if (skb_queue_empty(&pch->file.xq)) { read_lock_bh(&pch->upl); ppp = pch->ppp; - if (ppp != 0) + if (ppp) ppp_xmit_process(ppp); read_unlock_bh(&pch->upl); } @@ -1462,7 +1462,7 @@ ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) { ppp_recv_lock(ppp); /* ppp->dev == 0 means interface is closing down */ - if (ppp->dev != 0) + if (ppp->dev) ppp_receive_frame(ppp, skb, pch); else kfree_skb(skb); @@ -1475,19 +1475,19 @@ ppp_input(struct ppp_channel *chan, struct sk_buff *skb) struct channel *pch = chan->ppp; int proto; - if (pch == 0 || skb->len == 0) { + if (!pch || skb->len == 0) { kfree_skb(skb); return; } proto = PPP_PROTO(skb); read_lock_bh(&pch->upl); - if (pch->ppp == 0 || proto >= 0xc000 || proto == PPP_CCPFRAG) { + if (!pch->ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) { /* put it on the channel queue */ skb_queue_tail(&pch->file.rq, skb); /* drop old frames if queue too long */ while (pch->file.rq.qlen > PPP_MAX_RQLEN - && (skb = skb_dequeue(&pch->file.rq)) != 0) + && (skb = skb_dequeue(&pch->file.rq))) kfree_skb(skb); wake_up_interruptible(&pch->file.rwait); } else { @@ -1503,13 +1503,13 @@ ppp_input_error(struct ppp_channel *chan, int code) struct channel *pch = chan->ppp; struct sk_buff *skb; - if (pch == 0) + if (!pch) return; read_lock_bh(&pch->upl); - if (pch->ppp != 0) { + if (pch->ppp) { skb = alloc_skb(0, GFP_ATOMIC); - if (skb != 0) { + if (skb) { skb->len = 0; /* probably unnecessary */ skb->cb[0] = code; ppp_do_recv(pch->ppp, skb, pch); @@ -1548,7 +1548,7 @@ static void ppp_receive_error(struct ppp *ppp) { ++ppp->stats.rx_errors; - if (ppp->vj != 0) + if (ppp->vj) slhc_toss(ppp->vj); } @@ -1563,7 +1563,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb) * Note that some decompressors need to see uncompressed frames * that come in as well as compressed frames. */ - if (ppp->rc_state != 0 && (ppp->rstate & SC_DECOMP_RUN) + if (ppp->rc_state && (ppp->rstate & SC_DECOMP_RUN) && (ppp->rstate & (SC_DC_FERROR | SC_DC_ERROR)) == 0) skb = ppp_decompress_frame(ppp, skb); @@ -1574,13 +1574,13 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb) switch (proto) { case PPP_VJC_COMP: /* decompress VJ compressed packets */ - if (ppp->vj == 0 || (ppp->flags & SC_REJ_COMP_TCP)) + if (!ppp->vj || (ppp->flags & SC_REJ_COMP_TCP)) goto err; if (skb_tailroom(skb) < 124 || skb_cloned(skb)) { /* copy to a new sk_buff with more tailroom */ ns = dev_alloc_skb(skb->len + 128); - if (ns == 0) { + if (!ns) { printk(KERN_ERR"PPP: no memory (VJ decomp)\n"); goto err; } @@ -1606,7 +1606,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb) break; case PPP_VJC_UNCOMP: - if (ppp->vj == 0 || (ppp->flags & SC_REJ_COMP_TCP)) + if (!ppp->vj || (ppp->flags & SC_REJ_COMP_TCP)) goto err; /* Until we fix the decompressor need to make sure @@ -1636,7 +1636,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb) skb_queue_tail(&ppp->file.rq, skb); /* limit queue length by dropping old frames */ while (ppp->file.rq.qlen > PPP_MAX_RQLEN - && (skb = skb_dequeue(&ppp->file.rq)) != 0) + && (skb = skb_dequeue(&ppp->file.rq))) kfree_skb(skb); /* wake up any process polling or blocking on read */ wake_up_interruptible(&ppp->file.rwait); @@ -1718,7 +1718,7 @@ ppp_decompress_frame(struct ppp *ppp, struct sk_buff *skb) } ns = dev_alloc_skb(obuff_size); - if (ns == 0) { + if (!ns) { printk(KERN_ERR "ppp_decompress_frame: no memory\n"); goto err; } @@ -1836,7 +1836,7 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) ppp->minseq = ppp->mrq.next->sequence; /* Pull completed packets off the queue and receive them. */ - while ((skb = ppp_mp_reconstruct(ppp)) != 0) + while ((skb = ppp_mp_reconstruct(ppp))) ppp_receive_nonmp_frame(ppp, skb); return; @@ -2002,7 +2002,7 @@ ppp_register_channel(struct ppp_channel *chan) struct channel *pch; pch = kzalloc(sizeof(struct channel), GFP_KERNEL); - if (pch == 0) + if (!pch) return -ENOMEM; pch->ppp = NULL; pch->chan = chan; @@ -2030,7 +2030,7 @@ int ppp_channel_index(struct ppp_channel *chan) { struct channel *pch = chan->ppp; - if (pch != 0) + if (pch) return pch->file.index; return -1; } @@ -2043,9 +2043,9 @@ int ppp_unit_number(struct ppp_channel *chan) struct channel *pch = chan->ppp; int unit = -1; - if (pch != 0) { + if (pch) { read_lock_bh(&pch->upl); - if (pch->ppp != 0) + if (pch->ppp) unit = pch->ppp->file.index; read_unlock_bh(&pch->upl); } @@ -2061,7 +2061,7 @@ ppp_unregister_channel(struct ppp_channel *chan) { struct channel *pch = chan->ppp; - if (pch == 0) + if (!pch) return; /* should never happen */ chan->ppp = NULL; @@ -2093,7 +2093,7 @@ ppp_output_wakeup(struct ppp_channel *chan) { struct channel *pch = chan->ppp; - if (pch == 0) + if (!pch) return; ppp_channel_push(pch); } @@ -2124,18 +2124,18 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg) cp = find_compressor(ccp_option[0]); #ifdef CONFIG_KMOD - if (cp == 0) { + if (!cp) { request_module("ppp-compress-%d", ccp_option[0]); cp = find_compressor(ccp_option[0]); } #endif /* CONFIG_KMOD */ - if (cp == 0) + if (!cp) goto out; err = -ENOBUFS; if (data.transmit) { state = cp->comp_alloc(ccp_option, data.length); - if (state != 0) { + if (state) { ppp_xmit_lock(ppp); ppp->xstate &= ~SC_COMP_RUN; ocomp = ppp->xcomp; @@ -2143,7 +2143,7 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg) ppp->xcomp = cp; ppp->xc_state = state; ppp_xmit_unlock(ppp); - if (ostate != 0) { + if (ostate) { ocomp->comp_free(ostate); module_put(ocomp->owner); } @@ -2153,7 +2153,7 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg) } else { state = cp->decomp_alloc(ccp_option, data.length); - if (state != 0) { + if (state) { ppp_recv_lock(ppp); ppp->rstate &= ~SC_DECOMP_RUN; ocomp = ppp->rcomp; @@ -2161,7 +2161,7 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg) ppp->rcomp = cp; ppp->rc_state = state; ppp_recv_unlock(ppp); - if (ostate != 0) { + if (ostate) { ocomp->decomp_free(ostate); module_put(ocomp->owner); } @@ -2228,7 +2228,7 @@ ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound) break; if (inbound) { /* we will start receiving compressed packets */ - if (ppp->rc_state == 0) + if (!ppp->rc_state) break; if (ppp->rcomp->decomp_init(ppp->rc_state, dp, len, ppp->file.index, 0, ppp->mru, ppp->debug)) { @@ -2237,7 +2237,7 @@ ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound) } } else { /* we will soon start sending compressed packets */ - if (ppp->xc_state == 0) + if (!ppp->xc_state) break; if (ppp->xcomp->comp_init(ppp->xc_state, dp, len, ppp->file.index, 0, ppp->debug)) @@ -2320,11 +2320,11 @@ ppp_register_compressor(struct compressor *cp) int ret; spin_lock(&compressor_list_lock); ret = -EEXIST; - if (find_comp_entry(cp->compress_proto) != 0) + if (find_comp_entry(cp->compress_proto)) goto out; ret = -ENOMEM; ce = kmalloc(sizeof(struct compressor_entry), GFP_ATOMIC); - if (ce == 0) + if (!ce) goto out; ret = 0; ce->comp = cp; @@ -2342,7 +2342,7 @@ ppp_unregister_compressor(struct compressor *cp) spin_lock(&compressor_list_lock); ce = find_comp_entry(cp->compress_proto); - if (ce != 0 && ce->comp == cp) { + if (ce && ce->comp == cp) { list_del(&ce->list); kfree(ce); } @@ -2358,7 +2358,7 @@ find_compressor(int type) spin_lock(&compressor_list_lock); ce = find_comp_entry(type); - if (ce != 0) { + if (ce) { cp = ce->comp; if (!try_module_get(cp->owner)) cp = NULL; @@ -2383,7 +2383,7 @@ ppp_get_stats(struct ppp *ppp, struct ppp_stats *st) st->p.ppp_opackets = ppp->stats.tx_packets; st->p.ppp_oerrors = ppp->stats.tx_errors; st->p.ppp_obytes = ppp->stats.tx_bytes; - if (vj == 0) + if (!vj) return; st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed; st->vj.vjs_compressed = vj->sls_o_compressed; @@ -2604,11 +2604,11 @@ ppp_connect_channel(struct channel *pch, int unit) mutex_lock(&all_ppp_mutex); ppp = ppp_find_unit(unit); - if (ppp == 0) + if (!ppp) goto out; write_lock_bh(&pch->upl); ret = -EINVAL; - if (pch->ppp != 0) + if (pch->ppp) goto outl; ppp_lock(ppp); @@ -2644,7 +2644,7 @@ ppp_disconnect_channel(struct channel *pch) ppp = pch->ppp; pch->ppp = NULL; write_unlock_bh(&pch->upl); - if (ppp != 0) { + if (ppp) { /* remove it from the ppp unit's list */ ppp_lock(ppp); list_del(&pch->clist); diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c index 00e2fb48b4ae..f0c6a1926a02 100644 --- a/drivers/net/ppp_synctty.c +++ b/drivers/net/ppp_synctty.c @@ -209,7 +209,7 @@ ppp_sync_open(struct tty_struct *tty) ap = kzalloc(sizeof(*ap), GFP_KERNEL); err = -ENOMEM; - if (ap == 0) + if (!ap) goto out; /* initialize the syncppp structure */ @@ -262,7 +262,7 @@ ppp_sync_close(struct tty_struct *tty) ap = tty->disc_data; tty->disc_data = NULL; write_unlock_irq(&disc_data_lock); - if (ap == 0) + if (!ap) return; /* @@ -278,7 +278,7 @@ ppp_sync_close(struct tty_struct *tty) ppp_unregister_channel(&ap->chan); skb_queue_purge(&ap->rqueue); - if (ap->tpkt != 0) + if (ap->tpkt) kfree_skb(ap->tpkt); kfree(ap); } @@ -325,13 +325,13 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file, int __user *p = (int __user *)arg; int err, val; - if (ap == 0) + if (!ap) return -ENXIO; err = -EFAULT; switch (cmd) { case PPPIOCGCHAN: err = -ENXIO; - if (ap == 0) + if (!ap) break; err = -EFAULT; if (put_user(ppp_channel_index(&ap->chan), p)) @@ -341,7 +341,7 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file, case PPPIOCGUNIT: err = -ENXIO; - if (ap == 0) + if (!ap) break; err = -EFAULT; if (put_user(ppp_unit_number(&ap->chan), p)) @@ -390,7 +390,7 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf, struct syncppp *ap = sp_get(tty); unsigned long flags; - if (ap == 0) + if (!ap) return; spin_lock_irqsave(&ap->recv_lock, flags); ppp_sync_input(ap, buf, cflags, count); @@ -409,7 +409,7 @@ ppp_sync_wakeup(struct tty_struct *tty) struct syncppp *ap = sp_get(tty); clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); - if (ap == 0) + if (!ap) return; set_bit(XMIT_WAKEUP, &ap->xmit_flags); tasklet_schedule(&ap->tsk); @@ -651,7 +651,7 @@ ppp_sync_push(struct syncppp *ap) for (;;) { if (test_and_clear_bit(XMIT_WAKEUP, &ap->xmit_flags)) tty_stuffed = 0; - if (!tty_stuffed && ap->tpkt != 0) { + if (!tty_stuffed && ap->tpkt) { set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); sent = tty->driver->write(tty, ap->tpkt->data, ap->tpkt->len); if (sent < 0) @@ -669,7 +669,7 @@ ppp_sync_push(struct syncppp *ap) /* haven't made any progress */ spin_unlock_bh(&ap->xmit_lock); if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags) - || (!tty_stuffed && ap->tpkt != 0))) + || (!tty_stuffed && ap->tpkt))) break; if (!spin_trylock_bh(&ap->xmit_lock)) break; @@ -677,7 +677,7 @@ ppp_sync_push(struct syncppp *ap) return done; flush: - if (ap->tpkt != 0) { + if (ap->tpkt) { kfree_skb(ap->tpkt); ap->tpkt = NULL; clear_bit(XMIT_FULL, &ap->xmit_flags); @@ -732,7 +732,8 @@ ppp_sync_input(struct syncppp *ap, const unsigned char *buf, ppp_print_buffer ("receive buffer", buf, count); /* stuff the chars in the skb */ - if ((skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2)) == 0) { + skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2); + if (!skb) { printk(KERN_ERR "PPPsync: no memory (input pkt)\n"); goto err; } @@ -740,7 +741,7 @@ ppp_sync_input(struct syncppp *ap, const unsigned char *buf, if (buf[0] != PPP_ALLSTATIONS) skb_reserve(skb, 2 + (buf[0] & 1)); - if (flags != 0 && *flags) { + if (flags && *flags) { /* error flag set, ignore frame */ goto err; } else if (count > skb_tailroom(skb)) { -- cgit v1.2.3 From 62768e28d606c10ba54217f908123de34dad9374 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 12 Nov 2007 18:09:25 -0800 Subject: [SUNGEM]: Fix suspend regression due to NAPI changes. Commit bea3348e (the NAPI changes) made sungem unconditionally enable NAPI when resuming and unconditionally disable when suspending, this, however, makes napi_disable() hang when suspending when the interface was taken down before suspend because taking the interface down also disables NAPI. This patch makes touching the napi struct in suspend/resume code paths depend on having the interface up, thereby fixing the hang on suspend. The patch also moves the napi_disable() in gem_close() under the lock so that the NAPI state is always modified atomically together with the "opened" variable. Signed-off-by: Johannes Berg Acked-by: Benjamin Herrenschmidt Signed-off-by: David S. Miller --- drivers/net/sungem.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index 53b8344a68ef..f6fedcc32de1 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c @@ -2333,10 +2333,10 @@ static int gem_close(struct net_device *dev) { struct gem *gp = dev->priv; - napi_disable(&gp->napi); - mutex_lock(&gp->pm_mutex); + napi_disable(&gp->napi); + gp->opened = 0; if (!gp->asleep) gem_do_stop(dev, 0); @@ -2355,8 +2355,6 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state) mutex_lock(&gp->pm_mutex); - napi_disable(&gp->napi); - printk(KERN_INFO "%s: suspending, WakeOnLan %s\n", dev->name, (gp->wake_on_lan && gp->opened) ? "enabled" : "disabled"); @@ -2370,6 +2368,8 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state) /* If the driver is opened, we stop the MAC */ if (gp->opened) { + napi_disable(&gp->napi); + /* Stop traffic, mark us closed */ netif_device_detach(dev); @@ -2460,6 +2460,7 @@ static int gem_resume(struct pci_dev *pdev) /* Re-attach net device */ netif_device_attach(dev); + napi_enable(&gp->napi); } spin_lock_irqsave(&gp->lock, flags); @@ -2479,8 +2480,6 @@ static int gem_resume(struct pci_dev *pdev) spin_unlock(&gp->tx_lock); spin_unlock_irqrestore(&gp->lock, flags); - napi_enable(&gp->napi); - mutex_unlock(&gp->pm_mutex); return 0; -- cgit v1.2.3 From 91cf45f02af5c871251165d000c3f42a2a0b0552 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Mon, 12 Nov 2007 18:10:39 -0800 Subject: [NET]: Add the helper kernel_sock_shutdown() ...and fix a couple of bugs in the NBD, CIFS and OCFS2 socket handlers. Looking at the sock->op->shutdown() handlers, it looks as if all of them take a SHUT_RD/SHUT_WR/SHUT_RDWR argument instead of the RCV_SHUTDOWN/SEND_SHUTDOWN arguments. Add a helper, and then define the SHUT_* enum to ensure that kernel users of shutdown() don't get confused. Signed-off-by: Trond Myklebust Acked-by: Mark Fasheh Acked-by: David Howells Signed-off-by: David S. Miller --- drivers/block/nbd.c | 3 ++- fs/cifs/connect.c | 2 +- fs/ocfs2/cluster/tcp.c | 4 ++-- include/linux/net.h | 8 ++++++++ net/rxrpc/ar-local.c | 4 ++-- net/socket.c | 6 ++++++ 6 files changed, 21 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 6332acad078c..b4c0888aedc3 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -126,7 +127,7 @@ static void sock_shutdown(struct nbd_device *lo, int lock) if (lo->sock) { printk(KERN_WARNING "%s: shutting down socket\n", lo->disk->disk_name); - lo->sock->ops->shutdown(lo->sock, SEND_SHUTDOWN|RCV_SHUTDOWN); + kernel_sock_shutdown(lo->sock, SHUT_RDWR); lo->sock = NULL; } if (lock) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 1102160f6661..c52a76ff4bb9 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -160,7 +160,7 @@ cifs_reconnect(struct TCP_Server_Info *server) if (server->ssocket) { cFYI(1, ("State: 0x%x Flags: 0x%lx", server->ssocket->state, server->ssocket->flags)); - server->ssocket->ops->shutdown(server->ssocket, SEND_SHUTDOWN); + kernel_sock_shutdown(server->ssocket, SHUT_WR); cFYI(1, ("Post shutdown state: 0x%x Flags: 0x%lx", server->ssocket->state, server->ssocket->flags)); diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 685c18065c82..d84bd155997b 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -58,6 +58,7 @@ #include #include #include +#include #include #include @@ -616,8 +617,7 @@ static void o2net_shutdown_sc(struct work_struct *work) del_timer_sync(&sc->sc_idle_timeout); o2net_sc_cancel_delayed_work(sc, &sc->sc_keepalive_work); sc_put(sc); - sc->sc_sock->ops->shutdown(sc->sc_sock, - RCV_SHUTDOWN|SEND_SHUTDOWN); + kernel_sock_shutdown(sc->sc_sock, SHUT_RDWR); } /* not fatal so failed connects before the other guy has our diff --git a/include/linux/net.h b/include/linux/net.h index dd79cdb8c4cf..596131ea46f4 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -95,6 +95,12 @@ enum sock_type { #endif /* ARCH_HAS_SOCKET_TYPES */ +enum sock_shutdown_cmd { + SHUT_RD = 0, + SHUT_WR = 1, + SHUT_RDWR = 2, +}; + /** * struct socket - general BSD socket * @state: socket state (%SS_CONNECTED, etc) @@ -223,6 +229,8 @@ extern int kernel_setsockopt(struct socket *sock, int level, int optname, extern int kernel_sendpage(struct socket *sock, struct page *page, int offset, size_t size, int flags); extern int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg); +extern int kernel_sock_shutdown(struct socket *sock, + enum sock_shutdown_cmd how); #ifndef CONFIG_SMP #define SOCKOPS_WRAPPED(name) name diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c index fe03f71f17da..f3a2bd747a8f 100644 --- a/net/rxrpc/ar-local.c +++ b/net/rxrpc/ar-local.c @@ -114,7 +114,7 @@ static int rxrpc_create_local(struct rxrpc_local *local) return 0; error: - local->socket->ops->shutdown(local->socket, 2); + kernel_sock_shutdown(local->socket, SHUT_RDWR); local->socket->sk->sk_user_data = NULL; sock_release(local->socket); local->socket = NULL; @@ -267,7 +267,7 @@ static void rxrpc_destroy_local(struct work_struct *work) /* finish cleaning up the local descriptor */ rxrpc_purge_queue(&local->accept_queue); rxrpc_purge_queue(&local->reject_queue); - local->socket->ops->shutdown(local->socket, 2); + kernel_sock_shutdown(local->socket, SHUT_RDWR); sock_release(local->socket); up_read(&rxrpc_local_sem); diff --git a/net/socket.c b/net/socket.c index 5d879fd3d01d..74784dfe8e5b 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2319,6 +2319,11 @@ int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg) return err; } +int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how) +{ + return sock->ops->shutdown(sock, how); +} + /* ABI emulation layers need these two */ EXPORT_SYMBOL(move_addr_to_kernel); EXPORT_SYMBOL(move_addr_to_user); @@ -2345,3 +2350,4 @@ EXPORT_SYMBOL(kernel_getsockopt); EXPORT_SYMBOL(kernel_setsockopt); EXPORT_SYMBOL(kernel_sendpage); EXPORT_SYMBOL(kernel_sock_ioctl); +EXPORT_SYMBOL(kernel_sock_shutdown); -- cgit v1.2.3 From 57ce45dd16cd427ac2bdef202daf513bd25d650b Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Mon, 12 Nov 2007 21:03:58 -0800 Subject: [NET]: Remove references to net-modules.txt. When I removed net-modules.txt because it only contained ancient information I missed that many Kconfig entries pointed to this ancient information. Signed-off-by: Adrian Bunk Signed-off-by: David S. Miller --- Documentation/networking/3c505.txt | 3 +- drivers/net/Kconfig | 199 +++++++++++++------------------------ drivers/net/arcnet/Kconfig | 15 +-- drivers/net/tulip/Kconfig | 21 ++-- 4 files changed, 82 insertions(+), 156 deletions(-) (limited to 'drivers') diff --git a/Documentation/networking/3c505.txt b/Documentation/networking/3c505.txt index b9d5b7230118..72f38b13101d 100644 --- a/Documentation/networking/3c505.txt +++ b/Documentation/networking/3c505.txt @@ -14,8 +14,7 @@ If no base address is given at boot time, the driver will autoprobe ports 0x300, 0x280 and 0x310 (in that order). If no IRQ is given, the driver will try to probe for it. -The driver can be used as a loadable module. See net-modules.txt for details -of the parameters it can take. +The driver can be used as a loadable module. Theoretically, one instance of the driver can now run multiple cards, in the standard way (when loading a module, say "modprobe 3c505 diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index bf8890ebbc4c..e8d69b0adf90 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -366,8 +366,7 @@ config MAC89x0 read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . This module will + To compile this driver as a module, choose M here. This module will be called mac89x0. config MACSONIC @@ -380,8 +379,7 @@ config MACSONIC one of these say Y and read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . This module will + To compile this driver as a module, choose M here. This module will be called macsonic. config MACMACE @@ -619,8 +617,7 @@ config EL1 have problems. Some people suggest to ping ("man ping") a nearby machine every minute ("man cron") when using this card. - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called 3c501. config EL2 @@ -632,8 +629,7 @@ config EL2 the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called 3c503. config ELPLUS @@ -645,8 +641,7 @@ config ELPLUS this type, say Y and read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called 3c505. config EL16 @@ -657,8 +652,7 @@ config EL16 the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called 3c507. config EL3 @@ -673,8 +667,7 @@ config EL3 setup disk to disable Plug & Play mode, and to select the default media type. - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called 3c509. config 3C515 @@ -685,8 +678,7 @@ config 3C515 network card, say Y and read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called 3c515. config ELMC @@ -697,8 +689,7 @@ config ELMC the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called 3c523. config ELMC_II @@ -709,8 +700,7 @@ config ELMC_II the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called 3c527. config VORTEX @@ -733,8 +723,7 @@ config VORTEX and in the comments at the beginning of . - To compile this support as a module, choose M here and read - . + To compile this support as a module, choose M here. config TYPHOON tristate "3cr990 series \"Typhoon\" support" @@ -751,8 +740,7 @@ config TYPHOON the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called typhoon. config LANCE @@ -789,8 +777,7 @@ config WD80x3 the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called wd. config ULTRAMCA @@ -802,8 +789,7 @@ config ULTRAMCA an MCA based system (PS/2), say Y and read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called smc-mca. config ULTRA @@ -822,8 +808,7 @@ config ULTRA this but keep it in mind if you have such a SCSI card and have problems. - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called smc-ultra. config ULTRA32 @@ -835,8 +820,7 @@ config ULTRA32 the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called smc-ultra32. config BFIN_MAC @@ -897,8 +881,7 @@ config SMC9194 and the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called smc9194. config SMC91X @@ -916,8 +899,7 @@ config SMC91X This driver is also available as a module ( = code which can be inserted in and removed from the running kernel whenever you want). The module will be called smc91x. If you want to compile it as a - module, say M here and read - as well as . + module, say M here and read . config NET_NETX tristate "NetX Ethernet support" @@ -926,8 +908,7 @@ config NET_NETX help This is support for the Hilscher netX builtin Ethernet ports - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called netx-eth. config DM9000 @@ -938,9 +919,8 @@ config DM9000 ---help--- Support for DM9000 chipset. - To compile this driver as a module, choose M here and read - . The module will be - called dm9000. + To compile this driver as a module, choose M here. The module + will be called dm9000. config SMC911X tristate "SMSC LAN911[5678] support" @@ -980,8 +960,7 @@ config NI5010 . Note that this is still experimental code. - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called ni5010. config NI52 @@ -992,8 +971,7 @@ config NI52 the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called ni52. config NI65 @@ -1004,8 +982,7 @@ config NI65 the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called ni65. source "drivers/net/tulip/Kconfig" @@ -1019,8 +996,7 @@ config AT1700 the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called at1700. config DEPCA @@ -1033,8 +1009,7 @@ config DEPCA as well as . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called depca. config HP100 @@ -1045,8 +1020,7 @@ config HP100 the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called hp100. config NET_ISA @@ -1075,8 +1049,7 @@ config E2100 the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called e2100. config EWRK3 @@ -1090,8 +1063,7 @@ config EWRK3 well as the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called ewrk3. config EEXPRESS @@ -1105,8 +1077,7 @@ config EEXPRESS because the driver was very unreliable. We now have a new driver that should do better. - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called eexpress. config EEXPRESS_PRO @@ -1119,8 +1090,7 @@ config EEXPRESS_PRO driver. Please read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called eepro. config HPLAN_PLUS @@ -1132,8 +1102,7 @@ config HPLAN_PLUS the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called hp-plus. config HPLAN @@ -1145,8 +1114,7 @@ config HPLAN the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called hp. config LP486E @@ -1165,8 +1133,7 @@ config ETH16I the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called eth16i. config NE2000 @@ -1186,8 +1153,7 @@ config NE2000 laptops), say N here and Y to "NE/2 (ne2000 MCA version) support", below. - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called ne. config ZNET @@ -1208,8 +1174,7 @@ config SEEQ8005 is for you, read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called seeq8005. config NE2_MCA @@ -1221,8 +1186,7 @@ config NE2_MCA the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called ne2. config IBMLANA @@ -1233,8 +1197,7 @@ config IBMLANA CONFIG_MCA to use this driver. It is both available as an in-kernel driver and as a module. - To compile this driver as a module, choose M here and read - . The only + To compile this driver as a module, choose M here. The only currently supported card is the IBM LAN Adapter/A for Ethernet. It will both support 16K and 32K memory windows, however a 32K window gives a better security against packet losses. Usage of multiple @@ -1248,8 +1211,7 @@ config IBMVETH This driver supports virtual ethernet adapters on newer IBM iSeries and pSeries systems. - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called ibmveth. source "drivers/net/ibm_emac/Kconfig" @@ -1279,8 +1241,7 @@ config PCNET32 answer Y here and read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called pcnet32. config PCNET32_NAPI @@ -1307,8 +1268,7 @@ config AMD8111_ETH answer Y here and read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called amd8111e. config AMD8111E_NAPI @@ -1362,8 +1322,7 @@ config AC3200 the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called ac3200. config APRICOT @@ -1374,9 +1333,8 @@ config APRICOT read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module will be - called apricot. + To compile this driver as a module, choose M here. The module + will be called apricot. config B44 tristate "Broadcom 440x/47xx ethernet support" @@ -1388,9 +1346,8 @@ config B44 or M and read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module will be - called b44. + To compile this driver as a module, choose M here. The module + will be called b44. # Auto-select SSB PCI-HOST support, if possible config B44_PCI_AUTOSELECT @@ -1419,9 +1376,8 @@ config FORCEDETH read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module will be - called forcedeth. + To compile this driver as a module, choose M here. The module + will be called forcedeth. config FORCEDETH_NAPI bool "Use Rx Polling (NAPI) (EXPERIMENTAL)" @@ -1447,9 +1403,8 @@ config CS89x0 as well as . - To compile this driver as a module, choose M here and read - . The module will be - called cs89x0. + To compile this driver as a module, choose M here. The module + will be called cs89x0. config TC35815 tristate "TOSHIBA TC35815 Ethernet support" @@ -1465,8 +1420,7 @@ config EEPRO100 card, say Y and read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called eepro100. @@ -1493,8 +1447,7 @@ config E100 More specific information on configuring the driver is in . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called e100. config LNE390 @@ -1506,8 +1459,7 @@ config LNE390 the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called lne390. config FEALNX @@ -1547,8 +1499,7 @@ config NE2K_PCI NetVin NV5000SC Via 86C926 SureCom NE34 Winbond Holtek HT80232 Holtek HT80229 - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called ne2k-pci. config NE3210 @@ -1561,8 +1512,7 @@ config NE3210 . Note that this driver will NOT WORK for NE3200 cards as they are completely different. - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called ne3210. config ES3210 @@ -1574,8 +1524,7 @@ config ES3210 the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called es3210. config 8139CP @@ -1705,8 +1654,7 @@ config TLAN Compaq NetFlex and Olicom cards. Please read the file for more details. - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called tlan. Please email feedback to . @@ -1996,8 +1944,7 @@ config E1000 More specific information on configuring the driver is in . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called e1000. config E1000_NAPI @@ -2042,8 +1989,7 @@ config E1000E More specific information on configuring the driver is in . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called e1000e. source "drivers/net/ixp2000/Kconfig" @@ -2076,8 +2022,7 @@ config HAMACHI the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module will be + To compile this driver as a module, choose M here. The module will be called hamachi. config YELLOWFIN @@ -2526,8 +2471,7 @@ config IXGBE More specific information on configuring the driver is in . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called ixgbe. config IXGB @@ -2549,8 +2493,7 @@ config IXGB More specific information on configuring the driver is in . - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called ixgb. config IXGB_NAPI @@ -2603,8 +2546,7 @@ config MYRI10GE - To compile this driver as a module, choose M here and read - . The module + To compile this driver as a module, choose M here. The module will be called myri10ge. config NETXEN_NIC @@ -2828,10 +2770,9 @@ config PLIP with the PLIP support in Linux versions 1.0.x. This option enlarges your kernel by about 8 KB. - To compile this driver as a module, choose M here and read - . The module will be - called plip. If unsure, say Y or M, in case you buy a laptop - later. + To compile this driver as a module, choose M here. The module + will be called plip. If unsure, say Y or M, in case you buy + a laptop later. config PPP tristate "PPP (point-to-point protocol) support" @@ -2861,8 +2802,7 @@ config PPP If you said Y to "Version information on all symbols" above, then you cannot compile the PPP driver into the kernel; you can then only compile it as a module. To compile this driver as a module, choose M - here and read . - The module will be called ppp_generic. + here. The module will be called ppp_generic. config PPP_MULTILINK bool "PPP multilink support (EXPERIMENTAL)" @@ -3023,9 +2963,8 @@ config SLIP ). SLIP support will enlarge your kernel by about 4 KB. If unsure, say N. - To compile this driver as a module, choose M here and read - . The module will be - called slip. + To compile this driver as a module, choose M here. The module + will be called slip. config SLIP_COMPRESSED bool "CSLIP compressed headers" diff --git a/drivers/net/arcnet/Kconfig b/drivers/net/arcnet/Kconfig index 4030274fe788..3b2f7f115464 100644 --- a/drivers/net/arcnet/Kconfig +++ b/drivers/net/arcnet/Kconfig @@ -19,8 +19,7 @@ menuconfig ARCNET from (even though ARCnet is not really Ethernet). - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called arcnet. if ARCNET @@ -81,8 +80,7 @@ config ARCNET_COM90xx have always used the old ARCnet driver without knowing what type of card you had, this is probably the one for you. - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called com90xx. config ARCNET_COM90xxIO @@ -93,8 +91,7 @@ config ARCNET_COM90xxIO the normal driver. Only use it if your card doesn't support shared memory. - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called com90io. config ARCNET_RIM_I @@ -105,8 +102,7 @@ config ARCNET_RIM_I driver is completely untested, so if you have one of these cards, please mail , especially if it works! - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called arc-rimi. config ARCNET_COM20020 @@ -116,8 +112,7 @@ config ARCNET_COM20020 things as promiscuous mode, so packet sniffing is possible, and extra diagnostic information. - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called com20020. config ARCNET_COM20020_ISA diff --git a/drivers/net/tulip/Kconfig b/drivers/net/tulip/Kconfig index 49d7a290dbbc..20ac1503021e 100644 --- a/drivers/net/tulip/Kconfig +++ b/drivers/net/tulip/Kconfig @@ -24,8 +24,7 @@ config DE2104X will say Y here.) Do read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called de2104x. config TULIP @@ -42,8 +41,7 @@ config TULIP will say Y here.) Do read the Ethernet-HOWTO, available from . - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called tulip. config TULIP_MWI @@ -104,8 +102,7 @@ config DE4X5 information is contained in . - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called de4x5. config WINBOND_840 @@ -129,8 +126,7 @@ config DM9102 (Ethernet) card, say Y. Some information is contained in the file . - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called dmfe. config ULI526X @@ -141,8 +137,7 @@ config ULI526X This driver is for ULi M5261/M5263 10/100M Ethernet Controller (). - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called uli526x. config PCMCIA_XIRCOM @@ -154,8 +149,7 @@ config PCMCIA_XIRCOM as with work-alike chips from Lite-On (PNIC) and Macronix (MXIC) and ASIX. - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called xircom_cb. If unsure, say N. config PCMCIA_XIRTULIP @@ -168,8 +162,7 @@ config PCMCIA_XIRTULIP as with work-alike chips from Lite-On (PNIC) and Macronix (MXIC) and ASIX. - To compile this driver as a module, choose M here and read - . The module will + To compile this driver as a module, choose M here. The module will be called xircom_tulip_cb. If unsure, say N. endif # NET_TULIP -- cgit v1.2.3 From c88864df27590b80fca4a991e0c257d1757cec41 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:07:01 -0800 Subject: [TG3]: Fix 5761 PXEboot crash When 5761 devices boot the machine using PXEboot, PXE leaves the device active when it terminates. The tg3 driver has code to detect this condition and resets the device during initialization. On 5761 devices, device resets involve sending a driver state update message to the APE on the 5761. However, during this initialization stage, communications to the APE registers have not yet been set up. The driver then dereferences a NULL pointer and crashes the machine. The fix is to move the APE register access setup earlier in the initialization code to cover this condition. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index cad519910767..ddeaa0c78305 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -12464,6 +12464,28 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, goto err_out_iounmap; } + if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) { + if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) { + printk(KERN_ERR PFX "Cannot find proper PCI device " + "base address for APE, aborting.\n"); + err = -ENODEV; + goto err_out_iounmap; + } + + tg3reg_base = pci_resource_start(pdev, 2); + tg3reg_len = pci_resource_len(pdev, 2); + + tp->aperegs = ioremap_nocache(tg3reg_base, tg3reg_len); + if (tp->aperegs == 0UL) { + printk(KERN_ERR PFX "Cannot map APE registers, " + "aborting.\n"); + err = -ENOMEM; + goto err_out_iounmap; + } + + tg3_ape_lock_init(tp); + } + /* * Reset chip in case UNDI or EFI driver did not shutdown * DMA self test will enable WDMAC and we'll see (spurious) @@ -12478,7 +12500,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, err = tg3_test_dma(tp); if (err) { printk(KERN_ERR PFX "DMA engine test failed, aborting.\n"); - goto err_out_iounmap; + goto err_out_apeunmap; } /* Tigon3 can do ipv4 only... and some chips have buggy @@ -12501,28 +12523,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, tg3_init_coal(tp); - if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) { - if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) { - printk(KERN_ERR PFX "Cannot find proper PCI device " - "base address for APE, aborting.\n"); - err = -ENODEV; - goto err_out_iounmap; - } - - tg3reg_base = pci_resource_start(pdev, 2); - tg3reg_len = pci_resource_len(pdev, 2); - - tp->aperegs = ioremap_nocache(tg3reg_base, tg3reg_len); - if (tp->aperegs == 0UL) { - printk(KERN_ERR PFX "Cannot map APE registers, " - "aborting.\n"); - err = -ENOMEM; - goto err_out_iounmap; - } - - tg3_ape_lock_init(tp); - } - pci_set_drvdata(pdev, dev); err = register_netdev(dev); -- cgit v1.2.3 From ce057f01956bfcb3cb8588091000ae546be78e00 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:08:03 -0800 Subject: [TG3]: 5784 / 5764 GPHY power down fix 5784 and 5764 devices fail to link / pass traffic after one load / unload cycle. This happens because of a hardware bug in the new CPMU. During normal operation, the MAC depends on the PHY clock being available. When the PHY is powered down, the clock the MAC depends on is disabled. The fix is to switch the MAC clock to an alternate source before powering down the PHY, and to restore the MAC clock to the PHY source upon device resume. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 26 ++++++++++++++++++++++++-- drivers/net/tg3.h | 9 ++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index ddeaa0c78305..82b1cf0e2d18 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -1106,6 +1106,19 @@ static int tg3_phy_reset(struct tg3 *tp) if (err) return err; + if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || + tp->pci_chip_rev_id == CHIPREV_ID_5761_A0) { + u32 val; + + val = tr32(TG3_CPMU_LSPD_1000MB_CLK); + if ((val & CPMU_LSPD_1000MB_MACCLK_MASK) == + CPMU_LSPD_1000MB_MACCLK_12_5) { + val &= ~CPMU_LSPD_1000MB_MACCLK_MASK; + udelay(40); + tw32_f(TG3_CPMU_LSPD_1000MB_CLK, val); + } + } + out: if (tp->tg3_flags2 & TG3_FLG2_PHY_ADC_BUG) { tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); @@ -1297,6 +1310,8 @@ static void tg3_nvram_unlock(struct tg3 *); static void tg3_power_down_phy(struct tg3 *tp) { + u32 val; + if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) { if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { u32 sg_dig_ctrl = tr32(SG_DIG_CTRL); @@ -1311,8 +1326,6 @@ static void tg3_power_down_phy(struct tg3 *tp) } if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { - u32 val; - tg3_bmcr_reset(tp); val = tr32(GRC_MISC_CFG); tw32_f(GRC_MISC_CFG, val | GRC_MISC_CFG_EPHY_IDDQ); @@ -1332,6 +1345,15 @@ static void tg3_power_down_phy(struct tg3 *tp) (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780 && (tp->tg3_flags2 & TG3_FLG2_MII_SERDES))) return; + + if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || + tp->pci_chip_rev_id == CHIPREV_ID_5761_A0) { + val = tr32(TG3_CPMU_LSPD_1000MB_CLK); + val &= ~CPMU_LSPD_1000MB_MACCLK_MASK; + val |= CPMU_LSPD_1000MB_MACCLK_12_5; + tw32_f(TG3_CPMU_LSPD_1000MB_CLK, val); + } + tg3_writephy(tp, MII_BMCR, BMCR_PDOWN); } diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index 1d5b2a3dd29d..4659697beb4b 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h @@ -109,6 +109,7 @@ #define CHIPREV_ID_5714_A2 0x9002 #define CHIPREV_ID_5906_A1 0xc001 #define CHIPREV_ID_5784_A0 0x5784000 +#define CHIPREV_ID_5761_A0 0x5761000 #define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12) #define ASIC_REV_5700 0x07 #define ASIC_REV_5701 0x00 @@ -856,7 +857,13 @@ #define CPMU_CTRL_LINK_IDLE_MODE 0x00000200 #define CPMU_CTRL_LINK_AWARE_MODE 0x00000400 #define CPMU_CTRL_LINK_SPEED_MODE 0x00004000 -/* 0x3604 --> 0x365c unused */ +/* 0x3604 --> 0x360c unused */ + +#define TG3_CPMU_LSPD_1000MB_CLK 0x0000360c +#define CPMU_LSPD_1000MB_MACCLK_62_5 0x00000000 +#define CPMU_LSPD_1000MB_MACCLK_12_5 0x00110000 +#define CPMU_LSPD_1000MB_MACCLK_MASK 0x001f0000 +/* 0x3610 --> 0x365c unused */ #define TG3_CPMU_MUTEX_REQ 0x0000365c #define CPMU_MUTEX_REQ_DRIVER 0x00001000 -- cgit v1.2.3 From 84af67fdf07c4fce664dbca87a8d5e2802901bff Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:08:59 -0800 Subject: [TG3]: APE flag fix This patch corrects a bug where the ENABLE_APE flag was tested against the wrong flag variable. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 82b1cf0e2d18..833cb9b7f343 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -10881,7 +10881,7 @@ static void __devinit tg3_read_fw_ver(struct tg3 *tp) } if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF) || - (tp->tg3_flags & TG3_FLG3_ENABLE_APE)) + (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE)) return; for (offset = TG3_NVM_DIR_START; -- cgit v1.2.3 From 9acb961e7d780291659bf950b3b718ff9e085620 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:10:06 -0800 Subject: [TG3]: 5784 / 5764 DMA engine lockup fix 5784 and 5764 devices lock up when the link speed is 10Mbps, the CPMU link speed mode is enabled, and the MAC clock is running at 1.5Mhz. The fix is to run the MAC clock at faster speeds. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 15 +++++++++++++++ drivers/net/tg3.h | 15 +++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 833cb9b7f343..b865c5d44837 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -6369,6 +6369,21 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) val = tr32(TG3_CPMU_CTRL); val &= ~(CPMU_CTRL_LINK_AWARE_MODE | CPMU_CTRL_LINK_IDLE_MODE); tw32(TG3_CPMU_CTRL, val); + + val = tr32(TG3_CPMU_LSPD_10MB_CLK); + val &= ~CPMU_LSPD_10MB_MACCLK_MASK; + val |= CPMU_LSPD_10MB_MACCLK_6_25; + tw32(TG3_CPMU_LSPD_10MB_CLK, val); + + val = tr32(TG3_CPMU_LNK_AWARE_PWRMD); + val &= ~CPMU_LNK_AWARE_MACCLK_MASK; + val |= CPMU_LNK_AWARE_MACCLK_6_25; + tw32(TG3_CPMU_LNK_AWARE_PWRMD, val); + + val = tr32(TG3_CPMU_HST_ACC); + val &= ~CPMU_HST_ACC_MACCLK_MASK; + val |= CPMU_HST_ACC_MACCLK_6_25; + tw32(TG3_CPMU_HST_ACC, val); } /* This works around an issue with Athlon chipsets on diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index 4659697beb4b..c6aad49a375d 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h @@ -857,13 +857,24 @@ #define CPMU_CTRL_LINK_IDLE_MODE 0x00000200 #define CPMU_CTRL_LINK_AWARE_MODE 0x00000400 #define CPMU_CTRL_LINK_SPEED_MODE 0x00004000 -/* 0x3604 --> 0x360c unused */ +#define TG3_CPMU_LSPD_10MB_CLK 0x00003604 +#define CPMU_LSPD_10MB_MACCLK_MASK 0x001f0000 +#define CPMU_LSPD_10MB_MACCLK_6_25 0x00130000 +/* 0x3608 --> 0x360c unused */ #define TG3_CPMU_LSPD_1000MB_CLK 0x0000360c #define CPMU_LSPD_1000MB_MACCLK_62_5 0x00000000 #define CPMU_LSPD_1000MB_MACCLK_12_5 0x00110000 #define CPMU_LSPD_1000MB_MACCLK_MASK 0x001f0000 -/* 0x3610 --> 0x365c unused */ +#define TG3_CPMU_LNK_AWARE_PWRMD 0x00003610 +#define CPMU_LNK_AWARE_MACCLK_MASK 0x001f0000 +#define CPMU_LNK_AWARE_MACCLK_6_25 0x00130000 +/* 0x3614 --> 0x361c unused */ + +#define TG3_CPMU_HST_ACC 0x0000361c +#define CPMU_HST_ACC_MACCLK_MASK 0x001f0000 +#define CPMU_HST_ACC_MACCLK_6_25 0x00130000 +/* 0x3620 --> 0x365c unused */ #define TG3_CPMU_MUTEX_REQ 0x0000365c #define CPMU_MUTEX_REQ_DRIVER 0x00001000 -- cgit v1.2.3 From a5767dec1980463aef5614b7ad8a800bb4f4c353 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:10:58 -0800 Subject: [TG3]: Fix nvram selftest failures Newer devices contain bootcode in the chip's private ROM area. This bootcode is called selfboot. Selfboot can be patched in the device's NVRAM and the patches can have several formats. In one particular format, the checksum calculation needs to be slightly modified. This patch adjusts the NVRAM test code for that case, and add support for the missing formats. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 36 ++++++++++++++++++++++++++++++------ drivers/net/tg3.h | 8 ++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index b865c5d44837..ef849b1eb110 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -8701,7 +8701,9 @@ static void tg3_get_ethtool_stats (struct net_device *dev, } #define NVRAM_TEST_SIZE 0x100 -#define NVRAM_SELFBOOT_FORMAT1_SIZE 0x14 +#define NVRAM_SELFBOOT_FORMAT1_0_SIZE 0x14 +#define NVRAM_SELFBOOT_FORMAT1_2_SIZE 0x18 +#define NVRAM_SELFBOOT_FORMAT1_3_SIZE 0x1c #define NVRAM_SELFBOOT_HW_SIZE 0x20 #define NVRAM_SELFBOOT_DATA_SIZE 0x1c @@ -8716,9 +8718,22 @@ static int tg3_test_nvram(struct tg3 *tp) if (magic == TG3_EEPROM_MAGIC) size = NVRAM_TEST_SIZE; else if ((magic & TG3_EEPROM_MAGIC_FW_MSK) == TG3_EEPROM_MAGIC_FW) { - if ((magic & 0xe00000) == 0x200000) - size = NVRAM_SELFBOOT_FORMAT1_SIZE; - else + if ((magic & TG3_EEPROM_SB_FORMAT_MASK) == + TG3_EEPROM_SB_FORMAT_1) { + switch (magic & TG3_EEPROM_SB_REVISION_MASK) { + case TG3_EEPROM_SB_REVISION_0: + size = NVRAM_SELFBOOT_FORMAT1_0_SIZE; + break; + case TG3_EEPROM_SB_REVISION_2: + size = NVRAM_SELFBOOT_FORMAT1_2_SIZE; + break; + case TG3_EEPROM_SB_REVISION_3: + size = NVRAM_SELFBOOT_FORMAT1_3_SIZE; + break; + default: + return 0; + } + } else return 0; } else if ((magic & TG3_EEPROM_MAGIC_HW_MSK) == TG3_EEPROM_MAGIC_HW) size = NVRAM_SELFBOOT_HW_SIZE; @@ -8745,8 +8760,17 @@ static int tg3_test_nvram(struct tg3 *tp) TG3_EEPROM_MAGIC_FW) { u8 *buf8 = (u8 *) buf, csum8 = 0; - for (i = 0; i < size; i++) - csum8 += buf8[i]; + if ((cpu_to_be32(buf[0]) & TG3_EEPROM_SB_REVISION_MASK) == + TG3_EEPROM_SB_REVISION_2) { + /* For rev 2, the csum doesn't include the MBA. */ + for (i = 0; i < TG3_EEPROM_SB_F1R2_MBA_OFF; i++) + csum8 += buf8[i]; + for (i = TG3_EEPROM_SB_F1R2_MBA_OFF + 4; i < size; i++) + csum8 += buf8[i]; + } else { + for (i = 0; i < size; i++) + csum8 += buf8[i]; + } if (csum8 == 0) { err = 0; diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index c6aad49a375d..f715b35dfd54 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h @@ -1555,6 +1555,12 @@ #define TG3_EEPROM_MAGIC 0x669955aa #define TG3_EEPROM_MAGIC_FW 0xa5000000 #define TG3_EEPROM_MAGIC_FW_MSK 0xff000000 +#define TG3_EEPROM_SB_FORMAT_MASK 0x00e00000 +#define TG3_EEPROM_SB_FORMAT_1 0x00200000 +#define TG3_EEPROM_SB_REVISION_MASK 0x001f0000 +#define TG3_EEPROM_SB_REVISION_0 0x00000000 +#define TG3_EEPROM_SB_REVISION_2 0x00020000 +#define TG3_EEPROM_SB_REVISION_3 0x00030000 #define TG3_EEPROM_MAGIC_HW 0xabcd #define TG3_EEPROM_MAGIC_HW_MSK 0xffff @@ -1765,6 +1771,8 @@ /* APE convenience enumerations. */ #define TG3_APE_LOCK_MEM 4 +#define TG3_EEPROM_SB_F1R2_MBA_OFF 0x10 + /* There are two ways to manage the TX descriptors on the tigon3. * Either the descriptors are in host DMA'able memory, or they -- cgit v1.2.3 From e875093c9659d2a9f3923aa9ee1b89ef40cf95b9 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:11:51 -0800 Subject: [TG3]: CPMU adjustments for loopback tests This patch adds the LINK_SPEED mode to the list of CPMU modes that can cause the loopback tests to fail. These bugs are planned to be fixed in future revisions of the chip, so the patch qualifies the fixes as such. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index ef849b1eb110..25e57d8ddb51 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -9354,7 +9354,8 @@ static int tg3_test_loopback(struct tg3 *tp) if (err) return TG3_LOOPBACK_FAILED; - if (tp->tg3_flags & TG3_FLAG_CPMU_PRESENT) { + if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || + tp->pci_chip_rev_id == CHIPREV_ID_5761_A0) { int i; u32 status; @@ -9371,17 +9372,18 @@ static int tg3_test_loopback(struct tg3 *tp) if (status != CPMU_MUTEX_GNT_DRIVER) return TG3_LOOPBACK_FAILED; - cpmuctrl = tr32(TG3_CPMU_CTRL); - /* Turn off power management based on link speed. */ + cpmuctrl = tr32(TG3_CPMU_CTRL); tw32(TG3_CPMU_CTRL, - cpmuctrl & ~CPMU_CTRL_LINK_SPEED_MODE); + cpmuctrl & ~(CPMU_CTRL_LINK_SPEED_MODE | + CPMU_CTRL_LINK_AWARE_MODE)); } if (tg3_run_loopback(tp, TG3_MAC_LOOPBACK)) err |= TG3_MAC_LOOPBACK_FAILED; - if (tp->tg3_flags & TG3_FLAG_CPMU_PRESENT) { + if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || + tp->pci_chip_rev_id == CHIPREV_ID_5761_A0) { tw32(TG3_CPMU_CTRL, cpmuctrl); /* Release the mutex */ -- cgit v1.2.3 From 662f38d242488cfdcda7b3684ac610d3e4d568a7 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:16:17 -0800 Subject: [TG3]: Disable GPHY autopowerdown New CPMU devices contend with the GPHY for power management. The GPHY autopowerdown feature is enabled by default in the PHY and thus needs to be disabled after every PHY reset. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 6 ++++++ drivers/net/tg3.h | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 25e57d8ddb51..b5c4799003e0 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -1117,6 +1117,12 @@ static int tg3_phy_reset(struct tg3 *tp) udelay(40); tw32_f(TG3_CPMU_LSPD_1000MB_CLK, val); } + + /* Disable GPHY autopowerdown. */ + tg3_writephy(tp, MII_TG3_MISC_SHDW, + MII_TG3_MISC_SHDW_WREN | + MII_TG3_MISC_SHDW_APD_SEL | + MII_TG3_MISC_SHDW_APD_WKTM_84MS); } out: diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index f715b35dfd54..5b799ff2c4d6 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h @@ -1715,6 +1715,12 @@ #define MII_TG3_ISTAT 0x1a /* IRQ status register */ #define MII_TG3_IMASK 0x1b /* IRQ mask register */ +#define MII_TG3_MISC_SHDW 0x1c +#define MII_TG3_MISC_SHDW_WREN 0x8000 +#define MII_TG3_MISC_SHDW_APD_SEL 0x2800 + +#define MII_TG3_MISC_SHDW_APD_WKTM_84MS 0x0001 + /* ISTAT/IMASK event bits */ #define MII_TG3_INT_LINKCHG 0x0002 #define MII_TG3_INT_SPEEDCHG 0x0004 -- cgit v1.2.3 From 5f60891b80f1a0f0a0015b084f4838ae8b9637c7 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:17:07 -0800 Subject: [TG3]: Limit 5784 / 5764 to MAC LED mode Most 5784 / 5764 LED modes do not work as expected because of a hardware bug. This patch forces the LED mode to be in MAC LED mode. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index b5c4799003e0..bb3b73435170 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -10610,6 +10610,9 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL) tp->led_ctrl = LED_CTRL_MODE_PHY_2; + if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0) + tp->led_ctrl = LED_CTRL_MODE_MAC; + if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) { tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; if ((tp->pdev->subsystem_vendor == -- cgit v1.2.3 From aa6c91fe5913faa2cd2a62de993a3130799412b1 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:18:04 -0800 Subject: [TG3]: Prescaler fix Internal hardware timers become inaccurate after link events. Clock frequency switches performed by the CPMU fail to adjust timer prescalers. The fix is to detect core clock frequency changes during link events and adjust the timer prescalers accordingly. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 16 ++++++++++++++++ drivers/net/tg3.h | 9 ++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index bb3b73435170..ecd64a224e95 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -3154,6 +3154,22 @@ static int tg3_setup_phy(struct tg3 *tp, int force_reset) err = tg3_setup_copper_phy(tp, force_reset); } + if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0) { + u32 val, scale; + + val = tr32(TG3_CPMU_CLCK_STAT) & CPMU_CLCK_STAT_MAC_CLCK_MASK; + if (val == CPMU_CLCK_STAT_MAC_CLCK_62_5) + scale = 65; + else if (val == CPMU_CLCK_STAT_MAC_CLCK_6_25) + scale = 6; + else + scale = 12; + + val = tr32(GRC_MISC_CFG) & ~GRC_MISC_CFG_PRESCALAR_MASK; + val |= (scale << GRC_MISC_CFG_PRESCALAR_SHIFT); + tw32(GRC_MISC_CFG, val); + } + if (tp->link_config.active_speed == SPEED_1000 && tp->link_config.active_duplex == DUPLEX_HALF) tw32(MAC_TX_LENGTHS, diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index 5b799ff2c4d6..d325ab59b391 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h @@ -874,7 +874,14 @@ #define TG3_CPMU_HST_ACC 0x0000361c #define CPMU_HST_ACC_MACCLK_MASK 0x001f0000 #define CPMU_HST_ACC_MACCLK_6_25 0x00130000 -/* 0x3620 --> 0x365c unused */ +/* 0x3620 --> 0x3630 unused */ + +#define TG3_CPMU_CLCK_STAT 0x00003630 +#define CPMU_CLCK_STAT_MAC_CLCK_MASK 0x001f0000 +#define CPMU_CLCK_STAT_MAC_CLCK_62_5 0x00000000 +#define CPMU_CLCK_STAT_MAC_CLCK_12_5 0x00110000 +#define CPMU_CLCK_STAT_MAC_CLCK_6_25 0x00130000 +/* 0x3634 --> 0x365c unused */ #define TG3_CPMU_MUTEX_REQ 0x0000365c #define CPMU_MUTEX_REQ_DRIVER 0x00001000 -- cgit v1.2.3 From 5f5c51e3d473d8ddc0c32156c2b27e2fe92b9b57 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:19:37 -0800 Subject: [TG3]: Increase the PCI MRRS Previous devices hardcoded the PCI Maximum Read Request Size to 4K. To better comply with the PCI spec, the hardware now defaults the MRRS to 512 bytes. This will yield poor driver performance if left untouched. This patch increases the MRRS to 4K on driver initialization. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index ecd64a224e95..72db78b1ec3b 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -5098,12 +5098,15 @@ static void tg3_restore_pci_state(struct tg3 *tp) pci_write_config_word(tp->pdev, PCI_COMMAND, tp->pci_cmd); - if (!(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)) { + if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) + pcie_set_readrq(tp->pdev, 4096); + else { pci_write_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE, tp->pci_cacheline_sz); pci_write_config_byte(tp->pdev, PCI_LATENCY_TIMER, tp->pci_lat_timer); } + /* Make sure PCI-X relaxed ordering bit is clear. */ if (tp->pcix_cap) { u16 pcix_cmd; @@ -11215,6 +11218,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) pcie_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_EXP); if (pcie_cap != 0) { tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS; + + pcie_set_readrq(tp->pdev, 4096); + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { u16 lnkctl; -- cgit v1.2.3 From b5af7126ea7586eb8f030280c027611c42a6a9c7 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:22:02 -0800 Subject: [TG3]: Add A1 revs This patch adds the A1 revision of 5784, 5764, and 5761, and applies all previous bugfixes. In places where the list of devices gets too long, the patch uses a new TG3_FLG3_5761_5784_AX_FIXES flag instead. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 30 ++++++++++++++++++------------ drivers/net/tg3.h | 3 +++ 2 files changed, 21 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 72db78b1ec3b..8e76092a171e 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -1106,8 +1106,7 @@ static int tg3_phy_reset(struct tg3 *tp) if (err) return err; - if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || - tp->pci_chip_rev_id == CHIPREV_ID_5761_A0) { + if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { u32 val; val = tr32(TG3_CPMU_LSPD_1000MB_CLK); @@ -1352,8 +1351,7 @@ static void tg3_power_down_phy(struct tg3 *tp) (tp->tg3_flags2 & TG3_FLG2_MII_SERDES))) return; - if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || - tp->pci_chip_rev_id == CHIPREV_ID_5761_A0) { + if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { val = tr32(TG3_CPMU_LSPD_1000MB_CLK); val &= ~CPMU_LSPD_1000MB_MACCLK_MASK; val |= CPMU_LSPD_1000MB_MACCLK_12_5; @@ -3154,7 +3152,8 @@ static int tg3_setup_phy(struct tg3 *tp, int force_reset) err = tg3_setup_copper_phy(tp, force_reset); } - if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0) { + if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || + tp->pci_chip_rev_id == CHIPREV_ID_5784_A1) { u32 val, scale; val = tr32(TG3_CPMU_CLCK_STAT) & CPMU_CLCK_STAT_MAC_CLCK_MASK; @@ -6390,7 +6389,8 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) tg3_write_sig_legacy(tp, RESET_KIND_INIT); - if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0) { + if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || + tp->pci_chip_rev_id == CHIPREV_ID_5784_A1) { val = tr32(TG3_CPMU_CTRL); val &= ~(CPMU_CTRL_LINK_AWARE_MODE | CPMU_CTRL_LINK_IDLE_MODE); tw32(TG3_CPMU_CTRL, val); @@ -9379,8 +9379,7 @@ static int tg3_test_loopback(struct tg3 *tp) if (err) return TG3_LOOPBACK_FAILED; - if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || - tp->pci_chip_rev_id == CHIPREV_ID_5761_A0) { + if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { int i; u32 status; @@ -9407,8 +9406,7 @@ static int tg3_test_loopback(struct tg3 *tp) if (tg3_run_loopback(tp, TG3_MAC_LOOPBACK)) err |= TG3_MAC_LOOPBACK_FAILED; - if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || - tp->pci_chip_rev_id == CHIPREV_ID_5761_A0) { + if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) { tw32(TG3_CPMU_CTRL, cpmuctrl); /* Release the mutex */ @@ -10629,7 +10627,8 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL) tp->led_ctrl = LED_CTRL_MODE_PHY_2; - if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0) + if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || + tp->pci_chip_rev_id == CHIPREV_ID_5784_A1) tp->led_ctrl = LED_CTRL_MODE_MAC; if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) { @@ -11401,9 +11400,16 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) } if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761) + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761) { tp->tg3_flags |= TG3_FLAG_CPMU_PRESENT; + if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 || + tp->pci_chip_rev_id == CHIPREV_ID_5784_A1 || + tp->pci_chip_rev_id == CHIPREV_ID_5761_A0 || + tp->pci_chip_rev_id == CHIPREV_ID_5761_A1) + tp->tg3_flags3 |= TG3_FLG3_5761_5784_AX_FIXES; + } + /* Set up tp->grc_local_ctrl before calling tg3_set_power_state(). * GPIO1 driven high will bring 5700's external PHY out of reset. * It is also used as eeprom write protect on LOMs. diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index d325ab59b391..da18fb220712 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h @@ -109,7 +109,9 @@ #define CHIPREV_ID_5714_A2 0x9002 #define CHIPREV_ID_5906_A1 0xc001 #define CHIPREV_ID_5784_A0 0x5784000 +#define CHIPREV_ID_5784_A1 0x5784001 #define CHIPREV_ID_5761_A0 0x5761000 +#define CHIPREV_ID_5761_A1 0x5761001 #define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12) #define ASIC_REV_5700 0x07 #define ASIC_REV_5701 0x00 @@ -2391,6 +2393,7 @@ struct tg3 { u32 tg3_flags3; #define TG3_FLG3_NO_NVRAM_ADDR_TRANS 0x00000001 #define TG3_FLG3_ENABLE_APE 0x00000002 +#define TG3_FLG3_5761_5784_AX_FIXES 0x00000004 struct timer_list timer; u16 timer_counter; -- cgit v1.2.3 From 3bebab591413929c405925a8fdd98f5b0d660e39 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:22:40 -0800 Subject: [TG3]: MII => TP This patch changes the PHY type reported through ethtool for copper devices from MII to TP. The latter is more accurate. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 8e76092a171e..8d518cc85ad8 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -8329,7 +8329,7 @@ static int tg3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) SUPPORTED_100baseT_Full | SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | - SUPPORTED_MII); + SUPPORTED_TP); cmd->port = PORT_TP; } else { cmd->supported |= SUPPORTED_FIBRE; -- cgit v1.2.3 From 458c096ed787b2572303a7087d23bfab06b450be Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 12 Nov 2007 21:23:21 -0800 Subject: [TG3]: Update version to 3.86 This patch updates the version number to 3.86 Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 8d518cc85ad8..4942f7d18937 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -64,8 +64,8 @@ #define DRV_MODULE_NAME "tg3" #define PFX DRV_MODULE_NAME ": " -#define DRV_MODULE_VERSION "3.85" -#define DRV_MODULE_RELDATE "October 18, 2007" +#define DRV_MODULE_VERSION "3.86" +#define DRV_MODULE_RELDATE "November 9, 2007" #define TG3_DEF_MAC_MODE 0 #define TG3_DEF_RX_MODE 0 -- cgit v1.2.3 From 9db7720cca8f55a1e0c8d0dc1587e35dca50afbf Mon Sep 17 00:00:00 2001 From: Roel Kluin <12o3l@tiscali.nl> Date: Tue, 13 Nov 2007 03:16:17 -0800 Subject: [MYRI_SBUS]: Prevent that myri_do_handshake lies about ticks. With '<=' tick can be incremented up to 26, The last loop is redundant since even when 'softstate' becomes 'STATE_READY', 'if (tick > 25)' will still cause the function to return -1, Signed-off-by: Roel Kluin <12o3l@tiscali.nl> Signed-off-by: David S. Miller --- drivers/net/myri_sbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c index 8d29319cc5cb..656a260fc956 100644 --- a/drivers/net/myri_sbus.c +++ b/drivers/net/myri_sbus.c @@ -134,7 +134,7 @@ static int myri_do_handshake(struct myri_eth *mp) myri_disable_irq(mp->lregs, cregs); - while (tick++ <= 25) { + while (tick++ < 25) { u32 softstate; /* Wake it up. */ -- cgit v1.2.3 From 072ee3f9bd26a2f89a79d1eae9052d30b8d745a5 Mon Sep 17 00:00:00 2001 From: Roel Kluin <12o3l@tiscali.nl> Date: Tue, 13 Nov 2007 03:17:16 -0800 Subject: [TEHUTI]: Fix incorrect usage of strncat in bdx_get_drvinfo() Fix incorrect length for strncat by replacing it with strlcat Signed-off-by: Roel Kluin <12o3l@tiscali.nl> Signed-off-by: David S. Miller --- drivers/net/tehuti.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/net/tehuti.c b/drivers/net/tehuti.c index 4e1b84e6d66a..21230c97b2a0 100644 --- a/drivers/net/tehuti.c +++ b/drivers/net/tehuti.c @@ -2168,10 +2168,10 @@ bdx_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) { struct bdx_priv *priv = netdev->priv; - strncat(drvinfo->driver, BDX_DRV_NAME, sizeof(drvinfo->driver)); - strncat(drvinfo->version, BDX_DRV_VERSION, sizeof(drvinfo->version)); - strncat(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); - strncat(drvinfo->bus_info, pci_name(priv->pdev), + strlcat(drvinfo->driver, BDX_DRV_NAME, sizeof(drvinfo->driver)); + strlcat(drvinfo->version, BDX_DRV_VERSION, sizeof(drvinfo->version)); + strlcat(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); + strlcat(drvinfo->bus_info, pci_name(priv->pdev), sizeof(drvinfo->bus_info)); drvinfo->n_stats = ((priv->stats_flag) ? -- cgit v1.2.3 From 022cbae611a37eda80d498f8f379794c8ac3be47 Mon Sep 17 00:00:00 2001 From: "Denis V. Lunev" Date: Tue, 13 Nov 2007 03:23:50 -0800 Subject: [NET]: Move unneeded data to initdata section. This patch reverts Eric's commit 2b008b0a8e96b726c603c5e1a5a7a509b5f61e35 It diets .text & .data section of the kernel if CONFIG_NET_NS is not set. This is safe after list operations cleanup. Signed-of-by: Denis V. Lunev Signed-off-by: David S. Miller --- drivers/net/loopback.c | 2 +- fs/proc/proc_net.c | 2 +- include/net/net_namespace.h | 2 ++ net/core/dev.c | 6 +++--- net/core/dev_mcast.c | 2 +- net/netlink/af_netlink.c | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 45f30a2974b8..662b8d16803c 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -284,7 +284,7 @@ static __net_exit void loopback_net_exit(struct net *net) unregister_netdev(dev); } -static struct pernet_operations loopback_net_ops = { +static struct pernet_operations __net_initdata loopback_net_ops = { .init = loopback_net_init, .exit = loopback_net_exit, }; diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c index 153554cf5575..131f9c68be5f 100644 --- a/fs/proc/proc_net.c +++ b/fs/proc/proc_net.c @@ -178,7 +178,7 @@ static __net_exit void proc_net_ns_exit(struct net *net) kfree(net->proc_net_root); } -static struct pernet_operations proc_net_ns_ops = { +static struct pernet_operations __net_initdata proc_net_ns_ops = { .init = proc_net_ns_init, .exit = proc_net_ns_exit, }; diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 1fd449a6530b..5dd6d90b37eb 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -119,9 +119,11 @@ static inline struct net *maybe_get_net(struct net *net) #ifdef CONFIG_NET_NS #define __net_init #define __net_exit +#define __net_initdata #else #define __net_init __init #define __net_exit __exit_refok +#define __net_initdata __initdata #endif struct pernet_operations { diff --git a/net/core/dev.c b/net/core/dev.c index dd7e30754cbc..dd40b35bb006 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2688,7 +2688,7 @@ static void __net_exit dev_proc_net_exit(struct net *net) proc_net_remove(net, "dev"); } -static struct pernet_operations dev_proc_ops = { +static struct pernet_operations __net_initdata dev_proc_ops = { .init = dev_proc_net_init, .exit = dev_proc_net_exit, }; @@ -4353,7 +4353,7 @@ static void __net_exit netdev_exit(struct net *net) kfree(net->dev_index_head); } -static struct pernet_operations netdev_net_ops = { +static struct pernet_operations __net_initdata netdev_net_ops = { .init = netdev_init, .exit = netdev_exit, }; @@ -4384,7 +4384,7 @@ static void __net_exit default_device_exit(struct net *net) rtnl_unlock(); } -static struct pernet_operations default_device_ops = { +static struct pernet_operations __net_initdata default_device_ops = { .exit = default_device_exit, }; diff --git a/net/core/dev_mcast.c b/net/core/dev_mcast.c index 647973daca2b..69fff16ece10 100644 --- a/net/core/dev_mcast.c +++ b/net/core/dev_mcast.c @@ -285,7 +285,7 @@ static void __net_exit dev_mc_net_exit(struct net *net) proc_net_remove(net, "dev_mcast"); } -static struct pernet_operations dev_mc_net_ops = { +static struct pernet_operations __net_initdata dev_mc_net_ops = { .init = dev_mc_net_init, .exit = dev_mc_net_exit, }; diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 415c97236f63..de3988ba1f46 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1888,7 +1888,7 @@ static void __net_exit netlink_net_exit(struct net *net) #endif } -static struct pernet_operations netlink_net_ops = { +static struct pernet_operations __net_initdata netlink_net_ops = { .init = netlink_net_init, .exit = netlink_net_exit, }; -- cgit v1.2.3