Commit 599a52d1 authored by Richard Purdie's avatar Richard Purdie

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: default avatarRichard Purdie <rpurdie@rpsys.net>
parent 321709c5
...@@ -107,7 +107,7 @@ int die(const char *str, struct pt_regs *regs, long err) ...@@ -107,7 +107,7 @@ int die(const char *str, struct pt_regs *regs, long err)
if (machine_is(powermac) && pmac_backlight) { if (machine_is(powermac) && pmac_backlight) {
struct backlight_properties *props; struct backlight_properties *props;
props = pmac_backlight->props; props = &pmac_backlight->props;
props->brightness = props->max_brightness; props->brightness = props->max_brightness;
props->power = FB_BLANK_UNBLANK; props->power = FB_BLANK_UNBLANK;
backlight_update_status(pmac_backlight); backlight_update_status(pmac_backlight);
......
...@@ -44,7 +44,7 @@ DEFINE_MUTEX(pmac_backlight_mutex); ...@@ -44,7 +44,7 @@ DEFINE_MUTEX(pmac_backlight_mutex);
/* Main backlight storage /* Main backlight storage
* *
* Backlight drivers in this variable are required to have the "props" * Backlight drivers in this variable are required to have the "ops"
* attribute set and to have an update_status function. * attribute set and to have an update_status function.
* *
* We can only store one backlight here, but since Apple laptops have only one * We can only store one backlight here, but since Apple laptops have only one
...@@ -103,7 +103,7 @@ static void pmac_backlight_key_worker(struct work_struct *work) ...@@ -103,7 +103,7 @@ static void pmac_backlight_key_worker(struct work_struct *work)
struct backlight_properties *props; struct backlight_properties *props;
int brightness; int brightness;
props = pmac_backlight->props; props = &pmac_backlight->props;
brightness = props->brightness + brightness = props->brightness +
((pmac_backlight_key_queued?-1:1) * ((pmac_backlight_key_queued?-1:1) *
...@@ -141,7 +141,7 @@ static int __pmac_backlight_set_legacy_brightness(int brightness) ...@@ -141,7 +141,7 @@ static int __pmac_backlight_set_legacy_brightness(int brightness)
if (pmac_backlight) { if (pmac_backlight) {
struct backlight_properties *props; struct backlight_properties *props;
props = pmac_backlight->props; props = &pmac_backlight->props;
props->brightness = brightness * props->brightness = brightness *
(props->max_brightness + 1) / (props->max_brightness + 1) /
(OLD_BACKLIGHT_MAX + 1); (OLD_BACKLIGHT_MAX + 1);
...@@ -190,7 +190,7 @@ int pmac_backlight_get_legacy_brightness() ...@@ -190,7 +190,7 @@ int pmac_backlight_get_legacy_brightness()
if (pmac_backlight) { if (pmac_backlight) {
struct backlight_properties *props; struct backlight_properties *props;
props = pmac_backlight->props; props = &pmac_backlight->props;
result = props->brightness * result = props->brightness *
(OLD_BACKLIGHT_MAX + 1) / (OLD_BACKLIGHT_MAX + 1) /
......
...@@ -848,7 +848,7 @@ static int set_brightness(int value) ...@@ -848,7 +848,7 @@ static int set_brightness(int value)
static int set_brightness_status(struct backlight_device *bd) static int set_brightness_status(struct backlight_device *bd)
{ {
return set_brightness(bd->props->brightness); return set_brightness(bd->props.brightness);
} }
static int static int
...@@ -1352,10 +1352,9 @@ static int asus_hotk_remove(struct acpi_device *device, int type) ...@@ -1352,10 +1352,9 @@ static int asus_hotk_remove(struct acpi_device *device, int type)
return 0; return 0;
} }
static struct backlight_properties asus_backlight_data = { static struct backlight_ops asus_backlight_data = {
.get_brightness = read_brightness, .get_brightness = read_brightness,
.update_status = set_brightness_status, .update_status = set_brightness_status,
.max_brightness = 15,
}; };
static void __exit asus_acpi_exit(void) static void __exit asus_acpi_exit(void)
...@@ -1409,6 +1408,7 @@ static int __init asus_acpi_init(void) ...@@ -1409,6 +1408,7 @@ static int __init asus_acpi_init(void)
asus_backlight_device = NULL; asus_backlight_device = NULL;
asus_acpi_exit(); asus_acpi_exit();
} }
asus_backlight_device->props.max_brightness = 15;
return 0; return 0;
} }
......
...@@ -1701,13 +1701,12 @@ static int brightness_write(char *buf) ...@@ -1701,13 +1701,12 @@ static int brightness_write(char *buf)
static int brightness_update_status(struct backlight_device *bd) static int brightness_update_status(struct backlight_device *bd)
{ {
return brightness_set(bd->props->brightness); return brightness_set(bd->props.brightness);
} }
static struct backlight_properties ibm_backlight_data = { static struct backlight_ops ibm_backlight_data = {
.get_brightness = brightness_get, .get_brightness = brightness_get,
.update_status = brightness_update_status, .update_status = brightness_update_status,
.max_brightness = 7,
}; };
static int brightness_init(void) static int brightness_init(void)
...@@ -1719,6 +1718,8 @@ static int brightness_init(void) ...@@ -1719,6 +1718,8 @@ static int brightness_init(void)
return PTR_ERR(ibm_backlight_device); return PTR_ERR(ibm_backlight_device);
} }
ibm_backlight_device->props.max_brightness = 7;
return 0; return 0;
} }
......
...@@ -315,7 +315,7 @@ static int set_lcd(int value) ...@@ -315,7 +315,7 @@ static int set_lcd(int value)
static int set_lcd_status(struct backlight_device *bd) static int set_lcd_status(struct backlight_device *bd)
{ {
return set_lcd(bd->props->brightness); return set_lcd(bd->props.brightness);
} }
static unsigned long write_lcd(const char *buffer, unsigned long count) static unsigned long write_lcd(const char *buffer, unsigned long count)
...@@ -533,10 +533,9 @@ static acpi_status __exit remove_device(void) ...@@ -533,10 +533,9 @@ static acpi_status __exit remove_device(void)
return AE_OK; return AE_OK;
} }
static struct backlight_properties toshiba_backlight_data = { static struct backlight_ops toshiba_backlight_data = {
.get_brightness = get_lcd, .get_brightness = get_lcd,
.update_status = set_lcd_status, .update_status = set_lcd_status,
.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1,
}; };
static void __exit toshiba_acpi_exit(void) static void __exit toshiba_acpi_exit(void)
...@@ -596,6 +595,7 @@ static int __init toshiba_acpi_init(void) ...@@ -596,6 +595,7 @@ static int __init toshiba_acpi_init(void)
toshiba_backlight_device = NULL; toshiba_backlight_device = NULL;
toshiba_acpi_exit(); toshiba_acpi_exit();
} }
toshiba_backlight_device->props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
return (ACPI_SUCCESS(status)) ? 0 : -ENODEV; return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
} }
......
...@@ -169,7 +169,6 @@ struct acpi_video_device { ...@@ -169,7 +169,6 @@ struct acpi_video_device {
struct acpi_device *dev; struct acpi_device *dev;
struct acpi_video_device_brightness *brightness; struct acpi_video_device_brightness *brightness;
struct backlight_device *backlight; struct backlight_device *backlight;
struct backlight_properties *data;
}; };
/* bus */ /* bus */
...@@ -286,13 +285,18 @@ static int acpi_video_get_brightness(struct backlight_device *bd) ...@@ -286,13 +285,18 @@ static int acpi_video_get_brightness(struct backlight_device *bd)
static int acpi_video_set_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 *vd =
(struct acpi_video_device *)class_get_devdata(&bd->class_dev); (struct acpi_video_device *)class_get_devdata(&bd->class_dev);
acpi_video_device_lcd_set_level(vd, request_level); acpi_video_device_lcd_set_level(vd, request_level);
return 0; return 0;
} }
static struct backlight_ops acpi_backlight_ops = {
.get_brightness = acpi_video_get_brightness,
.update_status = acpi_video_set_brightness,
};
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Video Management Video Management
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
...@@ -608,30 +612,18 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) ...@@ -608,30 +612,18 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
unsigned long tmp; unsigned long tmp;
static int count = 0; static int count = 0;
char *name; char *name;
struct backlight_properties *acpi_video_data;
name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); name = kzalloc(MAX_NAME_LEN, GFP_KERNEL);
if (!name) if (!name)
return; 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++); 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_device_lcd_get_level_current(device, &tmp);
acpi_video_data->brightness = (int)tmp;
device->backlight = backlight_device_register(name, 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); kfree(name);
} }
return; return;
...@@ -1676,10 +1668,7 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device) ...@@ -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, status = acpi_remove_notify_handler(device->dev->handle,
ACPI_DEVICE_NOTIFY, ACPI_DEVICE_NOTIFY,
acpi_video_device_notify); acpi_video_device_notify);
if (device->backlight){ backlight_device_unregister(device->backlight);
backlight_device_unregister(device->backlight);
kfree(device->data);
}
return 0; return 0;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#define MAX_PMU_LEVEL 0xFF #define MAX_PMU_LEVEL 0xFF
static struct backlight_properties pmu_backlight_data; static struct backlight_ops pmu_backlight_data;
static DEFINE_SPINLOCK(pmu_backlight_lock); static DEFINE_SPINLOCK(pmu_backlight_lock);
static int sleeping; static int sleeping;
static u8 bl_curve[FB_BACKLIGHT_LEVELS]; static u8 bl_curve[FB_BACKLIGHT_LEVELS];
...@@ -72,7 +72,7 @@ static int pmu_backlight_update_status(struct backlight_device *bd) ...@@ -72,7 +72,7 @@ static int pmu_backlight_update_status(struct backlight_device *bd)
{ {
struct adb_request req; struct adb_request req;
unsigned long flags; unsigned long flags;
int level = bd->props->brightness; int level = bd->props.brightness;
spin_lock_irqsave(&pmu_backlight_lock, flags); spin_lock_irqsave(&pmu_backlight_lock, flags);
...@@ -80,8 +80,8 @@ static int pmu_backlight_update_status(struct backlight_device *bd) ...@@ -80,8 +80,8 @@ static int pmu_backlight_update_status(struct backlight_device *bd)
if (sleeping) if (sleeping)
goto out; goto out;
if (bd->props->power != FB_BLANK_UNBLANK || if (bd->props.power != FB_BLANK_UNBLANK ||
bd->props->fb_blank != FB_BLANK_UNBLANK) bd->props.fb_blank != FB_BLANK_UNBLANK)
level = 0; level = 0;
if (level > 0) { if (level > 0) {
...@@ -107,13 +107,13 @@ static int pmu_backlight_update_status(struct backlight_device *bd) ...@@ -107,13 +107,13 @@ static int pmu_backlight_update_status(struct backlight_device *bd)
static int pmu_backlight_get_brightness(struct backlight_device *bd) static int pmu_backlight_get_brightness(struct backlight_device *bd)
{ {
return bd->props->brightness; return bd->props.brightness;
} }
static struct backlight_properties pmu_backlight_data = { static struct backlight_ops pmu_backlight_data = {
.get_brightness = pmu_backlight_get_brightness, .get_brightness = pmu_backlight_get_brightness,
.update_status = pmu_backlight_update_status, .update_status = pmu_backlight_update_status,
.max_brightness = (FB_BACKLIGHT_LEVELS - 1),
}; };
#ifdef CONFIG_PM #ifdef CONFIG_PM
...@@ -151,9 +151,10 @@ void __init pmu_backlight_init() ...@@ -151,9 +151,10 @@ void __init pmu_backlight_init()
printk("pmubl: Backlight registration failed\n"); printk("pmubl: Backlight registration failed\n");
goto error; goto error;
} }
bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
pmu_backlight_init_curve(0x7F, 0x46, 0x0E); pmu_backlight_init_curve(0x7F, 0x46, 0x0E);
level = pmu_backlight_data.max_brightness; level = bd->props.max_brightness;
if (autosave) { if (autosave) {
/* read autosaved value if available */ /* read autosaved value if available */
...@@ -163,11 +164,11 @@ void __init pmu_backlight_init() ...@@ -163,11 +164,11 @@ void __init pmu_backlight_init()
level = pmu_backlight_curve_lookup( level = pmu_backlight_curve_lookup(
(req.reply[0] >> 4) * (req.reply[0] >> 4) *
pmu_backlight_data.max_brightness / 15); bd->props.max_brightness / 15);
} }
bd->props->brightness = level; bd->props.brightness = level;
bd->props->power = FB_BLANK_UNBLANK; bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd); backlight_update_status(bd);
printk("pmubl: Backlight initialized (%s)\n", name); printk("pmubl: Backlight initialized (%s)\n", name);
......
...@@ -195,10 +195,9 @@ static struct backlight_device *asus_backlight_device; ...@@ -195,10 +195,9 @@ static struct backlight_device *asus_backlight_device;
*/ */
static int read_brightness(struct backlight_device *bd); static int read_brightness(struct backlight_device *bd);
static int update_bl_status(struct backlight_device *bd); static int update_bl_status(struct backlight_device *bd);
static struct backlight_properties asusbl_data = { static struct backlight_ops asusbl_ops = {
.get_brightness = read_brightness, .get_brightness = read_brightness,
.update_status = update_bl_status, .update_status = update_bl_status,
.max_brightness = 15,
}; };
/* These functions actually update the LED's, and are called from a /* These functions actually update the LED's, and are called from a
...@@ -348,7 +347,7 @@ static void lcd_blank(int blank) ...@@ -348,7 +347,7 @@ static void lcd_blank(int blank)
struct backlight_device *bd = asus_backlight_device; struct backlight_device *bd = asus_backlight_device;
if (bd) { if (bd) {
bd->props->power = blank; bd->props.power = blank;
backlight_update_status(bd); backlight_update_status(bd);
} }
} }
...@@ -381,13 +380,13 @@ static int set_brightness(struct backlight_device *bd, int value) ...@@ -381,13 +380,13 @@ static int set_brightness(struct backlight_device *bd, int value)
static int update_bl_status(struct backlight_device *bd) static int update_bl_status(struct backlight_device *bd)
{ {
int rv; int rv;
int value = bd->props->brightness; int value = bd->props.brightness;
rv = set_brightness(bd, value); rv = set_brightness(bd, value);
if (rv) if (rv)
return rv; return rv;
value = (bd->props->power == FB_BLANK_UNBLANK) ? 1 : 0; value = (bd->props.power == FB_BLANK_UNBLANK) ? 1 : 0;
return set_lcd_state(value); return set_lcd_state(value);
} }
...@@ -1013,7 +1012,7 @@ static int asus_backlight_init(struct device *dev) ...@@ -1013,7 +1012,7 @@ static int asus_backlight_init(struct device *dev)
if (brightness_set_handle && lcd_switch_handle) { if (brightness_set_handle && lcd_switch_handle) {
bd = backlight_device_register(ASUS_HOTK_FILE, dev, bd = backlight_device_register(ASUS_HOTK_FILE, dev,
NULL, &asusbl_data); NULL, &asusbl_ops);
if (IS_ERR(bd)) { if (IS_ERR(bd)) {
printk(ASUS_ERR printk(ASUS_ERR
"Could not register asus backlight device\n"); "Could not register asus backlight device\n");
...@@ -1023,8 +1022,9 @@ static int asus_backlight_init(struct device *dev) ...@@ -1023,8 +1022,9 @@ static int asus_backlight_init(struct device *dev)
asus_backlight_device = bd; asus_backlight_device = bd;
bd->props->brightness = read_brightness(NULL); bd->props.max_brightness = 15;
bd->props->power = FB_BLANK_UNBLANK; bd->props.brightness = read_brightness(NULL);
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd); backlight_update_status(bd);
} }
return 0; return 0;
......
...@@ -157,13 +157,12 @@ static int bl_get_brightness(struct backlight_device *b) ...@@ -157,13 +157,12 @@ static int bl_get_brightness(struct backlight_device *b)
static int bl_update_status(struct backlight_device *b) static int bl_update_status(struct backlight_device *b)
{ {
return set_lcd_level(b->props->brightness); return set_lcd_level(b->props.brightness);
} }
static struct backlight_properties msibl_props = { static struct backlight_ops msibl_ops = {
.get_brightness = bl_get_brightness, .get_brightness = bl_get_brightness,
.update_status = bl_update_status, .update_status = bl_update_status,
.max_brightness = MSI_LCD_LEVEL_MAX-1,
}; };
static struct backlight_device *msibl_device; static struct backlight_device *msibl_device;
...@@ -317,10 +316,12 @@ static int __init msi_init(void) ...@@ -317,10 +316,12 @@ static int __init msi_init(void)
/* Register backlight stuff */ /* Register backlight stuff */
msibl_device = backlight_device_register("msi-laptop-bl", NULL, NULL, msibl_device = backlight_device_register("msi-laptop-bl", NULL, NULL,
&msibl_props); &msibl_ops);
if (IS_ERR(msibl_device)) if (IS_ERR(msibl_device))
return PTR_ERR(msibl_device); return PTR_ERR(msibl_device);
msibl_device->props.max_brightness = MSI_LCD_LEVEL_MAX-1,
ret = platform_driver_register(&msipf_driver); ret = platform_driver_register(&msipf_driver);
if (ret) if (ret)
goto fail_backlight; goto fail_backlight;
......
...@@ -141,7 +141,7 @@ static int appledisplay_bl_update_status(struct backlight_device *bd) ...@@ -141,7 +141,7 @@ static int appledisplay_bl_update_status(struct backlight_device *bd)
int retval; int retval;
pdata->msgdata[0] = 0x10; pdata->msgdata[0] = 0x10;
pdata->msgdata[1] = bd->props->brightness; pdata->msgdata[1] = bd->props.brightness;
retval = usb_control_msg( retval = usb_control_msg(
pdata->udev, pdata->udev,
...@@ -177,10 +177,9 @@ static int appledisplay_bl_get_brightness(struct backlight_device *bd) ...@@ -177,10 +177,9 @@ static int appledisplay_bl_get_brightness(struct backlight_device *bd)
return pdata->msgdata[1]; return pdata->msgdata[1];
} }
static struct backlight_properties appledisplay_bl_data = { static struct backlight_ops appledisplay_bl_data = {
.get_brightness = appledisplay_bl_get_brightness, .get_brightness = appledisplay_bl_get_brightness,
.update_status = appledisplay_bl_update_status, .update_status = appledisplay_bl_update_status,
.max_brightness = 0xFF
}; };
static void appledisplay_work(struct work_struct *work) static void appledisplay_work(struct work_struct *work)
...@@ -191,7 +190,7 @@ static void appledisplay_work(struct work_struct *work) ...@@ -191,7 +190,7 @@ static void appledisplay_work(struct work_struct *work)
retval = appledisplay_bl_get_brightness(pdata->bd); retval = appledisplay_bl_get_brightness(pdata->bd);
if (retval >= 0) if (retval >= 0)
pdata->bd->props->brightness = retval; pdata->bd->props.brightness = retval;
/* Poll again in about 125ms if there's still a button pressed */ /* Poll again in about 125ms if there's still a button pressed */
if (pdata->button_pressed) if (pdata->button_pressed)
...@@ -285,6 +284,8 @@ static int appledisplay_probe(struct usb_interface *iface, ...@@ -285,6 +284,8 @@ static int appledisplay_probe(struct usb_interface *iface,
goto error; goto error;
} }
pdata->bd->props.max_brightness = 0xff;
/* Try to get brightness */ /* Try to get brightness */
brightness = appledisplay_bl_get_brightness(pdata->bd); brightness = appledisplay_bl_get_brightness(pdata->bd);
...@@ -295,7 +296,7 @@ static int appledisplay_probe(struct usb_interface *iface, ...@@ -295,7 +296,7 @@ static int appledisplay_probe(struct usb_interface *iface,
} }
/* Set brightness in backlight device */ /* Set brightness in backlight device */
pdata->bd->props->brightness = brightness; pdata->bd->props.brightness = brightness;
/* save our data pointer in the interface device */ /* save our data pointer in the interface device */
usb_set_intfdata(iface, pdata); usb_set_intfdata(iface, pdata);
......
...@@ -1695,8 +1695,6 @@ static int __devinit aty128fb_setup(char *options) ...@@ -1695,8 +1695,6 @@ static int __devinit aty128fb_setup(char *options)
#ifdef CONFIG_FB_ATY128_BACKLIGHT #ifdef CONFIG_FB_ATY128_BACKLIGHT
#define MAX_LEVEL 0xFF #define MAX_LEVEL 0xFF
static struct backlight_properties aty128_bl_data;
static int aty128_bl_get_level_brightness(struct aty128fb_par *par, static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
int level) int level)
{ {
...@@ -1730,12 +1728,12 @@ static int aty128_bl_update_status(struct backlight_device *bd) ...@@ -1730,12 +1728,12 @@ static int aty128_bl_update_status(struct backlight_device *bd)
unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL); unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL);
int level; int level;
if (bd->props->power != FB_BLANK_UNBLANK || if (bd->props.power != FB_BLANK_UNBLANK ||
bd->props->fb_blank != FB_BLANK_UNBLANK || bd->props.fb_blank != FB_BLANK_UNBLANK ||
!par->lcd_on) !par->lcd_on)
level = 0; level = 0;
else else
level = bd->props->brightness; level = bd->props.brightness;
reg |= LVDS_BL_MOD_EN | LVDS_BLON; reg |= LVDS_BL_MOD_EN | LVDS_BLON;
if (level > 0) { if (level > 0) {
...@@ -1779,19 +1777,18 @@ static int aty128_bl_update_status(struct backlight_device *bd) ...@@ -1779,19 +1777,18 @@ static int aty128_bl_update_status(struct backlight_device *bd)
static int aty128_bl_get_brightness(struct backlight_device *bd) static int aty128_bl_get_brightness(struct backlight_device *bd)
{ {
return bd->props->brightness; return bd->props.brightness;
} }
static struct backlight_properties aty128_bl_data = { static struct backlight_ops aty128_bl_data = {
.get_brightness = aty128_bl_get_brightness, .get_brightness = aty128_bl_get_brightness,
.update_status = aty128_bl_update_status, .update_status = aty128_bl_update_status,
.max_brightness = (FB_BACKLIGHT_LEVELS - 1),
}; };
static void aty128_bl_set_power(struct fb_info *info, int power) static void aty128_bl_set_power(struct fb_info *info, int power)
{ {
if (info->bl_dev) { if (info->bl_dev) {
info->bl_dev->props->power = power; info->bl_dev->props.power = power;
backlight_update_status(info->bl_dev); backlight_update_status(info->bl_dev);
} }
} }
...@@ -1825,8 +1822,9 @@ static void aty128_bl_init(struct aty128fb_par *par) ...@@ -1825,8 +1822,9 @@ static void aty128_bl_init(struct aty128fb_par *par)
63 * FB_BACKLIGHT_MAX / MAX_LEVEL, 63 * FB_BACKLIGHT_MAX / MAX_LEVEL,
219 * FB_BACKLIGHT_MAX / MAX_LEVEL); 219 * FB_BACKLIGHT_MAX / MAX_LEVEL);
bd->props->brightness = aty128_bl_data.max_brightness; bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd->props->power = FB_BLANK_UNBLANK; bd->props.brightness = bd->props.max_brightness;
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd); backlight_update_status(bd);
printk("aty128: Backlight initialized (%s)\n", name); printk("aty128: Backlight initialized (%s)\n", name);
......
...@@ -2114,8 +2114,6 @@ static int atyfb_pci_resume(struct pci_dev *pdev) ...@@ -2114,8 +2114,6 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
#ifdef CONFIG_FB_ATY_BACKLIGHT #ifdef CONFIG_FB_ATY_BACKLIGHT
#define MAX_LEVEL 0xFF #define MAX_LEVEL 0xFF
static struct backlight_properties aty_bl_data;
static int aty_bl_get_level_brightness(struct atyfb_par *par, int level) static int aty_bl_get_level_brightness(struct atyfb_par *par, int level)
{ {
struct fb_info *info = pci_get_drvdata(par->pdev); struct fb_info *info = pci_get_drvdata(par->pdev);
...@@ -2139,11 +2137,11 @@ static int aty_bl_update_status(struct backlight_device *bd) ...@@ -2139,11 +2137,11 @@ static int aty_bl_update_status(struct backlight_device *bd)
unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par); unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par);
int level; int level;
if (bd->props->power != FB_BLANK_UNBLANK || if (bd->props.power != FB_BLANK_UNBLANK ||
bd->props->fb_blank != FB_BLANK_UNBLANK) bd->props.fb_blank != FB_BLANK_UNBLANK)
level = 0; level = 0;
else else
level = bd->props->brightness; level = bd->props.brightness;
reg |= (BLMOD_EN | BIASMOD_EN); reg |= (BLMOD_EN | BIASMOD_EN);
if (level > 0) { if (level > 0) {
...@@ -2160,13 +2158,12 @@ static int aty_bl_update_status(struct backlight_device *bd) ...@@ -2160,13 +2158,12 @@ static int aty_bl_update_status(struct backlight_device *bd)
static int aty_bl_get_brightness(struct backlight_device *bd) static int aty_bl_get_brightness(struct backlight_device *bd)
{ {
return bd->props->brightness; return bd->props.brightness;
} }
static struct backlight_properties aty_bl_data = { static struct backlight_ops aty_bl_data = {
.get_brightness = aty_bl_get_brightness, .get_brightness = aty_bl_get_brightness,
.update_status = aty_bl_update_status, .update_status = aty_bl_update_status,
.max_brightness = (FB_BACKLIGHT_LEVELS - 1),
}; };
static void aty_bl_init(struct atyfb_par *par) static void aty_bl_init(struct atyfb_par *par)
...@@ -2194,8 +2191,9 @@ static void aty_bl_init(struct atyfb_par *par) ...@@ -2194,8 +2191,9 @@ static void aty_bl_init(struct atyfb_par *par)
0x3F * FB_BACKLIGHT_MAX / MAX_LEVEL, 0x3F * FB_BACKLIGHT_MAX / MAX_LEVEL,
0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL); 0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL);
bd->props->brightness = aty_bl_data.max_brightness; bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd->props->power = FB_BLANK_UNBLANK; bd->props.brightness = bd->props.max_brightness;
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd); backlight_update_status(bd);
printk("aty: Backlight initialized (%s)\n", name); printk("aty: Backlight initialized (%s)\n", name);
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
#define MAX_RADEON_LEVEL 0xFF #define MAX_RADEON_LEVEL 0xFF
static struct backlight_properties radeon_bl_data;
struct radeon_bl_privdata { struct radeon_bl_privdata {
struct radeonfb_info *rinfo; struct radeonfb_info *rinfo;
uint8_t negative; uint8_t negative;
...@@ -61,11 +59,11 @@ static int radeon_bl_update_status(struct backlight_device *bd) ...@@ -61,11 +59,11 @@ static int radeon_bl_update_status(struct backlight_device *bd)
* backlight. This provides some greater power saving and the display * backlight. This provides some greater power saving and the display
* is useless without backlight anyway. * is useless without backlight anyway.
*/ */
if (bd->props->power != FB_BLANK_UNBLANK || if (bd->props.power != FB_BLANK_UNBLANK ||
bd->props->fb_blank != FB_BLANK_UNBLANK) bd->props.fb_blank != FB_BLANK_UNBLANK)
level = 0; level = 0;
else else
level = bd->props->brightness; level = bd->props.brightness;
del_timer_sync(&rinfo->lvds_timer); del_timer_sync(&rinfo->lvds_timer);
radeon_engine_idle(); radeon_engine_idle();
...@@ -126,13 +124,12 @@ static int radeon_bl_update_status(struct backlight_device *bd) ...@@ -126,13 +124,12 @@ static int radeon_bl_update_status(struct backlight_device *bd)
static int radeon_bl_get_brightness(struct backlight_device *bd) static int radeon_bl_get_brightness(struct backlight_device *bd)
{ {
return bd->props->brightness; return bd->props.brightness;
} }
static struct backlight_properties radeon_bl_data = { static struct backlight_ops radeon_bl_data = {
.get_brightness = radeon_bl_get_brightness, .get_brightness = radeon_bl_get_brightness,
.update_status = radeon_bl_update_status, .update_status = radeon_bl_update_status,
.max_brightness = (FB_BACKLIGHT_LEVELS - 1),
}; };
void radeonfb_bl_init(struct radeonfb_info *rinfo) void radeonfb_bl_init(struct radeonfb_info *rinfo)
...@@ -188,8 +185,9 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo) ...@@ -188,8 +185,9 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo)
63 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL, 63 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL,
217 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL); 217 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL);
bd->props->brightness = radeon_bl_data.max_brightness; bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd->props->power = FB_BLANK_UNBLANK; bd->props.brightness = bd->props.max_brightness;
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd); backlight_update_status(bd);
printk("radeonfb: Backlight initialized (%s)\n", name); printk("radeonfb: Backlight initialized (%s)\n", name);
......
...@@ -35,14 +35,14 @@ static int fb_notifier_callback(struct notifier_block *self, ...@@ -35,14 +35,14 @@ static int fb_notifier_callback(struct notifier_block *self,
return 0; return 0;
bd = container_of(self, struct backlight_device, fb_notif); bd = container_of(self, struct backlight_device, fb_notif);
mutex_lock(&bd->props_lock); mutex_lock(&bd->ops_lock);
if (bd->props) if (bd->ops)
if (!bd->props->check_fb || if (!bd->ops->check_fb ||
bd->props->check_fb(evdata->info)) { bd->ops->check_fb(evdata->info)) {
bd->props->fb_blank = *(int *)evdata->data; bd->props.fb_blank = *(int *)evdata->data;
backlight_update_status(bd); backlight_update_status(bd);
} }
mutex_unlock(&bd->props_lock); mutex_unlock(&bd->ops_lock);
return 0; return 0;
} }
...@@ -71,15 +71,9 @@ static inline void backlight_unregister_fb(struct backlight_device *bd) ...@@ -71,15 +71,9 @@ static inline void backlight_unregister_fb(struct backlight_device *bd)
static ssize_t backlight_show_power(struct class_device *cdev, char *buf) static ssize_t backlight_show_power(struct class_device *cdev, char *buf)
{ {
int rc = -ENXIO;
struct backlight_device *bd = to_backlight_device(cdev); struct backlight_device *bd = to_backlight_device(cdev);
mutex_lock(&bd->props_lock); return sprintf(buf, "%d\n", bd->props.power);
if (bd->props)
rc = sprintf(buf, "%d\n", bd->props->power);
mutex_unlock(&bd->props_lock);
return rc;
} }
static ssize_t backlight_store_power(struct class_device *cdev, const char *buf, size_t count) static ssize_t backlight_store_power(struct class_device *cdev, const char *buf, size_t count)
...@@ -95,29 +89,23 @@ static ssize_t backlight_store_power(struct class_device *cdev, const char *buf, ...@@ -95,29 +89,23 @@ static ssize_t backlight_store_power(struct class_device *cdev, const char *buf,
if (size != count) if (size != count)
return -EINVAL; return -EINVAL;
mutex_lock(&bd->props_lock); mutex_lock(&bd->ops_lock);
if (bd->props) { if (bd->ops) {
pr_debug("backlight: set power to %d\n", power); pr_debug("backlight: set power to %d\n", power);
bd->props->power = power; bd->props.power = power;
backlight_update_status(bd); backlight_update_status(bd);
rc = count; rc = count;
} }
mutex_unlock(&bd->props_lock); mutex_unlock(&bd->ops_lock);
return rc; return rc;
} }
static ssize_t backlight_show_brightness(struct class_device *cdev, char *buf) static ssize_t backlight_show_brightness(struct class_device *cdev, char *buf)
{ {
int rc = -ENXIO;
struct backlight_device *bd = to_backlight_device(cdev); struct backlight_device *bd = to_backlight_device(cdev);
mutex_lock(&bd->props_lock); return sprintf(buf, "%d\n", bd->props.brightness);
if (bd->props)
rc = sprintf(buf, "%d\n", bd->props->brightness);
mutex_unlock(&bd->props_lock);
return rc;
} }
static ssize_t backlight_store_brightness(struct class_device *cdev, const char *buf, size_t count) static ssize_t backlight_store_brightness(struct class_device *cdev, const char *buf, size_t count)
...@@ -133,34 +121,28 @@ static ssize_t backlight_store_brightness(struct class_device *cdev, const char ...@@ -133,34 +121,28 @@ static ssize_t backlight_store_brightness(struct class_device *cdev, const char
if (size != count) if (size != count)
return -EINVAL; return -EINVAL;
mutex_lock(&bd->props_lock); mutex_lock(&bd->ops_lock);
if (bd->props) { if (bd->ops) {
if (brightness > bd->props->max_brightness) if (brightness > bd->props.max_brightness)
rc = -EINVAL; rc = -EINVAL;
else { else {
pr_debug("backlight: set brightness to %d\n", pr_debug("backlight: set brightness to %d\n",
brightness); brightness);
bd->props->brightness = brightness; bd->props.brightness = brightness;
backlight_update_status(bd); backlight_update_status(bd);
rc = count; rc = count;
} }
} }
mutex_unlock(&bd->props_lock); mutex_unlock(&bd->ops_lock);
return rc; return rc;
} }
static ssize_t backlight_show_max_brightness(struct class_device *cdev, char *buf) static ssize_t backlight_show_max_brightness(struct class_device *cdev, char *buf)
{ {
int rc = -ENXIO;
struct backlight_device *bd = to_backlight_device(cdev); struct backlight_device *bd = to_backlight_device(cdev);
mutex_lock(&bd->props_lock); return sprintf(buf, "%d\n", bd->props.max_brightness);
if (bd->props)
rc = sprintf(buf, "%d\n", bd->props->max_brightness);
mutex_unlock(&bd->props_lock);
return rc;
} }
static ssize_t backlight_show_actual_brightness(struct class_device *cdev, static ssize_t backlight_show_actual_brightness(struct class_device *cdev,
...@@ -169,10 +151,10 @@ static ssize_t backlight_show_actual_brightness(struct class_device *cdev, ...@@ -169,10 +151,10 @@ static ssize_t backlight_show_actual_brightness(struct class_device *cdev,
int rc = -ENXIO; int rc = -ENXIO;
struct backlight_device *bd = to_backlight_device(cdev); struct backlight_device *bd = to_backlight_device(cdev);
mutex_lock(&bd->props_lock); mutex_lock(&bd->ops_lock);
if (bd->props && bd->props->get_brightness) if (bd->ops && bd->ops->get_brightness)
rc = sprintf(buf, "%d\n", bd->props->get_brightness(bd)); rc = sprintf(buf, "%d\n", bd->ops->get_brightness(bd));
mutex_unlock(&bd->props_lock); mutex_unlock(&bd->ops_lock);
return rc; return rc;
} }
...@@ -211,7 +193,7 @@ static const struct class_device_attribute bl_class_device_attributes[] = { ...@@ -211,7 +193,7 @@ static const struct class_device_attribute bl_class_device_attributes[] = {
* respective framebuffer device). * respective framebuffer device).
* @devdata: an optional pointer to be stored in the class_device. The * @devdata: an optional pointer to be stored in the class_device. The
* methods may retrieve it by using class_get_devdata(&bd->class_dev). * methods may retrieve it by using class_get_devdata(&bd->class_dev).
* @bp: the backlight properties structure. * @ops: the backlight operations structure.
* *
* Creates and registers new backlight class_device. Returns either an * Creates and registers new backlight class_device. Returns either an
* ERR_PTR() or a pointer to the newly allocated device. * ERR_PTR() or a pointer to the newly allocated device.
...@@ -219,21 +201,20 @@ static const struct class_device_attribute bl_class_device_attributes[] = { ...@@ -219,21 +201,20 @@ static const struct class_device_attribute bl_class_device_attributes[] = {
struct backlight_device *backlight_device_register(const char *name, struct backlight_device *backlight_device_register(const char *name,
struct device *dev, struct device *dev,
void *devdata, void *devdata,
struct backlight_properties *bp) struct backlight_ops *ops)
{ {
int i, rc; int i, rc;
struct backlight_device *new_bd; struct backlight_device *new_bd;
pr_debug("backlight_device_alloc: name=%s\n", name); pr_debug("backlight_device_alloc: name=%s\n", name);
new_bd = kmalloc(sizeof(struct backlight_device), GFP_KERNEL); new_bd = kzalloc(sizeof(struct backlight_device), GFP_KERNEL);
if (!new_bd) if (!new_bd)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
mutex_init(&new_bd->update_lock); mutex_init(&new_bd->update_lock);
mutex_init(&new_bd->props_lock); mutex_init(&new_bd->ops_lock);
new_bd->props = bp; new_bd->ops = ops;
memset(&new_bd->class_dev, 0, sizeof(new_bd->class_dev));
new_bd->class_dev.class = &backlight_class; new_bd->class_dev.class = &backlight_class;
new_bd->class_dev.dev = dev; new_bd->class_dev.dev = dev;
strlcpy(new_bd->class_dev.class_id, name, KOBJ_NAME_LEN); strlcpy(new_bd->class_dev.class_id, name, KOBJ_NAME_LEN);
...@@ -302,9 +283,9 @@ void backlight_device_unregister(struct backlight_device *bd) ...@@ -302,9 +283,9 @@ void backlight_device_unregister(struct backlight_device *bd)
class_device_remove_file(&bd->class_dev, class_device_remove_file(&bd->class_dev,
&bl_class_device_attributes[i]); &bl_class_device_attributes[i]);
mutex_lock(&bd->props_lock); mutex_lock(&bd->ops_lock);
bd->props = NULL; bd->ops = NULL;
mutex_unlock(&bd->props_lock); mutex_unlock(&bd->ops_lock);
backlight_unregister_fb(bd); backlight_unregister_fb(bd);
......
...@@ -34,11 +34,11 @@ static unsigned long corgibl_flags; ...@@ -34,11 +34,11 @@ static unsigned long corgibl_flags;
static int corgibl_send_intensity(struct backlight_device *bd) static int corgibl_send_intensity(struct backlight_device *bd)
{ {
void (*corgi_kick_batt)(void); void (*corgi_kick_batt)(void);
int intensity = bd->props->brightness; int intensity = bd->props.brightness;
if (bd->props->power != FB_BLANK_UNBLANK) if (bd->props.power != FB_BLANK_UNBLANK)
intensity = 0; intensity = 0;
if (bd->props->fb_blank != FB_BLANK_UNBLANK) if (bd->props.fb_blank != FB_BLANK_UNBLANK)
intensity = 0; intensity = 0;
if (corgibl_flags & CORGIBL_SUSPENDED) if (corgibl_flags & CORGIBL_SUSPENDED)
intensity = 0; intensity = 0;
...@@ -103,7 +103,7 @@ void corgibl_limit_intensity(int limit) ...@@ -103,7 +103,7 @@ void corgibl_limit_intensity(int limit)
EXPORT_SYMBOL(corgibl_limit_intensity); EXPORT_SYMBOL(corgibl_limit_intensity);
static struct backlight_properties corgibl_data = { static struct backlight_ops corgibl_ops = {
.get_brightness = corgibl_get_intensity, .get_brightness = corgibl_get_intensity,
.update_status = corgibl_send_intensity, .update_status = corgibl_send_intensity,
}; };
...@@ -113,19 +113,19 @@ static int corgibl_probe(struct platform_device *pdev) ...@@ -113,19 +113,19 @@ static int corgibl_probe(struct platform_device *pdev)
struct corgibl_machinfo *machinfo = pdev->dev.platform_data; struct corgibl_machinfo *machinfo = pdev->dev.platform_data;
bl_machinfo = machinfo; bl_machinfo = machinfo;
corgibl_data.max_brightness = machinfo->max_intensity;
if (!machinfo->limit_mask) if (!machinfo->limit_mask)
machinfo->limit_mask = -1; machinfo->limit_mask = -1;
corgi_backlight_device = backlight_device_register ("corgi-bl", corgi_backlight_device = backlight_device_register ("corgi-bl",
&pdev->dev, NULL, &corgibl_data); &pdev->dev, NULL, &corgibl_ops);
if (IS_ERR (corgi_backlight_device)) if (IS_ERR (corgi_backlight_device))
return PTR_ERR (corgi_backlight_device); return PTR_ERR (corgi_backlight_device);
platform_set_drvdata(pdev, corgi_backlight_device); platform_set_drvdata(pdev, corgi_backlight_device);
corgibl_data.power = FB_BLANK_UNBLANK; corgi_backlight_device->props.max_brightness = machinfo->max_intensity;
corgibl_data.brightness = machinfo->default_intensity; corgi_backlight_device->props.power = FB_BLANK_UNBLANK;
corgi_backlight_device->props.brightness = machinfo->default_intensity;
corgibl_send_intensity(corgi_backlight_device); corgibl_send_intensity(corgi_backlight_device);
printk("Corgi Backlight Driver Initialized.\n"); printk("Corgi Backlight Driver Initialized.\n");
......
...@@ -33,11 +33,11 @@ static void hp680bl_send_intensity(struct backlight_device *bd) ...@@ -33,11 +33,11 @@ static void hp680bl_send_intensity(struct backlight_device *bd)
{ {
unsigned long flags; unsigned long flags;
u16 v; u16 v;
int intensity = bd->props->brightness; int intensity = bd->props.brightness;
if (bd->props->power != FB_BLANK_UNBLANK) if (bd->props.power != FB_BLANK_UNBLANK)
intensity = 0; intensity = 0;
if (bd->props->fb_blank != FB_BLANK_UNBLANK) if (bd->props.fb_blank != FB_BLANK_UNBLANK)
intensity = 0; intensity = 0;
if (hp680bl_suspended) if (hp680bl_suspended)
intensity = 0; intensity = 0;
...@@ -98,8 +98,7 @@ static int hp680bl_get_intensity(struct backlight_device *bd) ...@@ -98,8 +98,7 @@ static int hp680bl_get_intensity(struct backlight_device *bd)
return current_intensity; return current_intensity;
} }
static struct backlight_properties hp680bl_data = { static struct backlight_ops hp680bl_ops = {
.max_brightness = HP680_MAX_INTENSITY,
.get_brightness = hp680bl_get_intensity, .get_brightness = hp680bl_get_intensity,
.update_status = hp680bl_set_intensity, .update_status = hp680bl_set_intensity,
}; };
...@@ -109,13 +108,14 @@ static int __init hp680bl_probe(struct platform_device *pdev) ...@@ -109,13 +108,14 @@ static int __init hp680bl_probe(struct platform_device *pdev)
struct backlight_device *bd; struct backlight_device *bd;
bd = backlight_device_register ("hp680-bl", &pdev->dev, NULL, bd = backlight_device_register ("hp680-bl", &pdev->dev, NULL,
&hp680bl_data); &hp680bl_ops);
if (IS_ERR(bd)) if (IS_ERR(bd))
return PTR_ERR(bd); return PTR_ERR(bd);
platform_set_drvdata(pdev, bd); platform_set_drvdata(pdev, bd);
bd->props->brightness = HP680_DEFAULT_INTENSITY; bd->props.max_brightness = HP680_MAX_INTENSITY;
bd->props.brightness = HP680_DEFAULT_INTENSITY;
hp680bl_send_intensity(bd); hp680bl_send_intensity(bd);
return 0; return 0;
......
...@@ -31,11 +31,11 @@ static int fb_notifier_callback(struct notifier_block *self, ...@@ -31,11 +31,11 @@ static int fb_notifier_callback(struct notifier_block *self,
return 0; return 0;
ld = container_of(self, struct lcd_device, fb_notif); ld = container_of(self, struct lcd_device, fb_notif);
mutex_lock(&ld->props_lock); mutex_lock(&ld->ops_lock);
if (ld->props) if (ld->ops)
if (!ld->props->check_fb || ld->props->check_fb(evdata->info)) if (!ld->ops->check_fb || ld->ops->check_fb(evdata->info))
ld->props->set_power(ld, *(int *)evdata->data); ld->ops->set_power(ld, *(int *)evdata->data);
mutex_unlock(&ld->props_lock); mutex_unlock(&ld->ops_lock);
return 0; return 0;
} }
...@@ -66,12 +66,12 @@ static ssize_t lcd_show_power(struct class_device *cdev, char *buf) ...@@ -66,12 +66,12 @@ static ssize_t lcd_show_power(struct class_device *cdev, char *buf)
int rc; int rc;
struct lcd_device *ld = to_lcd_device(cdev); struct lcd_device *ld = to_lcd_device(cdev);
mutex_lock(&ld->props_lock); mutex_lock(&ld->ops_lock);
if (ld->props && ld->props->get_power) if (ld->ops && ld->ops->get_power)
rc = sprintf(buf, "%d\n", ld->props->get_power(ld)); rc = sprintf(buf, "%d\n", ld->ops->get_power(ld));
else else
rc = -ENXIO; rc = -ENXIO;
mutex_unlock(&ld->props_lock); mutex_unlock(&ld->ops_lock);
return rc; return rc;
} }
...@@ -89,13 +89,13 @@ static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_ ...@@ -89,13 +89,13 @@ static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_
if (size != count) if (size != count)
return -EINVAL; return -EINVAL;
mutex_lock(&ld->props_lock); mutex_lock(&ld->ops_lock);
if (ld->props && ld->props->set_power) { if (ld->ops && ld->ops->set_power) {
pr_debug("lcd: set power to %d\n", power); pr_debug("lcd: set power to %d\n", power);
ld->props->set_power(ld, power); ld->ops->set_power(ld, power);
rc = count; rc = count;
} }
mutex_unlock(&ld->props_lock); mutex_unlock(&ld->ops_lock);
return rc; return rc;
} }
...@@ -105,10 +105,10 @@ static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf) ...@@ -105,10 +105,10 @@ static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf)
int rc = -ENXIO; int rc = -ENXIO;
struct lcd_device *ld = to_lcd_device(cdev); struct lcd_device *ld = to_lcd_device(cdev);
mutex_lock(&ld->props_lock); mutex_lock(&ld->ops_lock);
if (ld->props && ld->props->get_contrast) if (ld->ops && ld->ops->get_contrast)
rc = sprintf(buf, "%d\n", ld->props->get_contrast(ld)); rc = sprintf(buf, "%d\n", ld->ops->get_contrast(ld));
mutex_unlock(&ld->props_lock); mutex_unlock(&ld->ops_lock);
return rc; return rc;
} }
...@@ -126,28 +126,22 @@ static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, si ...@@ -126,28 +126,22 @@ static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, si
if (size != count) if (size != count)
return -EINVAL; return -EINVAL;
mutex_lock(&ld->props_lock); mutex_lock(&ld->ops_lock);
if (ld->props && ld->props->set_contrast) { if (ld->ops && ld->ops->set_contrast) {
pr_debug("lcd: set contrast to %d\n", contrast); pr_debug("lcd: set contrast to %d\n", contrast);
ld->props->set_contrast(ld, contrast); ld->ops->set_contrast(ld, contrast);
rc = count; rc = count;
} }
mutex_unlock(&ld->props_lock); mutex_unlock(&ld->ops_lock);
return rc; return rc;
} }
static ssize_t lcd_show_max_contrast(struct class_device *cdev, char *buf) static ssize_t lcd_show_max_contrast(struct class_device *cdev, char *buf)
{ {
int rc = -ENXIO;
struct lcd_device *ld = to_lcd_device(cdev); struct lcd_device *ld = to_lcd_device(cdev);
mutex_lock(&ld->props_lock); return sprintf(buf, "%d\n", ld->props.max_contrast);
if (ld->props)
rc = sprintf(buf, "%d\n", ld->props->max_contrast);
mutex_unlock(&ld->props_lock);
return rc;
} }
static void lcd_class_release(struct class_device *dev) static void lcd_class_release(struct class_device *dev)
...@@ -180,27 +174,26 @@ static const struct class_device_attribute lcd_class_device_attributes[] = { ...@@ -180,27 +174,26 @@ static const struct class_device_attribute lcd_class_device_attributes[] = {
* respective framebuffer device). * respective framebuffer device).
* @devdata: an optional pointer to be stored in the class_device. The * @devdata: an optional pointer to be stored in the class_device. The
* methods may retrieve it by using class_get_devdata(ld->class_dev). * methods may retrieve it by using class_get_devdata(ld->class_dev).
* @lp: the lcd properties structure. * @ops: the lcd operations structure.
* *
* Creates and registers a new lcd class_device. Returns either an ERR_PTR() * Creates and registers a new lcd class_device. Returns either an ERR_PTR()
* or a pointer to the newly allocated device. * or a pointer to the newly allocated device.
*/ */
struct lcd_device *lcd_device_register(const char *name, void *devdata, struct lcd_device *lcd_device_register(const char *name, void *devdata,
struct lcd_properties *lp) struct lcd_ops *ops)
{ {
int i, rc; int i, rc;
struct lcd_device *new_ld; struct lcd_device *new_ld;
pr_debug("lcd_device_register: name=%s\n", name); pr_debug("lcd_device_register: name=%s\n", name);
new_ld = kmalloc(sizeof(struct lcd_device), GFP_KERNEL); new_ld = kzalloc(sizeof(struct lcd_device), GFP_KERNEL);
if (!new_ld) if (!new_ld)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
mutex_init(&new_ld->props_lock); mutex_init(&new_ld->ops_lock);
mutex_init(&new_ld->update_lock); mutex_init(&new_ld->update_lock);
new_ld->props = lp; new_ld->ops = ops;
memset(&new_ld->class_dev, 0, sizeof(new_ld->class_dev));
new_ld->class_dev.class = &lcd_class; new_ld->class_dev.class = &lcd_class;
strlcpy(new_ld->class_dev.class_id, name, KOBJ_NAME_LEN); strlcpy(new_ld->class_dev.class_id, name, KOBJ_NAME_LEN);
class_set_devdata(&new_ld->class_dev, devdata); class_set_devdata(&new_ld->class_dev, devdata);
...@@ -253,9 +246,9 @@ void lcd_device_unregister(struct lcd_device *ld) ...@@ -253,9 +246,9 @@ void lcd_device_unregister(struct lcd_device *ld)
class_device_remove_file(&ld->class_dev, class_device_remove_file(&ld->class_dev,
&lcd_class_device_attributes[i]); &lcd_class_device_attributes[i]);
mutex_lock(&ld->props_lock); mutex_lock(&ld->ops_lock);
ld->props = NULL; ld->ops = NULL;
mutex_unlock(&ld->props_lock); mutex_unlock(&ld->ops_lock);
lcd_unregister_fb(ld); lcd_unregister_fb(ld);
class_device_unregister(&ld->class_dev); class_device_unregister(&ld->class_dev);
} }
......
...@@ -112,11 +112,11 @@ static int current_intensity; ...@@ -112,11 +112,11 @@ static int current_intensity;
static int locomolcd_set_intensity(struct backlight_device *bd) static int locomolcd_set_intensity(struct backlight_device *bd)
{ {
int intensity = bd->props->brightness; int intensity = bd->props.brightness;
if (bd->props->power != FB_BLANK_UNBLANK) if (bd->props.power != FB_BLANK_UNBLANK)
intensity = 0; intensity = 0;
if (bd->props->fb_blank != FB_BLANK_UNBLANK) if (bd->props.fb_blank != FB_BLANK_UNBLANK)
intensity = 0; intensity = 0;
if (locomolcd_flags & LOCOMOLCD_SUSPENDED) if (locomolcd_flags & LOCOMOLCD_SUSPENDED)
intensity = 0; intensity = 0;
...@@ -141,10 +141,9 @@ static int locomolcd_get_intensity(struct backlight_device *bd) ...@@ -141,10 +141,9 @@ static int locomolcd_get_intensity(struct backlight_device *bd)
return current_intensity; return current_intensity;
} }
static struct backlight_properties locomobl_data = { static struct backlight_ops locomobl_data = {
.get_brightness = locomolcd_get_intensity, .get_brightness = locomolcd_get_intensity,
.update_status = locomolcd_set_intensity, .update_status = locomolcd_set_intensity,
.max_brightness = 4,
}; };
#ifdef CONFIG_PM #ifdef CONFIG_PM
...@@ -189,7 +188,8 @@ static int locomolcd_probe(struct locomo_dev *ldev) ...@@ -189,7 +188,8 @@ static int locomolcd_probe(struct locomo_dev *ldev)
return PTR_ERR (locomolcd_bl_device); return PTR_ERR (locomolcd_bl_device);
/* Set up frontlight so that screen is readable */ /* Set up frontlight so that screen is readable */
locomobl_data.brightness = 2; locomolcd_bl_device->props.max_brightness = 4,
locomolcd_bl_device->props.brightness = 2;
locomolcd_set_intensity(locomolcd_bl_device); locomolcd_set_intensity(locomolcd_bl_device);
return 0; return 0;
......
...@@ -35,11 +35,11 @@ static struct pci_dev *sb_dev = NULL; ...@@ -35,11 +35,11 @@ static struct pci_dev *sb_dev = NULL;
static int progearbl_set_intensity(struct backlight_device *bd) static int progearbl_set_intensity(struct backlight_device *bd)
{ {
int intensity = bd->props->brightness; int intensity = bd->props.brightness;
if (bd->props->power != FB_BLANK_UNBLANK) if (bd->props.power != FB_BLANK_UNBLANK)
intensity = 0; intensity = 0;
if (bd->props->fb_blank != FB_BLANK_UNBLANK) if (bd->props.fb_blank != FB_BLANK_UNBLANK)
intensity = 0; intensity = 0;
pci_write_config_byte(pmu_dev, PMU_LPCR, intensity + HW_LEVEL_MIN); pci_write_config_byte(pmu_dev, PMU_LPCR, intensity + HW_LEVEL_MIN);
...@@ -55,7 +55,7 @@ static int progearbl_get_intensity(struct backlight_device *bd) ...@@ -55,7 +55,7 @@ static int progearbl_get_intensity(struct backlight_device *bd)
return intensity - HW_LEVEL_MIN; return intensity - HW_LEVEL_MIN;
} }
static struct backlight_properties progearbl_data = { static struct backlight_ops progearbl_ops = {
.get_brightness = progearbl_get_intensity, .get_brightness = progearbl_get_intensity,
.update_status = progearbl_set_intensity, .update_status = progearbl_set_intensity,
}; };
...@@ -84,15 +84,15 @@ static int progearbl_probe(struct platform_device *pdev) ...@@ -84,15 +84,15 @@ static int progearbl_probe(struct platform_device *pdev)
progear_backlight_device = backlight_device_register("progear-bl", progear_backlight_device = backlight_device_register("progear-bl",
&pdev->dev, NULL, &pdev->dev, NULL,
&progearbl_data); &progearbl_ops);
if (IS_ERR(progear_backlight_device)) if (IS_ERR(progear_backlight_device))
return PTR_ERR(progear_backlight_device); return PTR_ERR(progear_backlight_device);
platform_set_drvdata(pdev, progear_backlight_device); platform_set_drvdata(pdev, progear_backlight_device);
progearbl_data.power = FB_BLANK_UNBLANK; progear_backlight_device->props.power = FB_BLANK_UNBLANK;
progearbl_data.brightness = HW_LEVEL_MAX - HW_LEVEL_MIN; progear_backlight_device->props.brightness = HW_LEVEL_MAX - HW_LEVEL_MIN;
progearbl_data.max_brightness = HW_LEVEL_MAX - HW_LEVEL_MIN; progear_backlight_device->props.max_brightness = HW_LEVEL_MAX - HW_LEVEL_MIN;
progearbl_set_intensity(progear_backlight_device); progearbl_set_intensity(progear_backlight_device);
return 0; return 0;
......
...@@ -395,7 +395,7 @@ chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent) ...@@ -395,7 +395,7 @@ chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent)
/* turn on the backlight */ /* turn on the backlight */
mutex_lock(&pmac_backlight_mutex); mutex_lock(&pmac_backlight_mutex);
if (pmac_backlight) { if (pmac_backlight) {
pmac_backlight->props->power = FB_BLANK_UNBLANK; pmac_backlight->props.power = FB_BLANK_UNBLANK;
backlight_update_status(pmac_backlight); backlight_update_status(pmac_backlight);
} }
mutex_unlock(&pmac_backlight_mutex); mutex_unlock(&pmac_backlight_mutex);
......
...@@ -54,11 +54,11 @@ static int nvidia_bl_update_status(struct backlight_device *bd) ...@@ -54,11 +54,11 @@ static int nvidia_bl_update_status(struct backlight_device *bd)
if (!par->FlatPanel) if (!par->FlatPanel)
return 0; return 0;
if (bd->props->power != FB_BLANK_UNBLANK || if (bd->props.power != FB_BLANK_UNBLANK ||
bd->props->fb_blank != FB_BLANK_UNBLANK) bd->props.fb_blank != FB_BLANK_UNBLANK)
level = 0; level = 0;
else else
level = bd->props->brightness; level = bd->props.brightness;
tmp_pmc = NV_RD32(par->PMC, 0x10F0) & 0x0000FFFF; tmp_pmc = NV_RD32(par->PMC, 0x10F0) & 0x0000FFFF;
tmp_pcrt = NV_RD32(par->PCRTC0, 0x081C) & 0xFFFFFFFC; tmp_pcrt = NV_RD32(par->PCRTC0, 0x081C) & 0xFFFFFFFC;
...@@ -81,13 +81,12 @@ static int nvidia_bl_update_status(struct backlight_device *bd) ...@@ -81,13 +81,12 @@ static int nvidia_bl_update_status(struct backlight_device *bd)
static int nvidia_bl_get_brightness(struct backlight_device *bd) static int nvidia_bl_get_brightness(struct backlight_device *bd)
{ {
return bd->props->brightness; return bd->props.brightness;
} }
static struct backlight_properties nvidia_bl_data = { static struct backlight_ops nvidia_bl_ops = {
.get_brightness = nvidia_bl_get_brightness, .get_brightness = nvidia_bl_get_brightness,
.update_status = nvidia_bl_update_status, .update_status = nvidia_bl_update_status,
.max_brightness = (FB_BACKLIGHT_LEVELS - 1),
}; };
void nvidia_bl_init(struct nvidia_par *par) void nvidia_bl_init(struct nvidia_par *par)
...@@ -107,7 +106,7 @@ void nvidia_bl_init(struct nvidia_par *par) ...@@ -107,7 +106,7 @@ void nvidia_bl_init(struct nvidia_par *par)
snprintf(name, sizeof(name), "nvidiabl%d", info->node); snprintf(name, sizeof(name), "nvidiabl%d", info->node);
bd = backlight_device_register(name, info->dev, par, &nvidia_bl_data); bd = backlight_device_register(name, info->dev, par, &nvidia_bl_ops);
if (IS_ERR(bd)) { if (IS_ERR(bd)) {
info->bl_dev = NULL; info->bl_dev = NULL;
printk(KERN_WARNING "nvidia: Backlight registration failed\n"); printk(KERN_WARNING "nvidia: Backlight registration failed\n");
...@@ -119,8 +118,9 @@ void nvidia_bl_init(struct nvidia_par *par) ...@@ -119,8 +118,9 @@ void nvidia_bl_init(struct nvidia_par *par)
0x158 * FB_BACKLIGHT_MAX / MAX_LEVEL, 0x158 * FB_BACKLIGHT_MAX / MAX_LEVEL,
0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL); 0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL);
bd->props->brightness = nvidia_bl_data.max_brightness; bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd->props->power = FB_BLANK_UNBLANK; bd->props.brightness = nvidia_bl_data.max_brightness;
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd); backlight_update_status(bd);
printk("nvidia: Backlight initialized (%s)\n", name); printk("nvidia: Backlight initialized (%s)\n", name);
......
...@@ -308,11 +308,11 @@ static int riva_bl_update_status(struct backlight_device *bd) ...@@ -308,11 +308,11 @@ static int riva_bl_update_status(struct backlight_device *bd)
U032 tmp_pcrt, tmp_pmc; U032 tmp_pcrt, tmp_pmc;
int level; int level;
if (bd->props->power != FB_BLANK_UNBLANK || if (bd->props.power != FB_BLANK_UNBLANK ||
bd->props->fb_blank != FB_BLANK_UNBLANK) bd->props.fb_blank != FB_BLANK_UNBLANK)
level = 0; level = 0;
else else
level = bd->props->brightness; level = bd->props.brightness;
tmp_pmc = par->riva.PMC[0x10F0/4] & 0x0000FFFF; tmp_pmc = par->riva.PMC[0x10F0/4] & 0x0000FFFF;
tmp_pcrt = par->riva.PCRTC0[0x081C/4] & 0xFFFFFFFC; tmp_pcrt = par->riva.PCRTC0[0x081C/4] & 0xFFFFFFFC;
...@@ -329,13 +329,12 @@ static int riva_bl_update_status(struct backlight_device *bd) ...@@ -329,13 +329,12 @@ static int riva_bl_update_status(struct backlight_device *bd)
static int riva_bl_get_brightness(struct backlight_device *bd) static int riva_bl_get_brightness(struct backlight_device *bd)
{ {
return bd->props->brightness; return bd->props.brightness;
} }
static struct backlight_properties riva_bl_data = { static struct backlight_ops riva_bl_ops = {
.get_brightness = riva_bl_get_brightness, .get_brightness = riva_bl_get_brightness,
.update_status = riva_bl_update_status, .update_status = riva_bl_update_status,
.max_brightness = (FB_BACKLIGHT_LEVELS - 1),
}; };
static void riva_bl_init(struct riva_par *par) static void riva_bl_init(struct riva_par *par)
...@@ -355,7 +354,7 @@ static void riva_bl_init(struct riva_par *par) ...@@ -355,7 +354,7 @@ static void riva_bl_init(struct riva_par *par)
snprintf(name, sizeof(name), "rivabl%d", info->node); snprintf(name, sizeof(name), "rivabl%d", info->node);
bd = backlight_device_register(name, info->dev, par, &riva_bl_data); bd = backlight_device_register(name, info->dev, par, &riva_bl_ops);
if (IS_ERR(bd)) { if (IS_ERR(bd)) {
info->bl_dev = NULL; info->bl_dev = NULL;
printk(KERN_WARNING "riva: Backlight registration failed\n"); printk(KERN_WARNING "riva: Backlight registration failed\n");
...@@ -367,8 +366,9 @@ static void riva_bl_init(struct riva_par *par) ...@@ -367,8 +366,9 @@ static void riva_bl_init(struct riva_par *par)
MIN_LEVEL * FB_BACKLIGHT_MAX / MAX_LEVEL, MIN_LEVEL * FB_BACKLIGHT_MAX / MAX_LEVEL,
FB_BACKLIGHT_MAX); FB_BACKLIGHT_MAX);
bd->props->brightness = riva_bl_data.max_brightness; bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd->props->power = FB_BLANK_UNBLANK; bd->props.brightness = riva_bl_data.max_brightness;
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd); backlight_update_status(bd);
printk("riva: Backlight initialized (%s)\n", name); printk("riva: Backlight initialized (%s)\n", name);
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
/* Notes on locking: /* Notes on locking:
* *
* backlight_device->props_lock is an internal backlight lock protecting the * backlight_device->ops_lock is an internal backlight lock protecting the
* props field and no code outside the core should need to touch it. * ops pointer and no code outside the core should need to touch it.
* *
* Access to update_status() is serialised by the update_lock mutex since * Access to update_status() is serialised by the update_lock mutex since
* most drivers seem to need this and historically get it wrong. * most drivers seem to need this and historically get it wrong.
...@@ -30,9 +30,7 @@ ...@@ -30,9 +30,7 @@
struct backlight_device; struct backlight_device;
struct fb_info; struct fb_info;
/* This structure defines all the properties of a backlight struct backlight_ops {
(usually attached to a LCD). */
struct backlight_properties {
/* Notify the backlight driver some property has changed */ /* Notify the backlight driver some property has changed */
int (*update_status)(struct backlight_device *); int (*update_status)(struct backlight_device *);
/* Return the current backlight brightness (accounting for power, /* Return the current backlight brightness (accounting for power,
...@@ -41,7 +39,10 @@ struct backlight_properties { ...@@ -41,7 +39,10 @@ struct backlight_properties {
/* Check if given framebuffer device is the one bound to this backlight; /* Check if given framebuffer device is the one bound to this backlight;
return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */ return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */
int (*check_fb)(struct fb_info *); int (*check_fb)(struct fb_info *);
};
/* This structure defines all the properties of a backlight */
struct backlight_properties {
/* Current User requested brightness (0 - max_brightness) */ /* Current User requested brightness (0 - max_brightness) */
int brightness; int brightness;
/* Maximal value for brightness (read-only) */ /* Maximal value for brightness (read-only) */
...@@ -54,14 +55,18 @@ struct backlight_properties { ...@@ -54,14 +55,18 @@ struct backlight_properties {
}; };
struct backlight_device { struct backlight_device {
/* This protects the 'props' field. If 'props' is NULL, the driver that /* Backlight properties */
registered this device has been unloaded, and if class_get_devdata() struct backlight_properties props;
points to something in the body of that driver, it is also invalid. */
struct mutex props_lock;
/* If this is NULL, the backing module is unloaded */
struct backlight_properties *props;
/* Serialise access to update_status method */ /* Serialise access to update_status method */
struct mutex update_lock; struct mutex update_lock;
/* This protects the 'ops' field. If 'ops' is NULL, the driver that
registered this device has been unloaded, and if class_get_devdata()
points to something in the body of that driver, it is also invalid. */
struct mutex ops_lock;
struct backlight_ops *ops;
/* The framebuffer notifier block */ /* The framebuffer notifier block */
struct notifier_block fb_notif; struct notifier_block fb_notif;
/* The class device structure */ /* The class device structure */
...@@ -71,13 +76,13 @@ struct backlight_device { ...@@ -71,13 +76,13 @@ struct backlight_device {
static inline void backlight_update_status(struct backlight_device *bd) static inline void backlight_update_status(struct backlight_device *bd)
{ {
mutex_lock(&bd->update_lock); mutex_lock(&bd->update_lock);
if (bd->props && bd->props->update_status) if (bd->ops && bd->ops->update_status)
bd->props->update_status(bd); bd->ops->update_status(bd);
mutex_unlock(&bd->update_lock); mutex_unlock(&bd->update_lock);
} }
extern struct backlight_device *backlight_device_register(const char *name, extern struct backlight_device *backlight_device_register(const char *name,
struct device *dev,void *devdata,struct backlight_properties *bp); struct device *dev, void *devdata, struct backlight_ops *ops);
extern void backlight_device_unregister(struct backlight_device *bd); extern void backlight_device_unregister(struct backlight_device *bd);
#define to_backlight_device(obj) container_of(obj, struct backlight_device, class_dev) #define to_backlight_device(obj) container_of(obj, struct backlight_device, class_dev)
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
/* Notes on locking: /* Notes on locking:
* *
* lcd_device->props_lock is an internal backlight lock protecting the props * lcd_device->ops_lock is an internal backlight lock protecting the ops
* field and no code outside the core should need to touch it. * field and no code outside the core should need to touch it.
* *
* Access to set_power() is serialised by the update_lock mutex since * Access to set_power() is serialised by the update_lock mutex since
...@@ -30,15 +30,17 @@ ...@@ -30,15 +30,17 @@
struct lcd_device; struct lcd_device;
struct fb_info; struct fb_info;
/* This structure defines all the properties of a LCD flat panel. */
struct lcd_properties { struct lcd_properties {
/* The maximum value for contrast (read-only) */
int max_contrast;
};
struct lcd_ops {
/* Get the LCD panel power status (0: full on, 1..3: controller /* Get the LCD panel power status (0: full on, 1..3: controller
power on, flat panel power off, 4: full off), see FB_BLANK_XXX */ power on, flat panel power off, 4: full off), see FB_BLANK_XXX */
int (*get_power)(struct lcd_device *); int (*get_power)(struct lcd_device *);
/* Enable or disable power to the LCD (0: on; 4: off, see FB_BLANK_XXX) */ /* Enable or disable power to the LCD (0: on; 4: off, see FB_BLANK_XXX) */
int (*set_power)(struct lcd_device *, int power); int (*set_power)(struct lcd_device *, int power);
/* The maximum value for contrast (read-only) */
int max_contrast;
/* Get the current contrast setting (0-max_contrast) */ /* Get the current contrast setting (0-max_contrast) */
int (*get_contrast)(struct lcd_device *); int (*get_contrast)(struct lcd_device *);
/* Set LCD panel contrast */ /* Set LCD panel contrast */
...@@ -49,12 +51,13 @@ struct lcd_properties { ...@@ -49,12 +51,13 @@ struct lcd_properties {
}; };
struct lcd_device { struct lcd_device {
/* This protects the 'props' field. If 'props' is NULL, the driver that struct lcd_properties props;
/* This protects the 'ops' field. If 'ops' is NULL, the driver that
registered this device has been unloaded, and if class_get_devdata() registered this device has been unloaded, and if class_get_devdata()
points to something in the body of that driver, it is also invalid. */ points to something in the body of that driver, it is also invalid. */
struct mutex props_lock; struct mutex ops_lock;
/* If this is NULL, the backing module is unloaded */ /* If this is NULL, the backing module is unloaded */
struct lcd_properties *props; struct lcd_ops *ops;
/* Serialise access to set_power method */ /* Serialise access to set_power method */
struct mutex update_lock; struct mutex update_lock;
/* The framebuffer notifier block */ /* The framebuffer notifier block */
...@@ -66,13 +69,13 @@ struct lcd_device { ...@@ -66,13 +69,13 @@ struct lcd_device {
static inline void lcd_set_power(struct lcd_device *ld, int power) static inline void lcd_set_power(struct lcd_device *ld, int power)
{ {
mutex_lock(&ld->update_lock); mutex_lock(&ld->update_lock);
if (ld->props && ld->props->set_power) if (ld->ops && ld->ops->set_power)
ld->props->set_power(ld, power); ld->ops->set_power(ld, power);
mutex_unlock(&ld->update_lock); mutex_unlock(&ld->update_lock);
} }
extern struct lcd_device *lcd_device_register(const char *name, extern struct lcd_device *lcd_device_register(const char *name,
void *devdata, struct lcd_properties *lp); void *devdata, struct lcd_ops *ops);
extern void lcd_device_unregister(struct lcd_device *ld); extern void lcd_device_unregister(struct lcd_device *ld);
#define to_lcd_device(obj) container_of(obj, struct lcd_device, class_dev) #define to_lcd_device(obj) container_of(obj, struct lcd_device, class_dev)
......
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