aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/gunze.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/touchscreen/gunze.c')
-rw-r--r--drivers/input/touchscreen/gunze.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
index 53a27e43dd23..466da190ceec 100644
--- a/drivers/input/touchscreen/gunze.c
+++ b/drivers/input/touchscreen/gunze.c
@@ -48,14 +48,12 @@ MODULE_LICENSE("GPL");
48 48
49#define GUNZE_MAX_LENGTH 10 49#define GUNZE_MAX_LENGTH 10
50 50
51static char *gunze_name = "Gunze AHL-51S TouchScreen";
52
53/* 51/*
54 * Per-touchscreen data. 52 * Per-touchscreen data.
55 */ 53 */
56 54
57struct gunze { 55struct gunze {
58 struct input_dev dev; 56 struct input_dev *dev;
59 struct serio *serio; 57 struct serio *serio;
60 int idx; 58 int idx;
61 unsigned char data[GUNZE_MAX_LENGTH]; 59 unsigned char data[GUNZE_MAX_LENGTH];
@@ -64,7 +62,7 @@ struct gunze {
64 62
65static void gunze_process_packet(struct gunze* gunze, struct pt_regs *regs) 63static void gunze_process_packet(struct gunze* gunze, struct pt_regs *regs)
66{ 64{
67 struct input_dev *dev = &gunze->dev; 65 struct input_dev *dev = gunze->dev;
68 66
69 if (gunze->idx != GUNZE_MAX_LENGTH || gunze->data[5] != ',' || 67 if (gunze->idx != GUNZE_MAX_LENGTH || gunze->data[5] != ',' ||
70 (gunze->data[0] != 'T' && gunze->data[0] != 'R')) { 68 (gunze->data[0] != 'T' && gunze->data[0] != 'R')) {
@@ -100,11 +98,13 @@ static irqreturn_t gunze_interrupt(struct serio *serio,
100 98
101static void gunze_disconnect(struct serio *serio) 99static void gunze_disconnect(struct serio *serio)
102{ 100{
103 struct gunze* gunze = serio_get_drvdata(serio); 101 struct gunze *gunze = serio_get_drvdata(serio);
104 102
105 input_unregister_device(&gunze->dev); 103 input_get_device(gunze->dev);
104 input_unregister_device(gunze->dev);
106 serio_close(serio); 105 serio_close(serio);
107 serio_set_drvdata(serio, NULL); 106 serio_set_drvdata(serio, NULL);
107 input_put_device(gunze->dev);
108 kfree(gunze); 108 kfree(gunze);
109} 109}
110 110
@@ -117,45 +117,45 @@ static void gunze_disconnect(struct serio *serio)
117static int gunze_connect(struct serio *serio, struct serio_driver *drv) 117static int gunze_connect(struct serio *serio, struct serio_driver *drv)
118{ 118{
119 struct gunze *gunze; 119 struct gunze *gunze;
120 struct input_dev *input_dev;
120 int err; 121 int err;
121 122
122 if (!(gunze = kmalloc(sizeof(struct gunze), GFP_KERNEL))) 123 gunze = kzalloc(sizeof(struct gunze), GFP_KERNEL);
123 return -ENOMEM; 124 input_dev = input_allocate_device();
124 125 if (!gunze || !input_dev) {
125 memset(gunze, 0, sizeof(struct gunze)); 126 err = -ENOMEM;
126 127 goto fail;
127 init_input_dev(&gunze->dev); 128 }
128 gunze->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
129 gunze->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
130 input_set_abs_params(&gunze->dev, ABS_X, 24, 1000, 0, 0);
131 input_set_abs_params(&gunze->dev, ABS_Y, 24, 1000, 0, 0);
132 129
133 gunze->serio = serio; 130 gunze->serio = serio;
134 131 gunze->dev = input_dev;
135 sprintf(gunze->phys, "%s/input0", serio->phys); 132 sprintf(gunze->phys, "%s/input0", serio->phys);
136 133
137 gunze->dev.private = gunze; 134 input_dev->private = gunze;
138 gunze->dev.name = gunze_name; 135 input_dev->name = "Gunze AHL-51S TouchScreen";
139 gunze->dev.phys = gunze->phys; 136 input_dev->phys = gunze->phys;
140 gunze->dev.id.bustype = BUS_RS232; 137 input_dev->id.bustype = BUS_RS232;
141 gunze->dev.id.vendor = SERIO_GUNZE; 138 input_dev->id.vendor = SERIO_GUNZE;
142 gunze->dev.id.product = 0x0051; 139 input_dev->id.product = 0x0051;
143 gunze->dev.id.version = 0x0100; 140 input_dev->id.version = 0x0100;
141 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
142 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
143 input_set_abs_params(input_dev, ABS_X, 24, 1000, 0, 0);
144 input_set_abs_params(input_dev, ABS_Y, 24, 1000, 0, 0);
144 145
145 serio_set_drvdata(serio, gunze); 146 serio_set_drvdata(serio, gunze);
146 147
147 err = serio_open(serio, drv); 148 err = serio_open(serio, drv);
148 if (err) { 149 if (err)
149 serio_set_drvdata(serio, NULL); 150 goto fail;
150 kfree(gunze);
151 return err;
152 }
153
154 input_register_device(&gunze->dev);
155
156 printk(KERN_INFO "input: %s on %s\n", gunze_name, serio->phys);
157 151
152 input_register_device(gunze->dev);
158 return 0; 153 return 0;
154
155 fail: serio_set_drvdata(serio, NULL);
156 input_free_device(input_dev);
157 kfree(gunze);
158 return err;
159} 159}
160 160
161/* 161/*