Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[pandora-kernel.git] / drivers / input / joystick / turbografx.c
index b154938..b6f8598 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: turbografx.c,v 1.14 2002/01/22 20:30:39 vojtech Exp $
- *
  *  Copyright (c) 1998-2001 Vojtech Pavlik
  *
  *  Based on the work of:
@@ -35,8 +33,8 @@
 #include <linux/parport.h>
 #include <linux/input.h>
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/init.h>
+#include <linux/mutex.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
 MODULE_DESCRIPTION("TurboGraFX parallel port interface driver");
@@ -47,22 +45,18 @@ MODULE_LICENSE("GPL");
 
 struct tgfx_config {
        int args[TGFX_MAX_DEVICES + 1];
-       int nargs;
+       unsigned int nargs;
 };
 
-static struct tgfx_config tgfx[TGFX_MAX_PORTS] __initdata;
+static struct tgfx_config tgfx_cfg[TGFX_MAX_PORTS] __initdata;
 
-module_param_array_named(map, tgfx[0].args, int, &tgfx[0].nargs, 0);
+module_param_array_named(map, tgfx_cfg[0].args, int, &tgfx_cfg[0].nargs, 0);
 MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<js1>,<js2>,..<js7>");
-module_param_array_named(map2, tgfx[1].args, int, &tgfx[1].nargs, 0);
+module_param_array_named(map2, tgfx_cfg[1].args, int, &tgfx_cfg[1].nargs, 0);
 MODULE_PARM_DESC(map2, "Describes second set of devices");
-module_param_array_named(map3, tgfx[2].args, int, &tgfx[2].nargs, 0);
+module_param_array_named(map3, tgfx_cfg[2].args, int, &tgfx_cfg[2].nargs, 0);
 MODULE_PARM_DESC(map3, "Describes third set of devices");
 
-__obsolete_setup("tgfx=");
-__obsolete_setup("tgfx_2=");
-__obsolete_setup("tgfx_3=");
-
 #define TGFX_REFRESH_TIME      HZ/100  /* 10 ms */
 
 #define TGFX_TRIGGER           0x08
@@ -86,7 +80,7 @@ static struct tgfx {
        char phys[TGFX_MAX_DEVICES][32];
        int sticks;
        int used;
-       struct semaphore sem;
+       struct mutex sem;
 } *tgfx_base[TGFX_MAX_PORTS];
 
 /*
@@ -125,10 +119,10 @@ static void tgfx_timer(unsigned long private)
 
 static int tgfx_open(struct input_dev *dev)
 {
-       struct tgfx *tgfx = dev->private;
+       struct tgfx *tgfx = input_get_drvdata(dev);
        int err;
 
-       err = down_interruptible(&tgfx->sem);
+       err = mutex_lock_interruptible(&tgfx->sem);
        if (err)
                return err;
 
@@ -138,21 +132,21 @@ static int tgfx_open(struct input_dev *dev)
                mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME);
        }
 
-       up(&tgfx->sem);
+       mutex_unlock(&tgfx->sem);
        return 0;
 }
 
 static void tgfx_close(struct input_dev *dev)
 {
-       struct tgfx *tgfx = dev->private;
+       struct tgfx *tgfx = input_get_drvdata(dev);
 
-       down(&tgfx->sem);
+       mutex_lock(&tgfx->sem);
        if (!--tgfx->used) {
                del_timer_sync(&tgfx->timer);
                parport_write_control(tgfx->pd->port, 0x00);
                parport_release(tgfx->pd);
        }
-       up(&tgfx->sem);
+       mutex_unlock(&tgfx->sem);
 }
 
 
@@ -191,7 +185,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
                goto err_unreg_pardev;
        }
 
-       init_MUTEX(&tgfx->sem);
+       mutex_init(&tgfx->sem);
        tgfx->pd = pd;
        init_timer(&tgfx->timer);
        tgfx->timer.data = (long) tgfx;
@@ -227,11 +221,12 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
                input_dev->id.product = n_buttons[i];
                input_dev->id.version = 0x0100;
 
-               input_dev->private = tgfx;
+               input_set_drvdata(input_dev, tgfx);
+
                input_dev->open = tgfx_open;
                input_dev->close = tgfx_close;
 
-               input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+               input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
                input_set_abs_params(input_dev, ABS_X, -1, 1, 0, 0);
                input_set_abs_params(input_dev, ABS_Y, -1, 1, 0, 0);
 
@@ -285,16 +280,18 @@ static int __init tgfx_init(void)
        int err = 0;
 
        for (i = 0; i < TGFX_MAX_PORTS; i++) {
-               if (tgfx[i].nargs == 0 || tgfx[i].args[0] < 0)
+               if (tgfx_cfg[i].nargs == 0 || tgfx_cfg[i].args[0] < 0)
                        continue;
 
-               if (tgfx[i].nargs < 2) {
+               if (tgfx_cfg[i].nargs < 2) {
                        printk(KERN_ERR "turbografx.c: at least one joystick must be specified\n");
                        err = -EINVAL;
                        break;
                }
 
-               tgfx_base[i] = tgfx_probe(tgfx[i].args[0], tgfx[i].args + 1, tgfx[i].nargs - 1);
+               tgfx_base[i] = tgfx_probe(tgfx_cfg[i].args[0],
+                                         tgfx_cfg[i].args + 1,
+                                         tgfx_cfg[i].nargs - 1);
                if (IS_ERR(tgfx_base[i])) {
                        err = PTR_ERR(tgfx_base[i]);
                        break;