aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/mtouch.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-09-15 03:01:46 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 12:52:53 -0400
commiteca1ed196cd5b523c1057204cd3672555ad58dfe (patch)
treebf60f0c3ab6cbaf3235fe01387009e7df4b0926c /drivers/input/touchscreen/mtouch.c
parentbd622663192e8ebebb27dc1d9397f352a82d2495 (diff)
[PATCH] drivers/input/touchscreen: convert to dynamic input_dev allocation
Input: convert drivers/input/touchscreen to dynamic input_dev allocation This is required for input_dev sysfs integration Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/input/touchscreen/mtouch.c')
-rw-r--r--drivers/input/touchscreen/mtouch.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c
index aa8ee7842179..1d0d37eeef6e 100644
--- a/drivers/input/touchscreen/mtouch.c
+++ b/drivers/input/touchscreen/mtouch.c
@@ -51,14 +51,12 @@ MODULE_LICENSE("GPL");
51#define MTOUCH_GET_YC(data) (((data[4])<<7) | data[3]) 51#define MTOUCH_GET_YC(data) (((data[4])<<7) | data[3])
52#define MTOUCH_GET_TOUCHED(data) (MTOUCH_FORMAT_TABLET_TOUCH_BIT & data[0]) 52#define MTOUCH_GET_TOUCHED(data) (MTOUCH_FORMAT_TABLET_TOUCH_BIT & data[0])
53 53
54static char *mtouch_name = "MicroTouch Serial TouchScreen";
55
56/* 54/*
57 * Per-touchscreen data. 55 * Per-touchscreen data.
58 */ 56 */
59 57
60struct mtouch { 58struct mtouch {
61 struct input_dev dev; 59 struct input_dev *dev;
62 struct serio *serio; 60 struct serio *serio;
63 int idx; 61 int idx;
64 unsigned char data[MTOUCH_MAX_LENGTH]; 62 unsigned char data[MTOUCH_MAX_LENGTH];
@@ -67,7 +65,7 @@ struct mtouch {
67 65
68static void mtouch_process_format_tablet(struct mtouch *mtouch, struct pt_regs *regs) 66static void mtouch_process_format_tablet(struct mtouch *mtouch, struct pt_regs *regs)
69{ 67{
70 struct input_dev *dev = &mtouch->dev; 68 struct input_dev *dev = mtouch->dev;
71 69
72 if (MTOUCH_FORMAT_TABLET_LENGTH == ++mtouch->idx) { 70 if (MTOUCH_FORMAT_TABLET_LENGTH == ++mtouch->idx) {
73 input_regs(dev, regs); 71 input_regs(dev, regs);
@@ -116,9 +114,11 @@ static void mtouch_disconnect(struct serio *serio)
116{ 114{
117 struct mtouch* mtouch = serio_get_drvdata(serio); 115 struct mtouch* mtouch = serio_get_drvdata(serio);
118 116
119 input_unregister_device(&mtouch->dev); 117 input_get_device(mtouch->dev);
118 input_unregister_device(mtouch->dev);
120 serio_close(serio); 119 serio_close(serio);
121 serio_set_drvdata(serio, NULL); 120 serio_set_drvdata(serio, NULL);
121 input_put_device(mtouch->dev);
122 kfree(mtouch); 122 kfree(mtouch);
123} 123}
124 124
@@ -131,46 +131,46 @@ static void mtouch_disconnect(struct serio *serio)
131static int mtouch_connect(struct serio *serio, struct serio_driver *drv) 131static int mtouch_connect(struct serio *serio, struct serio_driver *drv)
132{ 132{
133 struct mtouch *mtouch; 133 struct mtouch *mtouch;
134 struct input_dev *input_dev;
134 int err; 135 int err;
135 136
136 if (!(mtouch = kmalloc(sizeof(*mtouch), GFP_KERNEL))) 137 mtouch = kzalloc(sizeof(struct mtouch), GFP_KERNEL);
137 return -ENOMEM; 138 input_dev = input_allocate_device();
138 139 if (!mtouch || !input_dev) {
139 memset(mtouch, 0, sizeof(*mtouch)); 140 err = -ENOMEM;
140 141 goto fail;
141 init_input_dev(&mtouch->dev); 142 }
142 mtouch->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
143 mtouch->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
144
145 input_set_abs_params(&mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0);
146 input_set_abs_params(&mtouch->dev, ABS_Y, MTOUCH_MIN_YC, MTOUCH_MAX_YC, 0, 0);
147 143
148 mtouch->serio = serio; 144 mtouch->serio = serio;
149 145 mtouch->dev = input_dev;
150 sprintf(mtouch->phys, "%s/input0", serio->phys); 146 sprintf(mtouch->phys, "%s/input0", serio->phys);
151 147
152 mtouch->dev.private = mtouch; 148 input_dev->private = mtouch;
153 mtouch->dev.name = mtouch_name; 149 input_dev->name = "MicroTouch Serial TouchScreen";
154 mtouch->dev.phys = mtouch->phys; 150 input_dev->phys = mtouch->phys;
155 mtouch->dev.id.bustype = BUS_RS232; 151 input_dev->id.bustype = BUS_RS232;
156 mtouch->dev.id.vendor = SERIO_MICROTOUCH; 152 input_dev->id.vendor = SERIO_MICROTOUCH;
157 mtouch->dev.id.product = 0; 153 input_dev->id.product = 0;
158 mtouch->dev.id.version = 0x0100; 154 input_dev->id.version = 0x0100;
155 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
156 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
157 input_set_abs_params(mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0);
158 input_set_abs_params(mtouch->dev, ABS_Y, MTOUCH_MIN_YC, MTOUCH_MAX_YC, 0, 0);
159 159
160 serio_set_drvdata(serio, mtouch); 160 serio_set_drvdata(serio, mtouch);
161 161
162 err = serio_open(serio, drv); 162 err = serio_open(serio, drv);
163 if (err) { 163 if (err)
164 serio_set_drvdata(serio, NULL); 164 goto fail;
165 kfree(mtouch);
166 return err;
167 }
168
169 input_register_device(&mtouch->dev);
170 165
171 printk(KERN_INFO "input: %s on %s\n", mtouch->dev.name, serio->phys); 166 input_register_device(mtouch->dev);
172 167
173 return 0; 168 return 0;
169
170 fail: serio_set_drvdata(serio, NULL);
171 input_free_device(input_dev);
172 kfree(mtouch);
173 return err;
174} 174}
175 175
176/* 176/*