usb: cdc_ether: Add new product id for the 5AE profile
[linux-2.6.git] / drivers / net / sunvnet.c
index ff1028a..bf3c762 100644 (file)
@@ -1,8 +1,10 @@
 /* sunvnet.c: Sun LDOM Virtual Network Driver.
  *
- * Copyright (C) 2007 David S. Miller <davem@davemloft.net>
+ * Copyright (C) 2007, 2008 David S. Miller <davem@davemloft.net>
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
@@ -20,7 +22,6 @@
 #include "sunvnet.h"
 
 #define DRV_MODULE_NAME                "sunvnet"
-#define PFX DRV_MODULE_NAME    ": "
 #define DRV_MODULE_VERSION     "1.0"
 #define DRV_MODULE_RELDATE     "June 25, 2007"
 
@@ -45,9 +46,9 @@ static int vnet_handle_unknown(struct vnet_port *port, void *arg)
 {
        struct vio_msg_tag *pkt = arg;
 
-       printk(KERN_ERR PFX "Received unknown msg [%02x:%02x:%04x:%08x]\n",
+       pr_err("Received unknown msg [%02x:%02x:%04x:%08x]\n",
               pkt->type, pkt->stype, pkt->stype_env, pkt->sid);
-       printk(KERN_ERR PFX "Resetting connection.\n");
+       pr_err("Resetting connection\n");
 
        ldc_disconnect(port->vio.lp);
 
@@ -336,7 +337,7 @@ static int vnet_walk_rx_one(struct vnet_port *port,
        if (IS_ERR(desc))
                return PTR_ERR(desc);
 
-       viodbg(DATA, "vio_walk_rx_one desc[%02x:%02x:%08x:%08x:%lx:%lx]\n",
+       viodbg(DATA, "vio_walk_rx_one desc[%02x:%02x:%08x:%08x:%llx:%llx]\n",
               desc->hdr.state, desc->hdr.ack,
               desc->size, desc->ncookies,
               desc->cookies[0].cookie_addr,
@@ -394,14 +395,14 @@ static int vnet_rx(struct vnet_port *port, void *msgbuf)
        struct vio_dring_state *dr = &port->vio.drings[VIO_DRIVER_RX_RING];
        struct vio_driver_state *vio = &port->vio;
 
-       viodbg(DATA, "vnet_rx stype_env[%04x] seq[%016lx] rcv_nxt[%016lx]\n",
+       viodbg(DATA, "vnet_rx stype_env[%04x] seq[%016llx] rcv_nxt[%016llx]\n",
               pkt->tag.stype_env, pkt->seq, dr->rcv_nxt);
 
        if (unlikely(pkt->tag.stype_env != VIO_DRING_DATA))
                return 0;
        if (unlikely(pkt->seq != dr->rcv_nxt)) {
-               printk(KERN_ERR PFX "RX out of sequence seq[0x%lx] "
-                      "rcv_nxt[0x%lx]\n", pkt->seq, dr->rcv_nxt);
+               pr_err("RX out of sequence seq[0x%llx] rcv_nxt[0x%llx]\n",
+                      pkt->seq, dr->rcv_nxt);
                return 0;
        }
 
@@ -464,8 +465,7 @@ static int handle_mcast(struct vnet_port *port, void *msgbuf)
        struct vio_net_mcast_info *pkt = msgbuf;
 
        if (pkt->tag.stype != VIO_SUBTYPE_ACK)
-               printk(KERN_ERR PFX "%s: Got unexpected MCAST reply "
-                      "[%02x:%02x:%04x:%08x]\n",
+               pr_err("%s: Got unexpected MCAST reply [%02x:%02x:%04x:%08x]\n",
                       port->vp->dev->name,
                       pkt->tag.type,
                       pkt->tag.stype,
@@ -520,7 +520,7 @@ static void vnet_event(void *arg, int event)
        }
 
        if (unlikely(event != LDC_EVENT_DATA_READY)) {
-               printk(KERN_WARNING PFX "Unexpected LDC event %d\n", event);
+               pr_warning("Unexpected LDC event %d\n", event);
                spin_unlock_irqrestore(&vio->lock, flags);
                return;
        }
@@ -662,8 +662,7 @@ static int vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
                        netif_stop_queue(dev);
 
                        /* This is a hard error, log it. */
