diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-09-15 03:01:52 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-28 12:52:53 -0400 |
commit | 17dd3f0f7aa729a042af5d3318ff9b3e7781b45b (patch) | |
tree | 261580f0229e6365f044cd26925dfb2735e0754d /drivers/input/joystick/stinger.c | |
parent | 0259567ad60df13a55583b84d2cddb5526705907 (diff) |
[PATCH] drivers/input/joystick: convert to dynamic input_dev allocation
Input: convert drivers/input/joystick 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/joystick/stinger.c')
-rw-r--r-- | drivers/input/joystick/stinger.c | 75 |
1 files changed, 33 insertions, 42 deletions
diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c index 6f6e6753d590..0a9ed1d30636 100644 --- a/drivers/input/joystick/stinger.c +++ b/drivers/input/joystick/stinger.c | |||
@@ -48,14 +48,12 @@ MODULE_LICENSE("GPL"); | |||
48 | 48 | ||
49 | #define STINGER_MAX_LENGTH 8 | 49 | #define STINGER_MAX_LENGTH 8 |
50 | 50 | ||
51 | static char *stinger_name = "Gravis Stinger"; | ||
52 | |||
53 | /* | 51 | /* |
54 | * Per-Stinger data. | 52 | * Per-Stinger data. |
55 | */ | 53 | */ |
56 | 54 | ||
57 | struct stinger { | 55 | struct stinger { |
58 | struct input_dev dev; | 56 | struct input_dev *dev; |
59 | int idx; | 57 | int idx; |
60 | unsigned char data[STINGER_MAX_LENGTH]; | 58 | unsigned char data[STINGER_MAX_LENGTH]; |
61 | char phys[32]; | 59 | char phys[32]; |
@@ -68,7 +66,7 @@ struct stinger { | |||
68 | 66 | ||
69 | static void stinger_process_packet(struct stinger *stinger, struct pt_regs *regs) | 67 | static void stinger_process_packet(struct stinger *stinger, struct pt_regs *regs) |
70 | { | 68 | { |
71 | struct input_dev *dev = &stinger->dev; | 69 | struct input_dev *dev = stinger->dev; |
72 | unsigned char *data = stinger->data; | 70 | unsigned char *data = stinger->data; |
73 | 71 | ||
74 | if (!stinger->idx) return; | 72 | if (!stinger->idx) return; |
@@ -126,9 +124,9 @@ static void stinger_disconnect(struct serio *serio) | |||
126 | { | 124 | { |
127 | struct stinger *stinger = serio_get_drvdata(serio); | 125 | struct stinger *stinger = serio_get_drvdata(serio); |
128 | 126 | ||
129 | input_unregister_device(&stinger->dev); | ||
130 | serio_close(serio); | 127 | serio_close(serio); |
131 | serio_set_drvdata(serio, NULL); | 128 | serio_set_drvdata(serio, NULL); |
129 | input_unregister_device(stinger->dev); | ||
132 | kfree(stinger); | 130 | kfree(stinger); |
133 | } | 131 | } |
134 | 132 | ||
@@ -141,53 +139,46 @@ static void stinger_disconnect(struct serio *serio) | |||
141 | static int stinger_connect(struct serio *serio, struct serio_driver *drv) | 139 | static int stinger_connect(struct serio *serio, struct serio_driver *drv) |
142 | { | 140 | { |
143 | struct stinger *stinger; | 141 | struct stinger *stinger; |
144 | int i; | 142 | struct input_dev *input_dev; |
145 | int err; | 143 | int err = -ENOMEM; |
146 | |||
147 | if (!(stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL))) | ||
148 | return -ENOMEM; | ||
149 | |||
150 | memset(stinger, 0, sizeof(struct stinger)); | ||
151 | 144 | ||
152 | stinger->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 145 | stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL); |
153 | stinger->dev.keybit[LONG(BTN_A)] = BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_X) | \ | 146 | input_dev = input_allocate_device(); |
154 | BIT(BTN_Y) | BIT(BTN_Z) | BIT(BTN_TL) | BIT(BTN_TR) | \ | 147 | if (!stinger || !input_dev) |
155 | BIT(BTN_START) | BIT(BTN_SELECT); | 148 | goto fail; |
156 | stinger->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
157 | 149 | ||
150 | stinger->dev = input_dev; | ||
158 | sprintf(stinger->phys, "%s/serio0", serio->phys); | 151 | sprintf(stinger->phys, "%s/serio0", serio->phys); |
159 | 152 | ||
160 | init_input_dev(&stinger->dev); | 153 | input_dev->name = "Gravis Stinger"; |
161 | stinger->dev.name = stinger_name; | 154 | input_dev->phys = stinger->phys; |
162 | stinger->dev.phys = stinger->phys; | 155 | input_dev->id.bustype = BUS_RS232; |
163 | stinger->dev.id.bustype = BUS_RS232; | 156 | input_dev->id.vendor = SERIO_STINGER; |
164 | stinger->dev.id.vendor = SERIO_STINGER; | 157 | input_dev->id.product = 0x0001; |
165 | stinger->dev.id.product = 0x0001; | 158 | input_dev->id.version = 0x0100; |
166 | stinger->dev.id.version = 0x0100; | 159 | input_dev->cdev.dev = &serio->dev; |
167 | stinger->dev.dev = &serio->dev; | 160 | input_dev->private = stinger; |
168 | 161 | ||
169 | for (i = 0; i < 2; i++) { | 162 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
170 | stinger->dev.absmax[ABS_X+i] = 64; | 163 | input_dev->keybit[LONG(BTN_A)] = BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_X) | |
171 | stinger->dev.absmin[ABS_X+i] = -64; | 164 | BIT(BTN_Y) | BIT(BTN_Z) | BIT(BTN_TL) | BIT(BTN_TR) | |
172 | stinger->dev.absflat[ABS_X+i] = 4; | 165 | BIT(BTN_START) | BIT(BTN_SELECT); |
173 | } | 166 | input_set_abs_params(input_dev, ABS_X, -64, 64, 0, 4); |
174 | 167 | input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 4); | |
175 | stinger->dev.private = stinger; | ||
176 | 168 | ||
177 | serio_set_drvdata(serio, stinger); | 169 | serio_set_drvdata(serio, stinger); |
178 | 170 | ||
179 | err = serio_open(serio, drv); | 171 | err = serio_open(serio, drv); |
180 | if (err) { | 172 | if (err) |
181 | serio_set_drvdata(serio, NULL); | 173 | goto fail; |
182 | kfree(stinger); | ||
183 | return err; | ||
184 | } | ||
185 | |||
186 | input_register_device(&stinger->dev); | ||
187 | |||
188 | printk(KERN_INFO "input: %s on %s\n", stinger_name, serio->phys); | ||
189 | 174 | ||
175 | input_register_device(stinger->dev); | ||
190 | return 0; | 176 | return 0; |
177 | |||
178 | fail: serio_set_drvdata(serio, NULL); | ||
179 | input_free_device(input_dev); | ||
180 | kfree(stinger); | ||
181 | return err; | ||
191 | } | 182 | } |
192 | 183 | ||
193 | /* | 184 | /* |