Merge branch 'linux-2.6' into for-2.6.22
[sfrench/cifs-2.6.git] / drivers / media / video / planb.c
index d9e3cada52f4fba0bd349915834a811951a57247..1455a8f4e930389133dd1801fa7e6327517d9365 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/videodev.h>
+#include <media/v4l2-common.h>
 #include <linux/wait.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -90,7 +91,7 @@ static void planb_close(struct video_device *);
 static int planb_ioctl(struct video_device *, unsigned int, void *);
 static int planb_init_done(struct video_device *);
 static int planb_mmap(struct video_device *, const char *, unsigned long);
-static void planb_irq(int, void *, struct pt_regs *);
+static void planb_irq(int, void *);
 static void release_planb(void);
 int init_planbs(struct video_init *);
 
@@ -137,7 +138,7 @@ static int grabbuf_alloc(struct planb *pb)
                + MAX_LNUM
 #endif /* PLANB_GSCANLINE */
                );
-       if ((pb->rawbuf = (unsigned char**) kmalloc (npage
+       if ((pb->rawbuf = kmalloc(npage
                                * sizeof(unsigned long), GFP_KERNEL)) == 0)
                return -ENOMEM;
        for (i = 0; i < npage; i++) {
@@ -1315,7 +1316,7 @@ cmd_tab_data_end:
        return c1;
 }
 
-static void planb_irq(int irq, void *dev_id, struct pt_regs * regs)
+static void planb_irq(int irq, void *dev_id)
 {
        unsigned int stat, astat;
        struct planb *pb = (struct planb *)dev_id;
@@ -2159,7 +2160,7 @@ static int find_planb(void)
        if (!machine_is(powermac))
                return 0;
 
-       planb_devices = find_devices("planb");
+       planb_devices = of_find_node_by_name(NULL, "planb");
        if (planb_devices == 0) {
                planb_num=0;
                printk(KERN_WARNING "PlanB: no device found!\n");
@@ -2174,12 +2175,14 @@ static int find_planb(void)
        if (planb_devices->n_addrs != 1) {
                printk (KERN_WARNING "PlanB: expecting 1 address for planb "
                        "(got %d)", planb_devices->n_addrs);
+               of_node_put(planb_devices);
                return 0;
        }
 
        if (planb_devices->n_intrs == 0) {
                printk(KERN_WARNING "PlanB: no intrs for device %s\n",
                       planb_devices->full_name);
+               of_node_put(planb_devices);
                return 0;
        } else {
                irq = planb_devices->intrs[0].line;
@@ -2201,12 +2204,13 @@ static int find_planb(void)
        confreg = planb_devices->addrs[0].space & 0xff;
        old_base = planb_devices->addrs[0].address;
        new_base = 0xf1000000;
+       of_node_put(planb_devices);
 
        DEBUG("PlanB: Found on bus %d, dev %d, func %d, "
                "membase 0x%x (base reg. 0x%x)\n",
                bus, PCI_SLOT(dev_fn), PCI_FUNC(dev_fn), old_base, confreg);
 
-       pdev = pci_find_slot (bus, dev_fn);
+       pdev = pci_get_bus_and_slot(bus, dev_fn);
        if (!pdev) {
                printk(KERN_ERR "planb: cannot find slot\n");
                goto err_out;
@@ -2236,6 +2240,7 @@ static int find_planb(void)
        pb->planb_base = planb_regs;
        pb->planb_base_phys = (struct planb_registers *)new_base;
        pb->irq = irq;
+       pb->dev = pdev;
 
        return planb_num;
 
@@ -2243,6 +2248,7 @@ err_out_disable:
        pci_disable_device(pdev);
 err_out:
        /* FIXME handle error */   /* comment moved from pci_find_slot, above */
+       pci_dev_put(pdev);
        return 0;
 }
 
@@ -2270,6 +2276,8 @@ static void release_planb(void)
                printk(KERN_INFO "PlanB: unregistering with v4l\n");
                video_unregister_device(&pb->video_dev);
 
+               pci_dev_put(pb->dev);
+
                /* note that iounmap() does nothing on the PPC right now */
                iounmap ((void *)pb->planb_base);
        }