vserver 2.0 rc7
[linux-2.6.git] / drivers / input / touchscreen / h3600_ts_input.c
index 10ace15..acb9137 100644 (file)
@@ -102,6 +102,7 @@ struct h3600_dev {
        struct input_dev dev;
        struct pm_dev *pm_dev;
        struct serio *serio;
+       struct pm_dev *pm_dev;
        unsigned char event;    /* event ID from packet */
        unsigned char chksum;
        unsigned char len;
@@ -331,7 +332,7 @@ static int state;
 static irqreturn_t h3600ts_interrupt(struct serio *serio, unsigned char data,
                                      unsigned int flags, struct pt_regs *regs)
 {
-        struct h3600_dev *ts = serio->private;
+        struct h3600_dev *ts = serio_get_drvdata(serio);
 
        /*
          * We have a new frame coming in.
@@ -373,18 +374,16 @@ static irqreturn_t h3600ts_interrupt(struct serio *serio, unsigned char data,
 
 /*
  * h3600ts_connect() is the routine that is called when someone adds a
- * new serio device. It looks whether it was registered as a H3600 touchscreen
- * and if yes, registers it as an input device.
+ * new serio device that supports H3600 protocol and registers it as
+ * an input device.
  */
-static void h3600ts_connect(struct serio *serio, struct serio_driver *drv)
+static int h3600ts_connect(struct serio *serio, struct serio_driver *drv)
 {
        struct h3600_dev *ts;
-
-       if (serio->type != (SERIO_RS232 | SERIO_H3600))
-               return;
+       int err;
 
        if (!(ts = kmalloc(sizeof(struct h3600_dev), GFP_KERNEL)))
-               return;
+               return -ENOMEM;
 
        memset(ts, 0, sizeof(struct h3600_dev));
 
@@ -399,7 +398,7 @@ static void h3600ts_connect(struct serio *serio, struct serio_driver *drv)
                        "h3600_action", &ts->dev)) {
                printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n");
                kfree(ts);
-               return;
+               return -EBUSY;
        }
 
         if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler,
@@ -408,7 +407,7 @@ static void h3600ts_connect(struct serio *serio, struct serio_driver *drv)
                free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev);
                printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n");
                kfree(ts);
-               return;
+               return -EBUSY;
        }
 
        /* Now we have things going we setup our input device */
@@ -431,7 +430,6 @@ static void h3600ts_connect(struct serio *serio, struct serio_driver *drv)
        ts->dev.keybit[LONG(KEY_SUSPEND)] |= BIT(KEY_SUSPEND);
 
        ts->serio = serio;
-       serio->private = ts;
 
        sprintf(ts->phys, "%s/input0", serio->phys);
 
@@ -444,11 +442,15 @@ static void h3600ts_connect(struct serio *serio, struct serio_driver *drv)
        ts->dev.id.product = 0x0666;  /* FIXME !!! We can ask the hardware */
        ts->dev.id.version = 0x0100;
 
-       if (serio_open(serio, drv)) {
+       serio_set_drvdata(serio, ts);
+
+       err = serio_open(serio, drv);
+       if (err) {
                free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts);
                free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts);
+               serio_set_drvdata(serio, NULL);
                kfree(ts);
-               return;
+               return err;
        }
 
        //h3600_flite_control(1, 25);     /* default brightness */
@@ -460,6 +462,8 @@ static void h3600ts_connect(struct serio *serio, struct serio_driver *drv)
        input_register_device(&ts->dev);
 
        printk(KERN_INFO "input: %s on %s\n", h3600_name, serio->phys);
+
+       return 0;
 }
 
 /*
@@ -468,24 +472,38 @@ static void h3600ts_connect(struct serio *serio, struct serio_driver *drv)
 
 static void h3600ts_disconnect(struct serio *serio)
 {
-       struct h3600_dev *ts = serio->private;
+       struct h3600_dev *ts = serio_get_drvdata(serio);
 
-        free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev);
-        free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev);
+       free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev);
+       free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev);
        input_unregister_device(&ts->dev);
        serio_close(serio);
+       serio_set_drvdata(serio, NULL);
        kfree(ts);
 }
 
 /*
- * The serio device structure.
+ * The serio driver structure.
  */
 
+static struct serio_device_id h3600ts_serio_ids[] = {
+       {
+               .type   = SERIO_RS232,
+               .proto  = SERIO_H3600,
+               .id     = SERIO_ANY,
+               .extra  = SERIO_ANY,
+       },
+       { 0 }
+};
+
+MODULE_DEVICE_TABLE(serio, h3600ts_serio_ids);
+
 static struct serio_driver h3600ts_drv = {
        .driver         = {
                .name   = "h3600ts",
        },
        .description    = DRIVER_DESC,
+       .id_table       = h3600ts_serio_ids,
        .interrupt      = h3600ts_interrupt,
        .connect        = h3600ts_connect,
        .disconnect     = h3600ts_disconnect,