diff options
Diffstat (limited to 'drivers/char/sonypi.c')
-rw-r--r-- | drivers/char/sonypi.c | 122 |
1 files changed, 68 insertions, 54 deletions
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index 36ae9ad2598c..51a07370e636 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/dmi.h> | 48 | #include <linux/dmi.h> |
49 | #include <linux/err.h> | 49 | #include <linux/err.h> |
50 | #include <linux/kfifo.h> | 50 | #include <linux/kfifo.h> |
51 | #include <linux/platform_device.h> | ||
51 | 52 | ||
52 | #include <asm/uaccess.h> | 53 | #include <asm/uaccess.h> |
53 | #include <asm/io.h> | 54 | #include <asm/io.h> |
@@ -424,10 +425,6 @@ static struct sonypi_eventtypes { | |||
424 | 425 | ||
425 | #define SONYPI_BUF_SIZE 128 | 426 | #define SONYPI_BUF_SIZE 128 |
426 | 427 | ||
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 */ | 428 | /* Correspondance table between sonypi events and input layer events */ |
432 | static struct { | 429 | static struct { |
433 | int sonypiev; | 430 | int sonypiev; |
@@ -490,8 +487,8 @@ static struct sonypi_device { | |||
490 | struct fasync_struct *fifo_async; | 487 | struct fasync_struct *fifo_async; |
491 | int open_count; | 488 | int open_count; |
492 | int model; | 489 | int model; |
493 | struct input_dev input_jog_dev; | 490 | struct input_dev *input_jog_dev; |
494 | struct input_dev input_key_dev; | 491 | struct input_dev *input_key_dev; |
495 | struct work_struct input_work; | 492 | struct work_struct input_work; |
496 | struct kfifo *input_fifo; | 493 | struct kfifo *input_fifo; |
497 | spinlock_t input_fifo_lock; | 494 | spinlock_t input_fifo_lock; |
@@ -779,8 +776,8 @@ static void input_keyrelease(void *data) | |||
779 | 776 | ||
780 | static void sonypi_report_input_event(u8 event) | 777 | static void sonypi_report_input_event(u8 event) |
781 | { | 778 | { |
782 | struct input_dev *jog_dev = &sonypi_device.input_jog_dev; | 779 | struct input_dev *jog_dev = sonypi_device.input_jog_dev; |
783 | struct input_dev *key_dev = &sonypi_device.input_key_dev; | 780 | struct input_dev *key_dev = sonypi_device.input_key_dev; |
784 | struct sonypi_keypress kp = { NULL }; | 781 | struct sonypi_keypress kp = { NULL }; |
785 | int i; | 782 | int i; |
786 | 783 | ||
@@ -1171,38 +1168,78 @@ static int sonypi_disable(void) | |||
1171 | #ifdef CONFIG_PM | 1168 | #ifdef CONFIG_PM |
1172 | static int old_camera_power; | 1169 | static int old_camera_power; |
1173 | 1170 | ||
1174 | static int sonypi_suspend(struct device *dev, pm_message_t state, u32 level) | 1171 | static int sonypi_suspend(struct platform_device *dev, pm_message_t state) |
1175 | { | 1172 | { |
1176 | if (level == SUSPEND_DISABLE) { | 1173 | old_camera_power = sonypi_device.camera_power; |
1177 | old_camera_power = sonypi_device.camera_power; | 1174 | sonypi_disable(); |
1178 | sonypi_disable(); | 1175 | |
1179 | } | ||
1180 | return 0; | 1176 | return 0; |
1181 | } | 1177 | } |
1182 | 1178 | ||
1183 | static int sonypi_resume(struct device *dev, u32 level) | 1179 | static int sonypi_resume(struct platform_device *dev) |
1184 | { | 1180 | { |
1185 | if (level == RESUME_ENABLE) | 1181 | sonypi_enable(old_camera_power); |
1186 | sonypi_enable(old_camera_power); | ||
1187 | return 0; | 1182 | return 0; |
1188 | } | 1183 | } |
1189 | #endif | 1184 | #endif |
1190 | 1185 | ||
1191 | static void sonypi_shutdown(struct device *dev) | 1186 | static void sonypi_shutdown(struct platform_device *dev) |
1192 | { | 1187 | { |
1193 | sonypi_disable(); | 1188 | sonypi_disable(); |
1194 | } | 1189 | } |
1195 | 1190 | ||
1196 | static struct device_driver sonypi_driver = { | 1191 | static struct platform_driver sonypi_driver = { |
1197 | .name = "sonypi", | ||
1198 | .bus = &platform_bus_type, | ||
1199 | #ifdef CONFIG_PM | 1192 | #ifdef CONFIG_PM |
1200 | .suspend = sonypi_suspend, | 1193 | .suspend = sonypi_suspend, |
1201 | .resume = sonypi_resume, | 1194 | .resume = sonypi_resume, |
1202 | #endif | 1195 | #endif |
1203 | .shutdown = sonypi_shutdown, | 1196 | .shutdown = sonypi_shutdown, |
1197 | .driver = { | ||
1198 | .name = "sonypi", | ||
1199 | }, | ||
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 | ||
@@ -1442,20 +1456,20 @@ static int __init sonypi_init(void) | |||
1442 | if (!dmi_check_system(sonypi_dmi_table)) | 1456 | if (!dmi_check_system(sonypi_dmi_table)) |
1443 | return -ENODEV; | 1457 | return -ENODEV; |
1444 | 1458 | ||
1445 | ret = driver_register(&sonypi_driver); | 1459 | ret = platform_driver_register(&sonypi_driver); |
1446 | if (ret) | 1460 | if (ret) |
1447 | return ret; | 1461 | return ret; |
1448 | 1462 | ||
1449 | ret = sonypi_probe(); | 1463 | ret = sonypi_probe(); |
1450 | if (ret) | 1464 | if (ret) |
1451 | driver_unregister(&sonypi_driver); | 1465 | platform_driver_unregister(&sonypi_driver); |
1452 | 1466 | ||
1453 | return ret; | 1467 | return ret; |
1454 | } | 1468 | } |
1455 | 1469 | ||
1456 | static void __exit sonypi_exit(void) | 1470 | static void __exit sonypi_exit(void) |
1457 | { | 1471 | { |
1458 | driver_unregister(&sonypi_driver); | 1472 | platform_driver_unregister(&sonypi_driver); |
1459 | sonypi_remove(); | 1473 | sonypi_remove(); |
1460 | } | 1474 | } |
1461 | 1475 | ||