i2c: Document the message size limit
[safe/jmp/linux-2.6] / drivers / parport / parport_sunbpp.c
index 9793533..065f229 100644 (file)
@@ -26,6 +26,8 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #include <linux/parport.h>
 
@@ -34,7 +36,6 @@
 
 #include <asm/io.h>
 #include <asm/oplib.h>           /* OpenProm Library */
-#include <asm/sbus.h>
 #include <asm/dma.h>             /* BPP uses LSI 64854 for DMA */
 #include <asm/irq.h>
 #include <asm/sunbpp.h>
 #define dprintk(x)
 #endif
 
-static irqreturn_t parport_sunbpp_interrupt(int irq, void *dev_id)
-{
-       parport_generic_irq(irq, (struct parport *) dev_id);
-       return IRQ_HANDLED;
-}
-
 static void parport_sunbpp_disable_irq(struct parport *p)
 {
        struct bpp_regs __iomem *regs = (struct bpp_regs __iomem *)p->base;
@@ -126,7 +121,7 @@ static unsigned char status_sunbpp_to_pc(struct parport *p)
        if (!(value_tcr & P_TCR_BUSY))
                bits |= PARPORT_STATUS_BUSY;
 
-       dprintk((KERN_DEBUG "tcr 0x%x ir 0x%x\n", regs->p_tcr, regs->p_ir));
+       dprintk((KERN_DEBUG "tcr 0x%x ir 0x%x\n", value_tcr, value_ir));
        dprintk((KERN_DEBUG "read status 0x%x\n", bits));
        return bits;
 }
@@ -147,7 +142,7 @@ static unsigned char control_sunbpp_to_pc(struct parport *p)
        if (value_or & P_OR_SLCT_IN)
                bits |= PARPORT_CONTROL_SELECT;
 
-       dprintk((KERN_DEBUG "tcr 0x%x or 0x%x\n", regs->p_tcr, regs->p_or));
+       dprintk((KERN_DEBUG "tcr 0x%x or 0x%x\n", value_tcr, value_or));
        dprintk((KERN_DEBUG "read control 0x%x\n", bits));
        return bits;
 }
@@ -165,7 +160,8 @@ static unsigned char parport_sunbpp_frob_control(struct parport *p,
        unsigned char value_tcr = sbus_readb(&regs->p_tcr);
        unsigned char value_or = sbus_readb(&regs->p_or);
 
-       dprintk((KERN_DEBUG "frob1: tcr 0x%x or 0x%x\n", regs->p_tcr, regs->p_or));
+       dprintk((KERN_DEBUG "frob1: tcr 0x%x or 0x%x\n",
+                value_tcr, value_or));
        if (mask & PARPORT_CONTROL_STROBE) {
                if (val & PARPORT_CONTROL_STROBE) {
                        value_tcr &= ~P_TCR_DS;
@@ -197,7 +193,8 @@ static unsigned char parport_sunbpp_frob_control(struct parport *p,
 
        sbus_writeb(value_or, &regs->p_or);
        sbus_writeb(value_tcr, &regs->p_tcr);
-       dprintk((KERN_DEBUG "frob2: tcr 0x%x or 0x%x\n", regs->p_tcr, regs->p_or));
+       dprintk((KERN_DEBUG "frob2: tcr 0x%x or 0x%x\n",
+                value_tcr, value_or));
        return parport_sunbpp_read_control(p);
 }
 
@@ -289,39 +286,39 @@ static struct parport_operations parport_sunbpp_ops =
        .owner          = THIS_MODULE,
 };
 
-static int __devinit init_one_port(struct sbus_dev *sdev)
+static int __devinit bpp_probe(struct of_device *op, const struct of_device_id *match)
 {
-       struct parport *p;
-       /* at least in theory there may be a "we don't dma" case */
        struct parport_operations *ops;
-       void __iomem *base;
-       int irq, dma, err = 0, size;
        struct bpp_regs __iomem *regs;
+       int irq, dma, err = 0, size;
        unsigned char value_tcr;
+       void __iomem *base;
+       struct parport *p;
 
-       irq = sdev->irqs[0];
-       base = sbus_ioremap(&sdev->resource[0], 0,
-                           sdev->reg_addrs[0].reg_size, 
-                           "sunbpp");
+       irq = op->irqs[0];
+       base = of_ioremap(&op->resource[0], 0,
+                         resource_size(&op->resource[0]),
+                         "sunbpp");
        if (!base)
                return -ENODEV;
 
-       size = sdev->reg_addrs[0].reg_size;
+       size = resource_size(&op->resource[0]);
        dma = PARPORT_DMA_NONE;
 
        ops = kmalloc(sizeof(struct parport_operations), GFP_KERNEL);
         if (!ops)
                goto out_unmap;
 
-        memcpy (ops, &parport_sunbpp_ops, sizeof (struct parport_operations));
+        memcpy (ops, &parport_sunbpp_ops, sizeof(struct parport_operations));
 
        dprintk(("register_port\n"));
        if (!(p = parport_register_port((unsigned long)base, irq, dma, ops)))
                goto out_free_ops;
 
        p->size = size;
+       p->dev = &op->dev;
 
-       if ((err = request_irq(p->irq, parport_sunbpp_interrupt,
+       if ((err = request_irq(p->irq, parport_irq_handler,
                               IRQF_SHARED, p->name, p)) != 0) {
                goto out_put_port;
        }
@@ -336,7 +333,7 @@ static int __devinit init_one_port(struct sbus_dev *sdev)
 
        printk(KERN_INFO "%s: sunbpp at 0x%lx\n", p->name, p->base);
 
-       dev_set_drvdata(&sdev->ofdev.dev, p);
+       dev_set_drvdata(&op->dev, p);
 
        parport_announce_port(p);
 
@@ -349,21 +346,14 @@ out_free_ops:
        kfree(ops);
 
 out_unmap:
-       sbus_iounmap(base, size);
+       of_iounmap(&op->resource[0], base, size);
 
        return err;
 }
 
-static int __devinit bpp_probe(struct of_device *dev, const struct of_device_id *match)
-{
-       struct sbus_dev *sdev = to_sbus_device(&dev->dev);
-
-       return init_one_port(sdev);
-}
-
-static int __devexit bpp_remove(struct of_device *dev)
+static int __devexit bpp_remove(struct of_device *op)
 {
-       struct parport *p = dev_get_drvdata(&dev->dev);
+       struct parport *p = dev_get_drvdata(&op->dev);
        struct parport_operations *ops = p->ops;
 
        parport_remove_port(p);
@@ -373,16 +363,16 @@ static int __devexit bpp_remove(struct of_device *dev)
                free_irq(p->irq, p);
        }
 
-       sbus_iounmap((void __iomem *) p->base, p->size);
+       of_iounmap(&op->resource[0], (void __iomem *) p->base, p->size);
        parport_put_port(p);
        kfree(ops);
 
-       dev_set_drvdata(&dev->dev, NULL);
+       dev_set_drvdata(&op->dev, NULL);
 
        return 0;
 }
 
-static struct of_device_id bpp_match[] = {
+static const struct of_device_id bpp_match[] = {
        {
                .name = "SUNW,bpp",
        },
@@ -400,7 +390,7 @@ static struct of_platform_driver bpp_sbus_driver = {
 
 static int __init parport_sunbpp_init(void)
 {
-       return of_register_driver(&bpp_sbus_driver, &sbus_bus_type);
+       return of_register_driver(&bpp_sbus_driver, &of_bus_type);
 }
 
 static void __exit parport_sunbpp_exit(void)