diff options
author | Corentin Chary <corentincj@iksaif.net> | 2009-11-30 16:13:54 -0500 |
---|---|---|
committer | Corentin Chary <corentincj@iksaif.net> | 2010-02-28 13:35:10 -0500 |
commit | 7c247645f305da2bb309fa439fd6cc0aa26f8722 (patch) | |
tree | b55310c23b9c27b73649529fea65387fc7c26cc4 /drivers/platform | |
parent | 50a90c4d953fe4bb5a87ee5207c4243d25278189 (diff) |
asus-laptop: move backlight and dsdt info inside asus_laptop struct
Prepare the use of "driver data" for callbacks.
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/asus-laptop.c | 69 |
1 files changed, 30 insertions, 39 deletions
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 2505f15cbe6b..4ff30ca4df12 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c | |||
@@ -202,30 +202,24 @@ ASUS_HANDLE(kled_get, ASUS_LAPTOP_PREFIX "GLKB"); | |||
202 | struct asus_laptop { | 202 | struct asus_laptop { |
203 | char *name; /* laptop name */ | 203 | char *name; /* laptop name */ |
204 | 204 | ||
205 | struct acpi_table_header *dsdt_info; | ||
205 | struct platform_device *platform_device; | 206 | struct platform_device *platform_device; |
206 | struct acpi_device *device; /* the device we are in */ | 207 | struct acpi_device *device; /* the device we are in */ |
208 | struct backlight_device *backlight_device; | ||
209 | struct input_dev *inputdev; | ||
210 | |||
207 | acpi_handle handle; /* the handle of the hotk device */ | 211 | acpi_handle handle; /* the handle of the hotk device */ |
208 | char status; /* status of the hotk, for LEDs, ... */ | 212 | char status; /* status of the hotk, for LEDs, ... */ |
209 | u32 ledd_status; /* status of the LED display */ | 213 | u32 ledd_status; /* status of the LED display */ |
210 | u8 light_level; /* light sensor level */ | 214 | u8 light_level; /* light sensor level */ |
211 | u8 light_switch; /* light sensor switch value */ | 215 | u8 light_switch; /* light sensor switch value */ |
212 | u16 event_count[128]; /* count for each event TODO make this better */ | 216 | u16 event_count[128]; /* count for each event TODO make this better */ |
213 | struct input_dev *inputdev; | ||
214 | u16 *keycode_map; | 217 | u16 *keycode_map; |
215 | }; | 218 | }; |
216 | 219 | ||
217 | /* | ||
218 | * This header is made available to allow proper configuration given model, | ||
219 | * revision number , ... this info cannot go in struct asus_laptop because it is | ||
220 | * available before the hotk | ||
221 | */ | ||
222 | static struct acpi_table_header *asus_info; | ||
223 | |||
224 | /* The actual device the driver binds to */ | ||
225 | static struct asus_laptop *asus; | 220 | static struct asus_laptop *asus; |
226 | 221 | ||
227 | /* The backlight device /sys/class/backlight */ | 222 | static struct workqueue_struct *led_workqueue; |
228 | static struct backlight_device *asus_backlight_device; | ||
229 | 223 | ||
230 | /* | 224 | /* |
231 | * The backlight class declaration | 225 | * The backlight class declaration |
@@ -237,14 +231,6 @@ static struct backlight_ops asusbl_ops = { | |||
237 | .update_status = update_bl_status, | 231 | .update_status = update_bl_status, |
238 | }; | 232 | }; |
239 | 233 | ||
240 | /* | ||
241 | * These functions actually update the LED's, and are called from a | ||
242 | * workqueue. By doing this as separate work rather than when the LED | ||
243 | * subsystem asks, we avoid messing with the Asus ACPI stuff during a | ||
244 | * potentially bad time, such as a timer interrupt. | ||
245 | */ | ||
246 | static struct workqueue_struct *led_workqueue; | ||
247 | |||
248 | #define ASUS_LED(object, ledname, max) \ | 234 | #define ASUS_LED(object, ledname, max) \ |
249 | static void object##_led_set(struct led_classdev *led_cdev, \ | 235 | static void object##_led_set(struct led_classdev *led_cdev, \ |
250 | enum led_brightness value); \ | 236 | enum led_brightness value); \ |
@@ -522,7 +508,7 @@ static int set_lcd_state(int value) | |||
522 | 508 | ||
523 | static void lcd_blank(int blank) | 509 | static void lcd_blank(int blank) |
524 | { | 510 | { |
525 | struct backlight_device *bd = asus_backlight_device; | 511 | struct backlight_device *bd = asus->backlight_device; |
526 | 512 | ||
527 | if (bd) { | 513 | if (bd) { |
528 | bd->props.power = blank; | 514 | bd->props.power = blank; |
@@ -619,22 +605,22 @@ static ssize_t show_infos(struct device *dev, | |||
619 | if (!ACPI_FAILURE(rv)) | 605 | if (!ACPI_FAILURE(rv)) |
620 | len += sprintf(page + len, "ASYM value : %#x\n", | 606 | len += sprintf(page + len, "ASYM value : %#x\n", |
621 | (uint) temp); | 607 | (uint) temp); |
622 | if (asus_info) { | 608 | if (asus->dsdt_info) { |
623 | snprintf(buf, 16, "%d", asus_info->length); | 609 | snprintf(buf, 16, "%d", asus->dsdt_info->length); |
624 | len += sprintf(page + len, "DSDT length : %s\n", buf); | 610 | len += sprintf(page + len, "DSDT length : %s\n", buf); |
625 | snprintf(buf, 16, "%d", asus_info->checksum); | 611 | snprintf(buf, 16, "%d", asus->dsdt_info->checksum); |
626 | len += sprintf(page + len, "DSDT checksum : %s\n", buf); | 612 | len += sprintf(page + len, "DSDT checksum : %s\n", buf); |
627 | snprintf(buf, 16, "%d", asus_info->revision); | 613 | snprintf(buf, 16, "%d", asus->dsdt_info->revision); |
628 | len += sprintf(page + len, "DSDT revision : %s\n", buf); | 614 | len += sprintf(page + len, "DSDT revision : %s\n", buf); |
629 | snprintf(buf, 7, "%s", asus_info->oem_id); | 615 | snprintf(buf, 7, "%s", asus->dsdt_info->oem_id); |
630 | len += sprintf(page + len, "OEM id : %s\n", buf); | 616 | len += sprintf(page + len, "OEM id : %s\n", buf); |
631 | snprintf(buf, 9, "%s", asus_info->oem_table_id); | 617 | snprintf(buf, 9, "%s", asus->dsdt_info->oem_table_id); |
632 | len += sprintf(page + len, "OEM table id : %s\n", buf); | 618 | len += sprintf(page + len, "OEM table id : %s\n", buf); |
633 | snprintf(buf, 16, "%x", asus_info->oem_revision); | 619 | snprintf(buf, 16, "%x", asus->dsdt_info->oem_revision); |
634 | len += sprintf(page + len, "OEM revision : 0x%s\n", buf); | 620 | len += sprintf(page + len, "OEM revision : 0x%s\n", buf); |
635 | snprintf(buf, 5, "%s", asus_info->asl_compiler_id); | 621 | snprintf(buf, 5, "%s", asus->dsdt_info->asl_compiler_id); |
636 | len += sprintf(page + len, "ASL comp vendor id : %s\n", buf); | 622 | len += sprintf(page + len, "ASL comp vendor id : %s\n", buf); |
637 | snprintf(buf, 16, "%x", asus_info->asl_compiler_revision); | 623 | snprintf(buf, 16, "%x", asus->dsdt_info->asl_compiler_revision); |
638 | len += sprintf(page + len, "ASL comp revision : 0x%s\n", buf); | 624 | len += sprintf(page + len, "ASL comp revision : 0x%s\n", buf); |
639 | } | 625 | } |
640 | 626 | ||
@@ -1084,7 +1070,7 @@ static int asus_handle_init(char *name, acpi_handle * handle, | |||
1084 | * method, we can make all the detection we want, and modify the asus_laptop | 1070 | * method, we can make all the detection we want, and modify the asus_laptop |
1085 | * struct | 1071 | * struct |
1086 | */ | 1072 | */ |
1087 | static int asus_laptop_get_info(void) | 1073 | static int asus_laptop_get_info(struct asus_laptop *asus) |
1088 | { | 1074 | { |
1089 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 1075 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
1090 | union acpi_object *model = NULL; | 1076 | union acpi_object *model = NULL; |
@@ -1097,10 +1083,9 @@ static int asus_laptop_get_info(void) | |||
1097 | * models, but late enough to allow acpi_bus_register_driver() to fail | 1083 | * models, but late enough to allow acpi_bus_register_driver() to fail |
1098 | * before doing anything ACPI-specific. Should we encounter a machine, | 1084 | * before doing anything ACPI-specific. Should we encounter a machine, |
1099 | * which needs special handling (i.e. its hotkey device has a different | 1085 | * which needs special handling (i.e. its hotkey device has a different |
1100 | * HID), this bit will be moved. A global variable asus_info contains | 1086 | * HID), this bit will be moved. |
1101 | * the DSDT header. | ||
1102 | */ | 1087 | */ |
1103 | status = acpi_get_table(ACPI_SIG_DSDT, 1, &asus_info); | 1088 | status = acpi_get_table(ACPI_SIG_DSDT, 1, &asus->dsdt_info); |
1104 | if (ACPI_FAILURE(status)) | 1089 | if (ACPI_FAILURE(status)) |
1105 | pr_warning("Couldn't get the DSDT table header\n"); | 1090 | pr_warning("Couldn't get the DSDT table header\n"); |
1106 | 1091 | ||
@@ -1237,8 +1222,8 @@ static int asus_input_init(struct device *dev) | |||
1237 | 1222 | ||
1238 | static void asus_backlight_exit(void) | 1223 | static void asus_backlight_exit(void) |
1239 | { | 1224 | { |
1240 | if (asus_backlight_device) | 1225 | if (asus->backlight_device) |
1241 | backlight_device_unregister(asus_backlight_device); | 1226 | backlight_device_unregister(asus->backlight_device); |
1242 | } | 1227 | } |
1243 | 1228 | ||
1244 | #define ASUS_LED_UNREGISTER(object) \ | 1229 | #define ASUS_LED_UNREGISTER(object) \ |
@@ -1271,11 +1256,11 @@ static int asus_backlight_init(struct device *dev) | |||
1271 | NULL, &asusbl_ops); | 1256 | NULL, &asusbl_ops); |
1272 | if (IS_ERR(bd)) { | 1257 | if (IS_ERR(bd)) { |
1273 | pr_err("Could not register asus backlight device\n"); | 1258 | pr_err("Could not register asus backlight device\n"); |
1274 | asus_backlight_device = NULL; | 1259 | asus->backlight_device = NULL; |
1275 | return PTR_ERR(bd); | 1260 | return PTR_ERR(bd); |
1276 | } | 1261 | } |
1277 | 1262 | ||
1278 | asus_backlight_device = bd; | 1263 | asus->backlight_device = bd; |
1279 | 1264 | ||
1280 | bd->props.max_brightness = 15; | 1265 | bd->props.max_brightness = 15; |
1281 | bd->props.brightness = read_brightness(NULL); | 1266 | bd->props.brightness = read_brightness(NULL); |
@@ -1326,6 +1311,12 @@ static int asus_led_init(struct device *dev) | |||
1326 | if (rv) | 1311 | if (rv) |
1327 | goto out5; | 1312 | goto out5; |
1328 | 1313 | ||
1314 | /* | ||
1315 | * Functions that actually update the LED's are called from a | ||
1316 | * workqueue. By doing this as separate work rather than when the LED | ||
1317 | * subsystem asks, we avoid messing with the Asus ACPI stuff during a | ||
1318 | * potentially bad time, such as a timer interrupt. | ||
1319 | */ | ||
1329 | led_workqueue = create_singlethread_workqueue("led_workqueue"); | 1320 | led_workqueue = create_singlethread_workqueue("led_workqueue"); |
1330 | if (!led_workqueue) | 1321 | if (!led_workqueue) |
1331 | goto out6; | 1322 | goto out6; |
@@ -1363,7 +1354,7 @@ static int __devinit asus_acpi_init(struct acpi_device *device) | |||
1363 | return -ENODEV; | 1354 | return -ENODEV; |
1364 | } | 1355 | } |
1365 | 1356 | ||
1366 | result = asus_laptop_get_info(); | 1357 | result = asus_laptop_get_info(asus); |
1367 | if (result) | 1358 | if (result) |
1368 | return result; | 1359 | return result; |
1369 | 1360 | ||