*/
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;
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.
/*
* 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));
"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,
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 */
ts->dev.keybit[LONG(KEY_SUSPEND)] |= BIT(KEY_SUSPEND);
ts->serio = serio;
- serio->private = ts;
sprintf(ts->phys, "%s/input0", serio->phys);
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 */
#ifdef CONFIG_PM
- ts->dev.pm_dev = pm_register(PM_ILLUMINATION_DEV, PM_SYS_LIGHT,
- h3600ts_pm_callback);
+ ts->pm_dev = pm_register(PM_ILLUMINATION_DEV, PM_SYS_LIGHT,
+ h3600ts_pm_callback);
printk("registered pm callback\n");
#endif
input_register_device(&ts->dev);
printk(KERN_INFO "input: %s on %s\n", h3600_name, serio->phys);
+
+ return 0;
}
/*
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,