Commit 71e687dc authored by Corentin Chary's avatar Corentin Chary Committed by Matthew Garrett

platform-x86: sync eeepc-laptop and asus-laptop

Makes asus-laptop and eeepc-laptop _init/_exit functions
looks exactly the same as they do the same thing.
Signed-off-by: default avatarCorentin Chary <corentincj@iksaif.net>
Signed-off-by: default avatarMatthew Garrett <mjg@redhat.com>
parent 384a7cd9
...@@ -639,17 +639,19 @@ static int asus_backlight_notify(struct asus_laptop *asus) ...@@ -639,17 +639,19 @@ static int asus_backlight_notify(struct asus_laptop *asus)
static int asus_backlight_init(struct asus_laptop *asus) static int asus_backlight_init(struct asus_laptop *asus)
{ {
struct backlight_device *bd; struct backlight_device *bd;
struct device *dev = &asus->platform_device->dev;
struct backlight_properties props; struct backlight_properties props;
if (!acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_GET, NULL) && if (acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_GET, NULL) ||
!acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_SET, NULL) && acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_SET, NULL) ||
lcd_switch_handle) { !lcd_switch_handle)
return 0;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.max_brightness = 15; props.max_brightness = 15;
bd = backlight_device_register(ASUS_LAPTOP_FILE, dev, bd = backlight_device_register(ASUS_LAPTOP_FILE,
asus, &asusbl_ops, &props); &asus->platform_device->dev, asus,
&asusbl_ops, &props);
if (IS_ERR(bd)) { if (IS_ERR(bd)) {
pr_err("Could not register asus backlight device\n"); pr_err("Could not register asus backlight device\n");
asus->backlight_device = NULL; asus->backlight_device = NULL;
...@@ -657,11 +659,9 @@ static int asus_backlight_init(struct asus_laptop *asus) ...@@ -657,11 +659,9 @@ static int asus_backlight_init(struct asus_laptop *asus)
} }
asus->backlight_device = bd; asus->backlight_device = bd;
bd->props.power = FB_BLANK_UNBLANK;
bd->props.brightness = asus_read_brightness(bd); bd->props.brightness = asus_read_brightness(bd);
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd); backlight_update_status(bd);
}
return 0; return 0;
} }
...@@ -1130,7 +1130,6 @@ static int asus_input_init(struct asus_laptop *asus) ...@@ -1130,7 +1130,6 @@ static int asus_input_init(struct asus_laptop *asus)
input->phys = ASUS_LAPTOP_FILE "/input0"; input->phys = ASUS_LAPTOP_FILE "/input0";
input->id.bustype = BUS_HOST; input->id.bustype = BUS_HOST;
input->dev.parent = &asus->platform_device->dev; input->dev.parent = &asus->platform_device->dev;
input_set_drvdata(input, asus);
error = sparse_keymap_setup(input, asus_keymap, NULL); error = sparse_keymap_setup(input, asus_keymap, NULL);
if (error) { if (error) {
...@@ -1159,6 +1158,7 @@ static void asus_input_exit(struct asus_laptop *asus) ...@@ -1159,6 +1158,7 @@ static void asus_input_exit(struct asus_laptop *asus)
sparse_keymap_free(asus->inputdev); sparse_keymap_free(asus->inputdev);
input_unregister_device(asus->inputdev); input_unregister_device(asus->inputdev);
} }
asus->inputdev = NULL;
} }
/* /*
...@@ -1278,19 +1278,19 @@ static int asus_sysfs_init(struct asus_laptop *asus) ...@@ -1278,19 +1278,19 @@ static int asus_sysfs_init(struct asus_laptop *asus)
static int asus_platform_init(struct asus_laptop *asus) static int asus_platform_init(struct asus_laptop *asus)
{ {
int err; int result;
asus->platform_device = platform_device_alloc(ASUS_LAPTOP_FILE, -1); asus->platform_device = platform_device_alloc(ASUS_LAPTOP_FILE, -1);
if (!asus->platform_device) if (!asus->platform_device)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(asus->platform_device, asus); platform_set_drvdata(asus->platform_device, asus);
err = platform_device_add(asus->platform_device); result = platform_device_add(asus->platform_device);
if (err) if (result)
goto fail_platform_device; goto fail_platform_device;
err = asus_sysfs_init(asus); result = asus_sysfs_init(asus);
if (err) if (result)
goto fail_sysfs; goto fail_sysfs;
return 0; return 0;
...@@ -1299,7 +1299,7 @@ static int asus_platform_init(struct asus_laptop *asus) ...@@ -1299,7 +1299,7 @@ static int asus_platform_init(struct asus_laptop *asus)
platform_device_del(asus->platform_device); platform_device_del(asus->platform_device);
fail_platform_device: fail_platform_device:
platform_device_put(asus->platform_device); platform_device_put(asus->platform_device);
return err; return result;
} }
static void asus_platform_exit(struct asus_laptop *asus) static void asus_platform_exit(struct asus_laptop *asus)
...@@ -1428,8 +1428,6 @@ static int asus_laptop_get_info(struct asus_laptop *asus) ...@@ -1428,8 +1428,6 @@ static int asus_laptop_get_info(struct asus_laptop *asus)
return AE_OK; return AE_OK;
} }
static bool asus_device_present;
static int __devinit asus_acpi_init(struct asus_laptop *asus) static int __devinit asus_acpi_init(struct asus_laptop *asus)
{ {
int result = 0; int result = 0;
...@@ -1474,6 +1472,8 @@ static int __devinit asus_acpi_init(struct asus_laptop *asus) ...@@ -1474,6 +1472,8 @@ static int __devinit asus_acpi_init(struct asus_laptop *asus)
return result; return result;
} }
static bool asus_device_present;
static int __devinit asus_acpi_add(struct acpi_device *device) static int __devinit asus_acpi_add(struct acpi_device *device)
{ {
struct asus_laptop *asus; struct asus_laptop *asus;
......
...@@ -165,6 +165,7 @@ struct eeepc_laptop { ...@@ -165,6 +165,7 @@ struct eeepc_laptop {
u16 event_count[128]; /* count for each event */ u16 event_count[128]; /* count for each event */
struct platform_device *platform_device; struct platform_device *platform_device;
struct acpi_device *device; /* the device we are in */
struct device *hwmon_device; struct device *hwmon_device;
struct backlight_device *backlight_device; struct backlight_device *backlight_device;
...@@ -1193,9 +1194,9 @@ static int eeepc_input_init(struct eeepc_laptop *eeepc) ...@@ -1193,9 +1194,9 @@ static int eeepc_input_init(struct eeepc_laptop *eeepc)
eeepc->inputdev = input; eeepc->inputdev = input;
return 0; return 0;
err_free_keymap: err_free_keymap:
sparse_keymap_free(input); sparse_keymap_free(input);
err_free_dev: err_free_dev:
input_free_device(input); input_free_device(input);
return error; return error;
} }
...@@ -1206,6 +1207,7 @@ static void eeepc_input_exit(struct eeepc_laptop *eeepc) ...@@ -1206,6 +1207,7 @@ static void eeepc_input_exit(struct eeepc_laptop *eeepc)
sparse_keymap_free(eeepc->inputdev); sparse_keymap_free(eeepc->inputdev);
input_unregister_device(eeepc->inputdev); input_unregister_device(eeepc->inputdev);
} }
eeepc->inputdev = NULL;
} }
/* /*
...@@ -1326,16 +1328,15 @@ static void cmsg_quirks(struct eeepc_laptop *eeepc) ...@@ -1326,16 +1328,15 @@ static void cmsg_quirks(struct eeepc_laptop *eeepc)
cmsg_quirk(eeepc, CM_ASL_TPD, "TPD"); cmsg_quirk(eeepc, CM_ASL_TPD, "TPD");
} }
static int eeepc_acpi_init(struct eeepc_laptop *eeepc, static int __devinit eeepc_acpi_init(struct eeepc_laptop *eeepc)
struct acpi_device *device)
{ {
unsigned int init_flags; unsigned int init_flags;
int result; int result;
result = acpi_bus_get_status(device); result = acpi_bus_get_status(eeepc->device);
if (result) if (result)
return result; return result;
if (!device->status.present) { if (!eeepc->device->status.present) {
pr_err("Hotkey device not present, aborting\n"); pr_err("Hotkey device not present, aborting\n");
return -ENODEV; return -ENODEV;
} }
...@@ -1384,12 +1385,13 @@ static int __devinit eeepc_acpi_add(struct acpi_device *device) ...@@ -1384,12 +1385,13 @@ static int __devinit eeepc_acpi_add(struct acpi_device *device)
strcpy(acpi_device_name(device), EEEPC_ACPI_DEVICE_NAME); strcpy(acpi_device_name(device), EEEPC_ACPI_DEVICE_NAME);
strcpy(acpi_device_class(device), EEEPC_ACPI_CLASS); strcpy(acpi_device_class(device), EEEPC_ACPI_CLASS);
device->driver_data = eeepc; device->driver_data = eeepc;
eeepc->device = device;
eeepc->hotplug_disabled = hotplug_disabled; eeepc->hotplug_disabled = hotplug_disabled;
eeepc_dmi_check(eeepc); eeepc_dmi_check(eeepc);
result = eeepc_acpi_init(eeepc, device); result = eeepc_acpi_init(eeepc);
if (result) if (result)
goto fail_platform; goto fail_platform;
eeepc_enable_camera(eeepc); eeepc_enable_camera(eeepc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment