From 599a52d12629394236d785615808845823875868 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 10 Feb 2007 23:07:48 +0000 Subject: backlight: Separate backlight properties from backlight ops pointers Per device data such as brightness belongs to the indivdual device and should therefore be separate from the the backlight operation function pointers. This patch splits the two types of data and allows simplifcation of some code. Signed-off-by: Richard Purdie --- drivers/acpi/video.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'drivers/acpi/video.c') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 75e422bd926..0771b434feb 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -169,7 +169,6 @@ struct acpi_video_device { struct acpi_device *dev; struct acpi_video_device_brightness *brightness; struct backlight_device *backlight; - struct backlight_properties *data; }; /* bus */ @@ -286,13 +285,18 @@ static int acpi_video_get_brightness(struct backlight_device *bd) static int acpi_video_set_brightness(struct backlight_device *bd) { - int request_level = bd->props->brightness; + int request_level = bd->props.brightness; struct acpi_video_device *vd = (struct acpi_video_device *)class_get_devdata(&bd->class_dev); acpi_video_device_lcd_set_level(vd, request_level); return 0; } +static struct backlight_ops acpi_backlight_ops = { + .get_brightness = acpi_video_get_brightness, + .update_status = acpi_video_set_brightness, +}; + /* -------------------------------------------------------------------------- Video Management -------------------------------------------------------------------------- */ @@ -608,30 +612,18 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) unsigned long tmp; static int count = 0; char *name; - struct backlight_properties *acpi_video_data; - name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); if (!name) return; - acpi_video_data = kzalloc( - sizeof(struct backlight_properties), - GFP_KERNEL); - if (!acpi_video_data){ - kfree(name); - return; - } - acpi_video_data->get_brightness = - acpi_video_get_brightness; - acpi_video_data->update_status = - acpi_video_set_brightness; sprintf(name, "acpi_video%d", count++); - device->data = acpi_video_data; - acpi_video_data->max_brightness = max_level; acpi_video_device_lcd_get_level_current(device, &tmp); - acpi_video_data->brightness = (int)tmp; device->backlight = backlight_device_register(name, - NULL, device, acpi_video_data); + NULL, device, &acpi_backlight_ops); + device->backlight->props.max_brightness = max_level; + device->backlight->props.brightness = (int)tmp; + backlight_update_status(device->backlight); + kfree(name); } return; @@ -1676,10 +1668,7 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device) status = acpi_remove_notify_handler(device->dev->handle, ACPI_DEVICE_NOTIFY, acpi_video_device_notify); - if (device->backlight){ - backlight_device_unregister(device->backlight); - kfree(device->data); - } + backlight_device_unregister(device->backlight); return 0; } -- cgit v1.2.3