ACPI: thermal: syntax, spelling, kernel-doc
[safe/jmp/linux-2.6] / drivers / net / sunhme.c
index 9b246e4..b4e7f30 100644 (file)
@@ -13,7 +13,6 @@
  *     argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
@@ -33,6 +32,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/mm.h>
 #include <linux/bitops.h>
 
 #include <asm/system.h>
@@ -55,9 +55,6 @@
 
 #ifdef CONFIG_PCI
 #include <linux/pci.h>
-#ifdef CONFIG_SPARC
-#include <asm/pbm.h>
-#endif
 #endif
 
 #include "sunhme.h"
@@ -197,21 +194,21 @@ static u32 sbus_hme_read32(void __iomem *reg)
 
 static void sbus_hme_write_rxd(struct happy_meal_rxd *rxd, u32 flags, u32 addr)
 {
-       rxd->rx_addr = addr;
+       rxd->rx_addr = (__force hme32)addr;
        wmb();
-       rxd->rx_flags = flags;
+       rxd->rx_flags = (__force hme32)flags;
 }
 
 static void sbus_hme_write_txd(struct happy_meal_txd *txd, u32 flags, u32 addr)
 {
-       txd->tx_addr = addr;
+       txd->tx_addr = (__force hme32)addr;
        wmb();
-       txd->tx_flags = flags;
+       txd->tx_flags = (__force hme32)flags;
 }
 
-static u32 sbus_hme_read_desc32(u32 *p)
+static u32 sbus_hme_read_desc32(hme32 *p)
 {
-       return *p;
+       return (__force u32)*p;
 }
 
 static void pci_hme_write32(void __iomem *reg, u32 val)
@@ -226,21 +223,21 @@ static u32 pci_hme_read32(void __iomem *reg)
 
 static void pci_hme_write_rxd(struct happy_meal_rxd *rxd, u32 flags, u32 addr)
 {
-       rxd->rx_addr = cpu_to_le32(addr);
+       rxd->rx_addr = (__force hme32)cpu_to_le32(addr);
        wmb();
-       rxd->rx_flags = cpu_to_le32(flags);
+       rxd->rx_flags = (__force hme32)cpu_to_le32(flags);
 }
 
 static void pci_hme_write_txd(struct happy_meal_txd *txd, u32 flags, u32 addr)
 {
-       txd->tx_addr = cpu_to_le32(addr);
+       txd->tx_addr = (__force hme32)cpu_to_le32(addr);
        wmb();
-       txd->tx_flags = cpu_to_le32(flags);
+       txd->tx_flags = (__force hme32)cpu_to_le32(flags);
 }
 
-static u32 pci_hme_read_desc32(u32 *p)
+static u32 pci_hme_read_desc32(hme32 *p)
 {
-       return cpu_to_le32p(p);
+       return le32_to_cpup((__le32 *)p);
 }
 
 #define hme_write32(__hp, __reg, __val) \
@@ -269,16 +266,16 @@ static u32 pci_hme_read_desc32(u32 *p)
 #define hme_read32(__hp, __reg) \
        sbus_readl(__reg)
 #define hme_write_rxd(__hp, __rxd, __flags, __addr) \
