V4L/DVB (11743): Analog Devices ADV7343 video encoder driver
[pandora-kernel.git] / drivers / media / video / cpia_pp.c
index 41f4b8d..c431df8 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/workqueue.h>
-#include <linux/smp_lock.h>
 #include <linux/sched.h>
 
 #include <linux/kmod.h>
@@ -62,7 +61,6 @@ static int cpia_pp_close(void *privdata);
 #define PPCPIA_PARPORT_OFF -2
 #define PPCPIA_PARPORT_NONE -1
 
-#ifdef MODULE
 static int parport_nr[PARPORT_MAX] = {[0 ... PARPORT_MAX - 1] = PPCPIA_PARPORT_UNSPEC};
 static char *parport[PARPORT_MAX] = {NULL,};
 
@@ -72,16 +70,13 @@ MODULE_LICENSE("GPL");
 
 module_param_array(parport, charp, NULL, 0);
 MODULE_PARM_DESC(parport, "'auto' or a list of parallel port numbers. Just like lp.");
-#else
-static int parport_nr[PARPORT_MAX] __initdata =
-       {[0 ... PARPORT_MAX - 1] = PPCPIA_PARPORT_UNSPEC};
-static int parport_ptr = 0;
-#endif
 
 struct pp_cam_entry {
        struct pardevice *pdev;
        struct parport *port;
        struct work_struct cb_task;
+       void (*cb_func)(void *cbdata);
+       void *cb_data;
        int open_count;
        wait_queue_head_t wq_stream;
        /* image state flags */
@@ -130,6 +125,19 @@ static void cpia_parport_disable_irq( struct parport *port ) {
 #define PARPORT_CHUNK_SIZE     PAGE_SIZE
 
 
+static void cpia_pp_run_callback(struct work_struct *work)
+{
+       void (*cb_func)(void *cbdata);
+       void *cb_data;
+       struct pp_cam_entry *cam;
+
+       cam = container_of(work, struct pp_cam_entry, cb_task);
+       cb_func = cam->cb_func;
+       cb_data = cam->cb_data;
+
+       cb_func(cb_data);
+}
+
 /****************************************************************************
  *
  *  CPiA-specific  low-level parport functions for nibble uploads
@@ -664,7 +672,9 @@ static int cpia_pp_registerCallback(void *privdata, void (*cb)(void *cbdata), vo
        int retval = 0;
 
        if(cam->port->irq != PARPORT_IRQ_NONE) {
-               INIT_WORK(&cam->cb_task, cb, cbdata);
+               cam->cb_func = cb;
+               cam->cb_data = cbdata;
+               INIT_WORK(&cam->cb_task, cpia_pp_run_callback);
        } else {
                retval = -1;
        }
@@ -802,7 +812,7 @@ static struct parport_driver cpia_pp_driver = {
        .detach = cpia_pp_detach,
 };
 
-static int cpia_pp_init(void)
+static int __init cpia_pp_init(void)
 {
        printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT,
               CPIA_PP_MAJ_VER,CPIA_PP_MIN_VER,CPIA_PP_PATCH_VER);
@@ -821,8 +831,7 @@ static int cpia_pp_init(void)
        return 0;
 }
 
-#ifdef MODULE
-int init_module(void)
+static int __init cpia_init(void)
 {
        if (parport[0]) {
                /* The user gave some parameters.  Let's see what they were. */
@@ -849,38 +858,11 @@ int init_module(void)
        return cpia_pp_init();
 }
 
-void cleanup_module(void)
+static void __exit cpia_cleanup(void)
 {
-       parport_unregister_driver (&cpia_pp_driver);
+       parport_unregister_driver(&cpia_pp_driver);
        return;
 }
 
-#else /* !MODULE */
-
-static int __init cpia_pp_setup(char *str)
-{
-       int err;
-
-       if (!strncmp(str, "parport", 7)) {
-               int n = simple_strtoul(str + 7, NULL, 10);
-               if (parport_ptr < PARPORT_MAX) {
-                       parport_nr[parport_ptr++] = n;
-               } else {
-                       LOG("too many ports, %s ignored.\n", str);
-               }
-       } else if (!strcmp(str, "auto")) {
-               parport_nr[0] = PPCPIA_PARPORT_AUTO;
-       } else if (!strcmp(str, "none")) {
-               parport_nr[parport_ptr++] = PPCPIA_PARPORT_NONE;
-       }
-
-       err=cpia_pp_init();
-       if (err)
-               return err;
-
-       return 1;
-}
-
-__setup("cpia_pp=", cpia_pp_setup);
-
-#endif /* !MODULE */
+module_init(cpia_init);
+module_exit(cpia_cleanup);