-                       printk(KERN_ERR PFX "%s: BUG! Tx Ring full when "
-                              "queue awake!\n", dev->name);
+                       netdev_err(dev, "BUG! Tx Ring full when queue awake!\n");
                        dev->stats.tx_errors++;
                }
                spin_unlock_irqrestore(&port->vio.lock, flags);
@@ -696,8 +695,7 @@ static int vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        err = __vnet_tx_trigger(port);
        if (unlikely(err < 0)) {
-               printk(KERN_INFO PFX "%s: TX trigger error %d\n",
-                      dev->name, err);
+               netdev_info(dev, "TX trigger error %d\n", err);
                d->hdr.state = VIO_DESC_FREE;
                dev->stats.tx_carrier_errors++;
                goto out_dropped_unlock;
@@ -717,7 +715,6 @@ static int vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        dev_kfree_skb(skb);
 
-       dev->trans_start = jiffies;
        return NETDEV_TX_OK;
 
 out_dropped_unlock:
@@ -763,12 +760,12 @@ static struct vnet_mcast_entry *__vnet_mc_find(struct vnet *vp, u8 *addr)
 
 static void __update_mc_list(struct vnet *vp, struct net_device *dev)
 {
-       struct dev_addr_list *p;
+       struct netdev_hw_addr *ha;
 
-       for (p = dev->mc_list; p; p = p->next) {
+       netdev_for_each_mc_addr(ha, dev) {
                struct vnet_mcast_entry *m;
 
-               m = __vnet_mc_find(vp, p->dmi_addr);
+               m = __vnet_mc_find(vp, ha->addr);
                if (m) {
                        m->hit = 1;
                        continue;
@@ -778,7 +775,7 @@ static void __update_mc_list(struct vnet *vp, struct net_device *dev)
                        m = kzalloc(sizeof(*m), GFP_ATOMIC);
                        if (!m)
                                continue;
-                       memcpy(m->addr, p->dmi_addr, ETH_ALEN);
+                       memcpy(m->addr, ha->addr, ETH_ALEN);
                        m->hit = 1;
 
                        m->next = vp->mcast_list;
@@ -953,12 +950,12 @@ static int __devinit vnet_port_alloc_tx_bufs(struct vnet_port *port)
 
                err = -ENOMEM;
                if (!buf) {
-                       printk(KERN_ERR "TX buffer allocation failure\n");
+                       pr_err("TX buffer allocation failure\n");
                        goto err_out;
                }
                err = -EFAULT;
                if ((unsigned long)buf & (8UL - 1)) {
-                       printk(KERN_ERR "TX buffer misaligned\n");
+                       pr_err("TX buffer misaligned\n");
                        kfree(buf);
                        goto err_out;
                }
@@ -1012,6 +1009,17 @@ err_out:
 static LIST_HEAD(vnet_list);
 static DEFINE_MUTEX(vnet_list_mutex);
 
+static const struct net_device_ops vnet_ops = {
+       .ndo_open               = vnet_open,
+       .ndo_stop               = vnet_close,
+       .ndo_set_multicast_list = vnet_set_rx_mode,
+       .ndo_set_mac_address    = vnet_set_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_tx_timeout         = vnet_tx_timeout,
+       .ndo_change_mtu         = vnet_change_mtu,
+       .ndo_start_xmit         = vnet_start_xmit,
+};
+
 static struct vnet * __devinit vnet_new(const u64 *local_mac)
 {
        struct net_device *dev;
@@ -1020,7 +1028,7 @@ static struct vnet * __devinit vnet_new(const u64 *local_mac)
 
        dev = alloc_etherdev(sizeof(*vp));
        if (!dev) {
-               printk(KERN_ERR PFX "Etherdev alloc failed, aborting.\n");
+               pr_err("Etherdev alloc failed, aborting\n");
                return ERR_PTR(-ENOMEM);
        }
 
@@ -1040,27 +1048,17 @@ static struct vnet * __devinit vnet_new(const u64 *local_mac)
        INIT_LIST_HEAD(&vp->list);
        vp->local_mac = *local_mac;
 
-       dev->open = vnet_open;
-       dev->stop = vnet_close;
-       dev->set_multicast_list = vnet_set_rx_mode;
-       dev->set_mac_address = vnet_set_mac_addr;
-       dev->tx_timeout = vnet_tx_timeout;
+       dev->netdev_ops = &vnet_ops;
        dev->ethtool_ops = &vnet_ethtool_ops;
        dev->watchdog_timeo = VNET_TX_TIMEOUT;
-       dev->change_mtu = vnet_change_mtu;
-       dev->hard_start_xmit = vnet_start_xmit;
 
        err = register_netdev(dev);
        if (err) {
-               printk(KERN_ERR PFX "Cannot register net device, "
-                      "aborting.\n");
+               pr_err("Cannot register net device, aborting\n");
                goto err_out_free_dev;
        }
 
-       printk(KERN_INFO "%s: Sun LDOM vnet ", dev->name);
-
-       for (i = 0; i < 6; i++)
-               printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':');
+       netdev_info(dev, "Sun LDOM vnet %pM\n", dev->dev_addr);
 
        list_add(&vp->list, &vnet_list);
 
@@ -1130,12 +1128,9 @@ static struct vio_driver_ops vnet_vio_ops = {
        .handshake_complete     = vnet_handshake_complete,
 };
 
-static void print_version(void)
+static void __devinit print_version(void)
 {
-       static int version_printed;
-
-       if (version_printed++ == 0)
-               printk(KERN_INFO "%s", version);
+       printk_once(KERN_INFO "%s", version);
 }
 
 const char *remote_macaddr_prop = "remote-mac-address";
@@ -1156,7 +1151,7 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev,
 
        vp = vnet_find_parent(hp, vdev->mp);
        if (IS_ERR(vp)) {
-               printk(KERN_ERR PFX "Cannot find port parent vnet.\n");
+               pr_err("Cannot find port parent vnet\n");
                err = PTR_ERR(vp);
                goto err_out_put_mdesc;
        }
@@ -1164,15 +1159,14 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev,
        rmac = mdesc_get_property(hp, vdev->mp, remote_macaddr_prop, &len);
        err = -ENODEV;
        if (!rmac) {
-               printk(KERN_ERR PFX "Port lacks %s property.\n",
-                      remote_macaddr_prop);
+               pr_err("Port lacks %s property\n", remote_macaddr_prop);
                goto err_out_put_mdesc;
        }
 
        port = kzalloc(sizeof(*port), GFP_KERNEL);
        err = -ENOMEM;
        if (!port) {
-               printk(KERN_ERR PFX "Cannot allocate vnet_port.\n");
+               pr_err("Cannot allocate vnet_port\n");
                goto err_out_put_mdesc;
        }
 
@@ -1213,12 +1207,8 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev,
 
        dev_set_drvdata(&vdev->dev, port);
 
-       printk(KERN_INFO "%s: PORT ( remote-mac ", vp->dev->name);
-       for (i = 0; i < 6; i++)
-               printk("%2.2x%c", port->raddr[i], i == 5 ? ' ' : ':');
-       if (switch_port)
-               printk("switch-port ");
-       printk(")\n");
+       pr_info("%s: PORT ( remote-mac %pM%s )\n",
+               vp->dev->name, port->raddr, switch_port ? " switch-port" : "");
 
        vio_port_up(&port->vio);
 
@@ -1262,7 +1252,7 @@ static int vnet_port_remove(struct vio_dev *vdev)
        return 0;
 }
 
-static struct vio_device_id vnet_port_match[] = {
+static const struct vio_device_id vnet_port_match[] = {
        {
                .type = "vnet-port",
        },