-do {   (__rxd)->rx_addr = (__addr); \
+do {   (__rxd)->rx_addr = (__force hme32)(u32)(__addr); \
        wmb(); \
-       (__rxd)->rx_flags = (__flags); \
+       (__rxd)->rx_flags = (__force hme32)(u32)(__flags); \
 } while(0)
 #define hme_write_txd(__hp, __txd, __flags, __addr) \
-do {   (__txd)->tx_addr = (__addr); \
+do {   (__txd)->tx_addr = (__force hme32)(u32)(__addr); \
        wmb(); \
-       (__txd)->tx_flags = (__flags); \
+       (__txd)->tx_flags = (__force hme32)(u32)(__flags); \
 } while(0)
-#define hme_read_desc32(__hp, __p)     (*(__p))
+#define hme_read_desc32(__hp, __p)     ((__force u32)(hme32)*(__p))
 #define hme_dma_map(__hp, __ptr, __size, __dir) \
        sbus_map_single((__hp)->happy_dev, (__ptr), (__size), (__dir))
 #define hme_dma_unmap(__hp, __addr, __size, __dir) \
@@ -294,16 +291,19 @@ do {      (__txd)->tx_addr = (__addr); \
 #define hme_read32(__hp, __reg) \
        readl(__reg)
 #define hme_write_rxd(__hp, __rxd, __flags, __addr) \
-do {   (__rxd)->rx_addr = cpu_to_le32(__addr); \
+do {   (__rxd)->rx_addr = (__force hme32)cpu_to_le32(__addr); \
        wmb(); \
-       (__rxd)->rx_flags = cpu_to_le32(__flags); \
+       (__rxd)->rx_flags = (__force hme32)cpu_to_le32(__flags); \
 } while(0)
 #define hme_write_txd(__hp, __txd, __flags, __addr) \
-do {   (__txd)->tx_addr = cpu_to_le32(__addr); \
+do {   (__txd)->tx_addr = (__force hme32)cpu_to_le32(__addr); \
        wmb(); \
-       (__txd)->tx_flags = cpu_to_le32(__flags); \
+       (__txd)->tx_flags = (__force hme32)cpu_to_le32(__flags); \
 } while(0)
-#define hme_read_desc32(__hp, __p)     cpu_to_le32p(__p)
+static inline u32 hme_read_desc32(struct happy_meal *hp, hme32 *p)
+{
+       return le32_to_cpup((__le32 *)p);
+}
 #define hme_dma_map(__hp, __ptr, __size, __dir) \
        pci_map_single((__hp)->happy_dev, (__ptr), (__size), (__dir))
 #define hme_dma_unmap(__hp, __addr, __size, __dir) \
@@ -506,7 +506,7 @@ static void happy_meal_tcvr_write(struct happy_meal *hp,
                                  unsigned short value)
 {
        int tries = TCVR_WRITE_TRIES;
-       
+
        ASD(("happy_meal_tcvr_write: reg=0x%02x value=%04x\n", reg, value));
 
        /* Welcome to Sun Microsystems, can I take your order please? */
@@ -1208,7 +1208,7 @@ static void happy_meal_transceiver_check(struct happy_meal *hp, void __iomem *tr
  * flags, thus:
  *
  *     skb->csum = rxd->rx_flags & 0xffff;
- *     skb->ip_summed = CHECKSUM_HW;
+ *     skb->ip_summed = CHECKSUM_COMPLETE;
  *
  * before sending off the skb to the protocols, and we are good as gold.
  */
@@ -1284,7 +1284,7 @@ static void happy_meal_init_rings(struct happy_meal *hp)
                skb->dev = dev;
 
                /* Because we reserve afterwards. */
-               skb_put(skb, (ETH_FRAME_LEN + RX_OFFSET));
+               skb_put(skb, (ETH_FRAME_LEN + RX_OFFSET + 4));
                hme_write_rxd(hp, &hb->happy_meal_rxd[i],
                              (RXFLAG_OWN | ((RX_BUF_ALLOC_SIZE - RX_OFFSET) << 16)),
                              hme_dma_map(hp, skb->data, RX_BUF_ALLOC_SIZE, DMA_FROMDEVICE));
@@ -1703,6 +1703,11 @@ static int happy_meal_init(struct happy_meal *hp)
        HMD(("tx old[%08x] and rx [%08x] ON!\n",
             hme_read32(hp, bregs + BMAC_TXCFG),
             hme_read32(hp, bregs + BMAC_RXCFG)));
+
+       /* Set larger TX/RX size to allow for 802.1q */
+       hme_write32(hp, bregs + BMAC_TXMAX, ETH_FRAME_LEN + 8);
+       hme_write32(hp, bregs + BMAC_RXMAX, ETH_FRAME_LEN + 8);
+
        hme_write32(hp, bregs + BMAC_TXCFG,
                    hme_read32(hp, bregs + BMAC_TXCFG) | BIGMAC_TXCFG_ENABLE);
        hme_write32(hp, bregs + BMAC_RXCFG,
@@ -1779,7 +1784,7 @@ static void happy_meal_set_initial_advertisement(struct happy_meal *hp)
 static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 {
        int reset = 0;
-       
+
        /* Only print messages for non-counter related interrupts. */
        if (status & (GREG_STAT_STSTERR | GREG_STAT_TFIFO_UND |
                      GREG_STAT_MAXPKTERR | GREG_STAT_RXERR |
@@ -2042,7 +2047,7 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
                        hme_dma_unmap(hp, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROMDEVICE);
                        hp->rx_skbs[elem] = new_skb;
                        new_skb->dev = dev;
-                       skb_put(new_skb, (ETH_FRAME_LEN + RX_OFFSET));
+                       skb_put(new_skb, (ETH_FRAME_LEN + RX_OFFSET + 4));
                        hme_write_rxd(hp, this,
                                      (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)),
                                      hme_dma_map(hp, new_skb->data, RX_BUF_ALLOC_SIZE, DMA_FROMDEVICE));
@@ -2058,11 +2063,10 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
                                goto drop_it;
                        }
 
-                       copy_skb->dev = dev;
                        skb_reserve(copy_skb, 2);
                        skb_put(copy_skb, len);
                        hme_dma_sync_for_cpu(hp, dma_addr, len, DMA_FROMDEVICE);
-                       memcpy(copy_skb->data, skb->data, len);
+                       skb_copy_from_linear_data(skb, copy_skb->data, len);
                        hme_dma_sync_for_device(hp, dma_addr, len, DMA_FROMDEVICE);
 
                        /* Reuse original ring buffer. */
@@ -2074,8 +2078,8 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
                }
 
                /* This card is _fucking_ hot... */
-               skb->csum = ntohs(csum ^ 0xffff);
-               skb->ip_summed = CHECKSUM_HW;
+               skb->csum = csum_unfold(~(__force __sum16)htons(csum));
+               skb->ip_summed = CHECKSUM_COMPLETE;
 
                RXD(("len=%d csum=%4x]", len, csum));
                skb->protocol = eth_type_trans(skb, dev);
@@ -2094,10 +2098,10 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
        RXD((">"));
 }
 
-static irqreturn_t happy_meal_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t happy_meal_interrupt(int irq, void *dev_id)
 {
-       struct net_device *dev = (struct net_device *) dev_id;
-       struct happy_meal *hp  = dev->priv;
+       struct net_device *dev = dev_id;
+       struct happy_meal *hp  = netdev_priv(dev);
        u32 happy_status       = hme_read32(hp, hp->gregs + GREG_STAT);
 
        HMD(("happy_meal_interrupt: status=%08x ", happy_status));
@@ -2133,7 +2137,7 @@ out:
 }
 
 #ifdef CONFIG_SBUS
-static irqreturn_t quattro_sbus_interrupt(int irq, void *cookie, struct pt_regs *ptregs)
+static irqreturn_t quattro_sbus_interrupt(int irq, void *cookie)
 {
        struct quattro *qp = (struct quattro *) cookie;
        int i;
@@ -2195,7 +2199,7 @@ static int happy_meal_open(struct net_device *dev)
         */
        if ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO) {
                if (request_irq(dev->irq, &happy_meal_interrupt,
-                               SA_SHIRQ, dev->name, (void *)dev)) {
+                               IRQF_SHARED, dev->name, (void *)dev)) {
                        HMD(("EAGAIN\n"));
                        printk(KERN_ERR "happy_meal(SBUS): Can't order irq %d to go.\n",
                               dev->irq);
@@ -2269,11 +2273,9 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev)
        u32 tx_flags;
 
        tx_flags = TXFLAG_OWN;
-       if (skb->ip_summed == CHECKSUM_HW) {
-               u32 csum_start_off, csum_stuff_off;
-
-               csum_start_off = (u32) (skb->h.raw - skb->data);
-               csum_stuff_off = (u32) ((skb->h.raw + skb->csum) - skb->data);
+       if (skb->ip_summed == CHECKSUM_PARTIAL) {
+               const u32 csum_start_off = skb_transport_offset(skb);
+               const u32 csum_stuff_off = csum_start_off + skb->csum_offset;
 
                tx_flags = (TXFLAG_OWN | TXFLAG_CSENABLE |
                            ((csum_start_off << 14) & TXFLAG_CSBUFBEGIN) |
@@ -2513,7 +2515,7 @@ static u32 hme_get_link(struct net_device *dev)
        return (hp->sw_bmsr & BMSR_LSTATUS);
 }
 
-static struct ethtool_ops hme_ethtool_ops = {
+static const struct ethtool_ops hme_ethtool_ops = {
        .get_settings           = hme_get_settings,
        .set_settings           = hme_set_settings,
        .get_drvinfo            = hme_get_drvinfo,
@@ -2609,7 +2611,7 @@ static void __init quattro_sbus_register_irqs(void)
 
                err = request_irq(sdev->irqs[0],
                                  quattro_sbus_interrupt,
-                                 SA_SHIRQ, "Quattro",
+                                 IRQF_SHARED, "Quattro",
                                  qp);
                if (err != 0) {
                        printk(KERN_ERR "Quattro: Fatal IRQ registery error %d.\n", err);
@@ -2631,7 +2633,7 @@ static void quattro_sbus_free_irqs(void)
 #endif /* CONFIG_SBUS */
 
 #ifdef CONFIG_PCI
-static struct quattro * __init quattro_pci_find(struct pci_dev *pdev)
+static struct quattro * __devinit quattro_pci_find(struct pci_dev *pdev)
 {
        struct pci_dev *bdev = pdev->bus->self;
        struct quattro *qp;
@@ -2670,6 +2672,7 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe
        struct net_device *dev;
        int i, qfe_slot = -1;
        int err = -ENODEV;
+       DECLARE_MAC_BUF(mac);
 
        if (is_qfe) {
                qp = quattro_sbus_find(sdev);
@@ -2686,7 +2689,6 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe
        dev = alloc_etherdev(sizeof(struct happy_meal));
        if (!dev)
                goto err_out;
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &sdev->ofdev.dev);
 
        if (hme_version_printed++ == 0)
@@ -2704,7 +2706,7 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe
                        dev->dev_addr[i] = macaddr[i];
                macaddr[5]++;
        } else {
-               unsigned char *addr;
+               const unsigned char *addr;
                int len;
 
                addr = of_get_property(dp, "local-mac-address", &len);
@@ -2815,8 +2817,8 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe
        dev->watchdog_timeo = 5*HZ;
        dev->ethtool_ops = &hme_ethtool_ops;
 
-       /* Happy Meal can do it all... except VLAN. */
-       dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_VLAN_CHALLENGED;
+       /* Happy Meal can do it all... */
+       dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
 
        dev->irq = sdev->irqs[0];
 
@@ -2857,10 +2859,7 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe
                printk(KERN_INFO "%s: HAPPY MEAL (SBUS) 10/100baseT Ethernet ",
                       dev->name);
 
-       for (i = 0; i < 6; i++)
-               printk("%2.2x%c",
-                      dev->dev_addr[i], i == 5 ? ' ' : ':');
-       printk("\n");
+       printk("%s\n", print_mac(mac, dev->dev_addr));
 
        return 0;
 
@@ -2986,7 +2985,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
 {
        struct quattro *qp = NULL;
 #ifdef CONFIG_SPARC
-       struct pcidev_cookie *pcp;
+       struct device_node *dp;
 #endif
        struct happy_meal *hp;
        struct net_device *dev;
@@ -2995,16 +2994,12 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
        int i, qfe_slot = -1;
        char prom_name[64];
        int err;
+       DECLARE_MAC_BUF(mac);
 
        /* Now make sure pci_dev cookie is there. */
 #ifdef CONFIG_SPARC
-       pcp = pdev->sysdata;
-       if (pcp == NULL) {
-               printk(KERN_ERR "happymeal(PCI): Some PCI device info missing\n");
-               return -ENODEV;
-       }
-       
-       strcpy(prom_name, pcp->prom_node->name);
+       dp = pci_device_to_OF_node(pdev);
+       strcpy(prom_name, dp->name);
 #else
        if (is_quattro_p(pdev))
                strcpy(prom_name, "SUNW,qfe");
@@ -3013,6 +3008,11 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
 #endif
 
        err = -ENODEV;
+
+       if (pci_enable_device(pdev))
+               goto err_out;
+       pci_set_master(pdev);
+
        if (!strcmp(prom_name, "SUNW,qfe") || !strcmp(prom_name, "qfe")) {
                qp = quattro_pci_find(pdev);
                if (qp == NULL)
@@ -3028,7 +3028,6 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
        err = -ENOMEM;
        if (!dev)
                goto err_out;
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
 
        if (hme_version_printed++ == 0)
@@ -3047,7 +3046,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
                hp->qfe_parent = qp;
                hp->qfe_ent = qfe_slot;
                qp->happy_meals[qfe_slot] = dev;
-       }               
+       }
 
        hpreg_res = pci_resource_start(pdev, 0);
        err = -ENODEV;
@@ -3061,7 +3060,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
                goto err_out_clear_quattro;
        }
 
-       if ((hpreg_base = ioremap(hpreg_res, 0x8000)) == 0) {
+       if ((hpreg_base = ioremap(hpreg_res, 0x8000)) == NULL) {
                printk(KERN_ERR "happymeal(PCI): Unable to remap card memory.\n");
                goto err_out_free_res;
        }
@@ -3076,11 +3075,11 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
                macaddr[5]++;
        } else {
 #ifdef CONFIG_SPARC
-               unsigned char *addr;
+               const unsigned char *addr;
                int len;
 
                if (qfe_slot != -1 &&
-                   (addr = of_get_property(pcp->prom_node,
+                   (addr = of_get_property(dp,
                                            "local-mac-address", &len)) != NULL
                    && len == 6) {
                        memcpy(dev->dev_addr, addr, 6);
@@ -3091,7 +3090,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
                get_hme_mac_nonsparc(pdev, &dev->dev_addr[0]);
 #endif
        }
-       
+
        /* Layout registers. */
        hp->gregs      = (hpreg_base + 0x0000UL);
        hp->etxregs    = (hpreg_base + 0x2000UL);
@@ -3100,13 +3099,9 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
        hp->tcvregs    = (hpreg_base + 0x7000UL);
 
 #ifdef CONFIG_SPARC
-       hp->hm_revision = of_getintprop_default(pcp->prom_node, "hm-rev", 0xff);
-       if (hp->hm_revision == 0xff) {
-               unsigned char prev;
-
-               pci_read_config_byte(pdev, PCI_REVISION_ID, &prev);
-               hp->hm_revision = 0xc0 | (prev & 0x0f);
-       }
+       hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff);
+       if (hp->hm_revision == 0xff)
+               hp->hm_revision = 0xc0 | (pdev->revision & 0x0f);
 #else
        /* works with this on non-sparc hosts */
        hp->hm_revision = 0x20;
@@ -3202,7 +3197,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
                    qpdev->device == PCI_DEVICE_ID_DEC_21153)
                        printk("DEC 21153 PCI Bridge\n");
                else
-                       printk("unknown bridge %04x.%04x\n", 
+                       printk("unknown bridge %04x.%04x\n",
                                qpdev->vendor, qpdev->device);
        }
 
@@ -3213,10 +3208,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
                printk(KERN_INFO "%s: HAPPY MEAL (PCI/CheerIO) 10/100BaseT Ethernet ",
                       dev->name);
 
-       for (i = 0; i < 6; i++)
-               printk("%2.2x%c", dev->dev_addr[i], i == 5 ? ' ' : ':');
-
-       printk("\n");
+       printk("%s\n", print_mac(mac, dev->dev_addr));
 
        return 0;
 
@@ -3256,12 +3248,7 @@ static void __devexit happy_meal_pci_remove(struct pci_dev *pdev)
 }
 
 static struct pci_device_id happymeal_pci_ids[] = {
-       {
-         .vendor       = PCI_VENDOR_ID_SUN,
-         .device       = PCI_DEVICE_ID_SUN_HAPPYMEAL,
-         .subvendor    = PCI_ANY_ID,
-         .subdevice    = PCI_ANY_ID,
-       },
+       { PCI_DEVICE(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_HAPPYMEAL) },
        { }                     /* Terminating entry */
 };
 
@@ -3276,7 +3263,7 @@ static struct pci_driver hme_pci_driver = {
 
 static int __init happy_meal_pci_init(void)
 {
-       return pci_module_init(&hme_pci_driver);
+       return pci_register_driver(&hme_pci_driver);
 }
 
 static void happy_meal_pci_exit(void)
@@ -3300,7 +3287,7 @@ static int __devinit hme_sbus_probe(struct of_device *dev, const struct of_devic
 {
        struct sbus_dev *sdev = to_sbus_device(&dev->dev);
        struct device_node *dp = dev->node;
-       char *model = of_get_property(dp, "model", NULL);
+       const char *model = of_get_property(dp, "model", NULL);
        int is_qfe = (match->data != NULL);
 
        if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe"))
@@ -3314,7 +3301,7 @@ static int __devexit hme_sbus_remove(struct of_device *dev)
        struct happy_meal *hp = dev_get_drvdata(&dev->dev);
        struct net_device *net_dev = hp->dev;
 
-       unregister_netdevice(net_dev);
+       unregister_netdev(net_dev);
 
        /* XXX qfe parent interrupt... */