diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-09-15 03:01:50 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-28 12:52:53 -0400 |
commit | b416f2e452b6c0f5075145bb7301f7f3d44d8ed5 (patch) | |
tree | 01f69d80d4d9c75ce88e5f26d373a4a7b38fbe36 /drivers/char | |
parent | eca1ed196cd5b523c1057204cd3672555ad58dfe (diff) |
[PATCH] Input: convert sonypi to dynamic input_dev allocation
Input: convert sonypi 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/char')
-rw-r--r-- | drivers/char/sonypi.c | 92 |
1 files changed, 53 insertions, 39 deletions
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index 36ae9ad2598c..a4873684f22c 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c | |||
@@ -424,10 +424,6 @@ static struct sonypi_eventtypes { | |||
424 | 424 | ||
425 | #define SONYPI_BUF_SIZE 128 | 425 | #define SONYPI_BUF_SIZE 128 |
426 | 426 | ||
427 | /* The name of the devices for the input device drivers */ | ||
428 | #define SONYPI_JOG_INPUTNAME "Sony Vaio Jogdial" | ||
429 | #define SONYPI_KEY_INPUTNAME "Sony Vaio Keys" | ||
430 | |||
431 | /* Correspondance table between sonypi events and input layer events */ | 427 | /* Correspondance table between sonypi events and input layer events */ |
432 | static struct { | 428 | static struct { |
433 | int sonypiev; | 429 | int sonypiev; |
@@ -490,8 +486,8 @@ static struct sonypi_device { | |||
490 | struct fasync_struct *fifo_async; | 486 | struct fasync_struct *fifo_async; |
491 | int open_count; | 487 | int open_count; |
492 | int model; | 488 | int model; |
493 | struct input_dev input_jog_dev; | 489 | struct input_dev *input_jog_dev; |
494 | struct input_dev input_key_dev; | 490 | struct input_dev *input_key_dev; |
495 | struct work_struct input_work; | 491 | struct work_struct input_work; |
496 | struct kfifo *input_fifo; | 492 | struct kfifo *input_fifo; |
497 | spinlock_t input_fifo_lock; | 493 | spinlock_t input_fifo_lock; |
@@ -779,8 +775,8 @@ static void input_keyrelease(void *data) | |||
779 | 775 | ||
780 | static void sonypi_report_input_event(u8 event) | 776 | static void sonypi_report_input_event(u8 event) |
781 | { | 777 | { |
782 | struct input_dev *jog_dev = &sonypi_device.input_jog_dev; | 778 | struct input_dev *jog_dev = sonypi_device.input_jog_dev; |
783 | struct input_dev *key_dev = &sonypi_device.input_key_dev; | 779 | struct input_dev *key_dev = sonypi_device.input_key_dev; |
784 | struct sonypi_keypress kp = { NULL }; | 780 | struct sonypi_keypress kp = { NULL }; |
785 | int i; | 781 | int i; |
786 | 782 | ||
@@ -1203,6 +1199,47 @@ static struct device_driver sonypi_driver = { | |||
1203 | .shutdown = sonypi_shutdown, | 1199 | .shutdown = sonypi_shutdown, |
1204 | }; | 1200 | }; |
1205 | 1201 | ||
1202 | static int __devinit sonypi_create_input_devices(void) | ||
1203 | { | ||
1204 | struct input_dev *jog_dev; | ||
1205 | struct input_dev *key_dev; | ||
1206 | int i; | ||
1207 | |||
1208 | sonypi_device.input_jog_dev = jog_dev = input_allocate_device(); | ||
1209 | if (!jog_dev) | ||
1210 | return -ENOMEM; | ||
1211 | |||
1212 | jog_dev->name = "Sony Vaio Jogdial"; | ||
1213 | jog_dev->id.bustype = BUS_ISA; | ||
1214 | jog_dev->id.vendor = PCI_VENDOR_ID_SONY; | ||
1215 | |||
1216 | jog_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | ||
1217 | jog_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_MIDDLE); | ||
1218 | jog_dev->relbit[0] = BIT(REL_WHEEL); | ||
1219 | |||
1220 | sonypi_device.input_key_dev = key_dev = input_allocate_device(); | ||
1221 | if (!key_dev) { | ||
1222 | input_free_device(jog_dev); | ||
1223 | sonypi_device.input_jog_dev = NULL; | ||
1224 | return -ENOMEM; | ||
1225 | } | ||
1226 | |||
1227 | key_dev->name = "Sony Vaio Keys"; | ||
1228 | key_dev->id.bustype = BUS_ISA; | ||
1229 | key_dev->id.vendor = PCI_VENDOR_ID_SONY; | ||
1230 | |||
1231 | /* Initialize the Input Drivers: special keys */ | ||
1232 | key_dev->evbit[0] = BIT(EV_KEY); | ||
1233 | for (i = 0; sonypi_inputkeys[i].sonypiev; i++) | ||
1234 | if (sonypi_inputkeys[i].inputev) | ||
1235 | set_bit(sonypi_inputkeys[i].inputev, key_dev->keybit); | ||
1236 | |||
1237 | input_register_device(jog_dev); | ||
1238 | input_register_device(key_dev); | ||
1239 | |||
1240 | return 0; | ||
1241 | } | ||
1242 | |||
1206 | static int __devinit sonypi_probe(void) | 1243 | static int __devinit sonypi_probe(void) |
1207 | { | 1244 | { |
1208 | int i, ret; | 1245 | int i, ret; |
@@ -1298,34 +1335,10 @@ static int __devinit sonypi_probe(void) | |||
1298 | } | 1335 | } |
1299 | 1336 | ||
1300 | if (useinput) { | 1337 | if (useinput) { |
1301 | /* Initialize the Input Drivers: jogdial */ | ||
1302 | int i; | ||
1303 | sonypi_device.input_jog_dev.evbit[0] = | ||
1304 | BIT(EV_KEY) | BIT(EV_REL); | ||
1305 | sonypi_device.input_jog_dev.keybit[LONG(BTN_MOUSE)] = | ||
1306 | BIT(BTN_MIDDLE); | ||
1307 | sonypi_device.input_jog_dev.relbit[0] = BIT(REL_WHEEL); | ||
1308 | sonypi_device.input_jog_dev.name = SONYPI_JOG_INPUTNAME; | ||
1309 | sonypi_device.input_jog_dev.id.bustype = BUS_ISA; | ||
1310 | sonypi_device.input_jog_dev.id.vendor = PCI_VENDOR_ID_SONY; | ||
1311 | |||
1312 | input_register_device(&sonypi_device.input_jog_dev); | ||
1313 | printk(KERN_INFO "%s input method installed.\n", | ||
1314 | sonypi_device.input_jog_dev.name); | ||
1315 | |||
1316 | /* Initialize the Input Drivers: special keys */ | ||
1317 | sonypi_device.input_key_dev.evbit[0] = BIT(EV_KEY); | ||
1318 | for (i = 0; sonypi_inputkeys[i].sonypiev; i++) | ||
1319 | if (sonypi_inputkeys[i].inputev) | ||
1320 | set_bit(sonypi_inputkeys[i].inputev, | ||
1321 | sonypi_device.input_key_dev.keybit); | ||
1322 | sonypi_device.input_key_dev.name = SONYPI_KEY_INPUTNAME; | ||
1323 | sonypi_device.input_key_dev.id.bustype = BUS_ISA; | ||
1324 | sonypi_device.input_key_dev.id.vendor = PCI_VENDOR_ID_SONY; | ||
1325 | 1338 | ||
1326 | input_register_device(&sonypi_device.input_key_dev); | 1339 | ret = sonypi_create_input_devices(); |
1327 | printk(KERN_INFO "%s input method installed.\n", | 1340 | if (ret) |
1328 | sonypi_device.input_key_dev.name); | 1341 | goto out_inputdevices; |
1329 | 1342 | ||
1330 | spin_lock_init(&sonypi_device.input_fifo_lock); | 1343 | spin_lock_init(&sonypi_device.input_fifo_lock); |
1331 | sonypi_device.input_fifo = | 1344 | sonypi_device.input_fifo = |
@@ -1375,8 +1388,9 @@ static int __devinit sonypi_probe(void) | |||
1375 | out_platformdev: | 1388 | out_platformdev: |
1376 | kfifo_free(sonypi_device.input_fifo); | 1389 | kfifo_free(sonypi_device.input_fifo); |
1377 | out_infifo: | 1390 | out_infifo: |
1378 | input_unregister_device(&sonypi_device.input_key_dev); | 1391 | input_unregister_device(sonypi_device.input_key_dev); |
1379 | input_unregister_device(&sonypi_device.input_jog_dev); | 1392 | input_unregister_device(sonypi_device.input_jog_dev); |
1393 | out_inputdevices: | ||
1380 | free_irq(sonypi_device.irq, sonypi_irq); | 1394 | free_irq(sonypi_device.irq, sonypi_irq); |
1381 | out_reqirq: | 1395 | out_reqirq: |
1382 | release_region(sonypi_device.ioport1, sonypi_device.region_size); | 1396 | release_region(sonypi_device.ioport1, sonypi_device.region_size); |
@@ -1402,8 +1416,8 @@ static void __devexit sonypi_remove(void) | |||
1402 | platform_device_unregister(sonypi_device.pdev); | 1416 | platform_device_unregister(sonypi_device.pdev); |
1403 | 1417 | ||
1404 | if (useinput) { | 1418 | if (useinput) { |
1405 | input_unregister_device(&sonypi_device.input_key_dev); | 1419 | input_unregister_device(sonypi_device.input_key_dev); |
1406 | input_unregister_device(&sonypi_device.input_jog_dev); | 1420 | input_unregister_device(sonypi_device.input_jog_dev); |
1407 | kfifo_free(sonypi_device.input_fifo); | 1421 | kfifo_free(sonypi_device.input_fifo); |
1408 | } | 1422 | } |
1409 | 1423 | ||