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: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
This commit is contained in:
Corentin Chary 2010-08-24 09:30:44 +02:00 committed by Matthew Garrett
parent 384a7cd9ac
commit 71e687dc49
2 changed files with 36 additions and 34 deletions

View file

@ -639,29 +639,29 @@ 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)
memset(&props, 0, sizeof(struct backlight_properties)); return 0;
props.max_brightness = 15;
bd = backlight_device_register(ASUS_LAPTOP_FILE, dev, memset(&props, 0, sizeof(struct backlight_properties));
asus, &asusbl_ops, &props); props.max_brightness = 15;
if (IS_ERR(bd)) {
pr_err("Could not register asus backlight device\n");
asus->backlight_device = NULL;
return PTR_ERR(bd);
}
asus->backlight_device = bd; bd = backlight_device_register(ASUS_LAPTOP_FILE,
&asus->platform_device->dev, asus,
bd->props.power = FB_BLANK_UNBLANK; &asusbl_ops, &props);
bd->props.brightness = asus_read_brightness(bd); if (IS_ERR(bd)) {
backlight_update_status(bd); pr_err("Could not register asus backlight device\n");
asus->backlight_device = NULL;
return PTR_ERR(bd);
} }
asus->backlight_device = bd;
bd->props.brightness = asus_read_brightness(bd);
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd);
return 0; return 0;
} }
@ -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)
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)
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 @@ fail_sysfs:
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)
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)
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;

View file

@ -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)
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)
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)
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)
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);