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 <rpurdie@rpsys.net>
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 75e422bd..0771b43 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -169,7 +169,6 @@
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_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 @@
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 @@
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;
}