aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorAlan Jenkins <alan-jenkins@tuffmail.co.uk>2009-08-28 08:56:36 -0400
committerLen Brown <len.brown@intel.com>2009-08-28 15:21:11 -0400
commitf2a9d5e8a649c606f520b7a7b9f4f46fba79c327 (patch)
tree5e7e64548abc259ce49f0a996478d8a869308aa8 /drivers/platform
parent1e7798547fe6920ae27fb92c9202353e9e4c55db (diff)
eeepc-laptop: make input device a child of the platform device
Sysfs showed the ehotk input device as a "virtual" device - lies! The input device is provided by a physical device, the eeepc platform. This requires that we move the creation of the input device to come after platform device is created. Input initialization is moved from ehotk_check() [sic] to a new function called eeepc_input_init(). This brings the input device into line with the other eeepc-laptop devices. Also, refuse to load if we fail to register the input device. Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk> Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/eeepc-laptop.c70
1 files changed, 41 insertions, 29 deletions
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index cf47d1cd1a34..298dac9c6ada 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -579,7 +579,6 @@ static void cmsg_quirks(void)
579 579
580static int eeepc_hotk_check(void) 580static int eeepc_hotk_check(void)
581{ 581{
582 const struct key_entry *key;
583 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 582 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
584 int result; 583 int result;
585 584
@@ -604,31 +603,6 @@ static int eeepc_hotk_check(void)
604 pr_info("Get control methods supported: 0x%x\n", 603 pr_info("Get control methods supported: 0x%x\n",
605 ehotk->cm_supported); 604 ehotk->cm_supported);
606 } 605 }
607 ehotk->inputdev = input_allocate_device();
608 if (!ehotk->inputdev) {
609 pr_info("Unable to allocate input device\n");
610 return 0;
611 }
612 ehotk->inputdev->name = "Asus EeePC extra buttons";
613 ehotk->inputdev->phys = EEEPC_HOTK_FILE "/input0";
614 ehotk->inputdev->id.bustype = BUS_HOST;
615 ehotk->inputdev->getkeycode = eeepc_getkeycode;
616 ehotk->inputdev->setkeycode = eeepc_setkeycode;
617
618 for (key = eeepc_keymap; key->type != KE_END; key++) {
619 switch (key->type) {
620 case KE_KEY:
621 set_bit(EV_KEY, ehotk->inputdev->evbit);
622 set_bit(key->keycode, ehotk->inputdev->keybit);
623 break;
624 }
625 }
626 result = input_register_device(ehotk->inputdev);
627 if (result) {
628 pr_info("Unable to register input device\n");
629 input_free_device(ehotk->inputdev);
630 return 0;
631 }
632 } else { 606 } else {
633 pr_err("Hotkey device not present, aborting\n"); 607 pr_err("Hotkey device not present, aborting\n");
634 return -EINVAL; 608 return -EINVAL;
@@ -1142,6 +1116,40 @@ static int eeepc_hwmon_init(struct device *dev)
1142 return result; 1116 return result;
1143} 1117}
1144 1118
1119static int eeepc_input_init(struct device *dev)
1120{
1121 const struct key_entry *key;
1122 int result;
1123
1124 ehotk->inputdev = input_allocate_device();
1125 if (!ehotk->inputdev) {
1126 pr_info("Unable to allocate input device\n");
1127 return -ENOMEM;
1128 }
1129 ehotk->inputdev->name = "Asus EeePC extra buttons";
1130 ehotk->inputdev->dev.parent = dev;
1131 ehotk->inputdev->phys = EEEPC_HOTK_FILE "/input0";
1132 ehotk->inputdev->id.bustype = BUS_HOST;
1133 ehotk->inputdev->getkeycode = eeepc_getkeycode;
1134 ehotk->inputdev->setkeycode = eeepc_setkeycode;
1135
1136 for (key = eeepc_keymap; key->type != KE_END; key++) {
1137 switch (key->type) {
1138 case KE_KEY:
1139 set_bit(EV_KEY, ehotk->inputdev->evbit);
1140 set_bit(key->keycode, ehotk->inputdev->keybit);
1141 break;
1142 }
1143 }
1144 result = input_register_device(ehotk->inputdev);
1145 if (result) {
1146 pr_info("Unable to register input device\n");
1147 input_free_device(ehotk->inputdev);
1148 return result;
1149 }
1150 return 0;
1151}
1152
1145static int eeepc_hotk_add(struct acpi_device *device) 1153static int eeepc_hotk_add(struct acpi_device *device)
1146{ 1154{
1147 struct device *dev; 1155 struct device *dev;
@@ -1162,7 +1170,7 @@ static int eeepc_hotk_add(struct acpi_device *device)
1162 1170
1163 result = eeepc_hotk_check(); 1171 result = eeepc_hotk_check();
1164 if (result) 1172 if (result)
1165 goto fail_check; 1173 goto fail_platform_driver;
1166 eeepc_enable_camera(); 1174 eeepc_enable_camera();
1167 1175
1168 /* Register platform stuff */ 1176 /* Register platform stuff */
@@ -1192,6 +1200,10 @@ static int eeepc_hotk_add(struct acpi_device *device)
1192 pr_info("Backlight controlled by ACPI video " 1200 pr_info("Backlight controlled by ACPI video "
1193 "driver\n"); 1201 "driver\n");
1194 1202
1203 result = eeepc_input_init(dev);
1204 if (result)
1205 goto fail_input;
1206
1195 result = eeepc_hwmon_init(dev); 1207 result = eeepc_hwmon_init(dev);
1196 if (result) 1208 if (result)
1197 goto fail_hwmon; 1209 goto fail_hwmon;
@@ -1205,6 +1217,8 @@ static int eeepc_hotk_add(struct acpi_device *device)
1205fail_rfkill: 1217fail_rfkill:
1206 eeepc_hwmon_exit(); 1218 eeepc_hwmon_exit();
1207fail_hwmon: 1219fail_hwmon:
1220 eeepc_input_exit();
1221fail_input:
1208 eeepc_backlight_exit(); 1222 eeepc_backlight_exit();
1209fail_backlight: 1223fail_backlight:
1210 sysfs_remove_group(&platform_device->dev.kobj, 1224 sysfs_remove_group(&platform_device->dev.kobj,
@@ -1216,8 +1230,6 @@ fail_platform_device2:
1216fail_platform_device1: 1230fail_platform_device1:
1217 platform_driver_unregister(&platform_driver); 1231 platform_driver_unregister(&platform_driver);
1218fail_platform_driver: 1232fail_platform_driver:
1219 eeepc_input_exit();
1220fail_check:
1221 kfree(ehotk); 1233 kfree(ehotk);
1222 1234
1223 return result; 1235 return result;