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)
if (machine_is(powermac) && pmac_backlight) {
struct backlight_properties *props;
props = pmac_backlight->props;
props = &pmac_backlight->props;
props->brightness = props->max_brightness;
props->power = FB_BLANK_UNBLANK;
backlight_update_status(pmac_backlight);
......
......@@ -44,7 +44,7 @@ DEFINE_MUTEX(pmac_backlight_mutex);
/* 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.
*
* 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)
struct backlight_properties *props;
int brightness;
props = pmac_backlight->props;
props = &pmac_backlight->props;
brightness = props->brightness +
((pmac_backlight_key_queued?-1:1) *
......@@ -141,7 +141,7 @@ static int __pmac_backlight_set_legacy_brightness(int brightness)
if (pmac_backlight) {
struct backlight_properties *props;
props = pmac_backlight->props;
props = &pmac_backlight->props;
props->brightness = brightness *
(props->max_brightness + 1) /
(OLD_BACKLIGHT_MAX + 1);
......@@ -190,7 +190,7 @@ int pmac_backlight_get_legacy_brightness()
if (pmac_backlight) {
struct backlight_properties *props;
props = pmac_backlight->props;
props = &pmac_backlight->props;
result = props->brightness *
(OLD_BACKLIGHT_MAX + 1) /
......
......@@ -848,7 +848,7 @@ out:
static int set_brightness_status(struct backlight_device *bd)
{
return set_brightness(bd->props->brightness);
return set_brightness(bd->props.brightness);
}
static int
......@@ -1352,10 +1352,9 @@ static int asus_hotk_remove(struct acpi_device *device, int type)
return 0;
}
static struct backlight_properties asus_backlight_data = {
static struct backlight_ops asus_backlight_data = {
.get_brightness = read_brightness,
.update_status = set_brightness_status,
.max_brightness = 15,
};
static void __exit asus_acpi_exit(void)
......@@ -1409,6 +1408,7 @@ static int __init asus_acpi_init(void)
asus_backlight_device = NULL;
asus_acpi_exit();
}
asus_backlight_device->props.max_brightness = 15;
return 0;
}
......
......@@ -1701,13 +1701,12 @@ static int brightness_write(char *buf)
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,
.update_status = brightness_update_status,
.max_brightness = 7,
};
static int brightness_init(void)
......@@ -1719,6 +1718,8 @@ static int brightness_init(void)
return PTR_ERR(ibm_backlight_device);
}
ibm_backlight_device->props.max_brightness = 7;
return 0;
}
......
......@@ -315,7 +315,7 @@ static int set_lcd(int value)
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)
......@@ -533,10 +533,9 @@ static acpi_status __exit remove_device(void)
return AE_OK;
}
static struct backlight_properties toshiba_backlight_data = {
static struct backlight_ops toshiba_backlight_data = {
.get_brightness = get_lcd,
.update_status = set_lcd_status,
.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1,
};
static void __exit toshiba_acpi_exit(void)
......@@ -596,6 +595,7 @@ static int __init toshiba_acpi_init(void)
toshiba_backlight_device = NULL;
toshiba_acpi_exit();
}
toshiba_backlight_device->props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
}
......
......@@ -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;
}
......
......@@ -15,7 +15,7 @@
#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 int sleeping;
static u8 bl_curve[FB_BACKLIGHT_LEVELS];
......@@ -72,7 +72,7 @@ static int pmu_backlight_update_status(struct backlight_device *bd)
{
struct adb_request req;
unsigned long flags;
int level = bd->props->brightness;
int level = bd->props.brightness;
spin_lock_irqsave(&pmu_backlight_lock, flags);
......@@ -80,8 +80,8 @@ static int pmu_backlight_update_status(struct backlight_device *bd)
if (sleeping)
goto out;
if (bd->props->power != FB_BLANK_UNBLANK ||
bd->props->fb_blank != FB_BLANK_UNBLANK)
if (bd->props.power != FB_BLANK_UNBLANK ||
bd->props.fb_blank != FB_BLANK_UNBLANK)
level = 0;
if (level > 0) {
......@@ -107,13 +107,13 @@ out:
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,
.update_status = pmu_backlight_update_status,
.max_brightness = (FB_BACKLIGHT_LEVELS - 1),
};
#ifdef CONFIG_PM
......@@ -151,9 +151,10 @@ void __init pmu_backlight_init()
printk("pmubl: Backlight registration failed\n");
goto error;
}
bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
pmu_backlight_init_curve(0x7F, 0x46, 0x0E);
level = pmu_backlight_data.max_brightness;
level = bd->props.max_brightness;
if (autosave) {
/* read autosaved value if available */
......@@ -163,11 +164,11 @@ void __init pmu_backlight_init()
level = pmu_backlight_curve_lookup(
(req.reply[0] >> 4) *
pmu_backlight_data.max_brightness / 15);
bd->props.max_brightness / 15);
}
bd->props->brightness = level;
bd->props->power = FB_BLANK_UNBLANK;
bd->props.brightness = level;
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd);
printk("pmubl: Backlight initialized (%s)\n", name);
......
......@@ -195,10 +195,9 @@ static struct backlight_device *asus_backlight_device;
*/
static int read_brightness(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,
.update_status = update_bl_status,
.max_brightness = 15,
};
/* These functions actually update the LED's, and are called from a
......@@ -348,7 +347,7 @@ static void lcd_blank(int blank)
struct backlight_device *bd = asus_backlight_device;
if (bd) {
bd->props->power = blank;
bd->props.power = blank;
backlight_update_status(bd);
}
}
......@@ -381,13 +380,13 @@ static int set_brightness(struct backlight_device *bd, int value)
static int update_bl_status(struct backlight_device *bd)
{
int rv;
int value = bd->props->brightness;
int value = bd->props.brightness;
rv = set_brightness(bd, value);
if (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);
}
......@@ -1013,7 +1012,7 @@ static int asus_backlight_init(struct device *dev)
if (brightness_set_handle && lcd_switch_handle) {
bd = backlight_device_register(ASUS_HOTK_FILE, dev,
NULL, &asusbl_data);
NULL, &asusbl_ops);
if (IS_ERR(bd)) {
printk(ASUS_ERR
"Could not register asus backlight device\n");
......@@ -1023,8 +1022,9 @@ static int asus_backlight_init(struct device *dev)
asus_backlight_device = bd;
bd->props->brightness = read_brightness(NULL);
bd->props->power = FB_BLANK_UNBLANK;
bd->props.max_brightness = 15;
bd->props.brightness = read_brightness(NULL);
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd);
}
return 0;
......
......@@ -157,13 +157,12 @@ static int bl_get_brightness(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,
.update_status = bl_update_status,
.max_brightness = MSI_LCD_LEVEL_MAX-1,
};
static struct backlight_device *msibl_device;
......@@ -317,10 +316,12 @@ static int __init msi_init(void)
/* Register backlight stuff */
msibl_device = backlight_device_register("msi-laptop-bl", NULL, NULL,
&msibl_props);
&msibl_ops);
if (IS_ERR(msibl_device))
return PTR_ERR(msibl_device);
msibl_device->props.max_brightness = MSI_LCD_LEVEL_MAX-1,
ret = platform_driver_register(&msipf_driver);
if (ret)
goto fail_backlight;
......
......@@ -141,7 +141,7 @@ static int appledisplay_bl_update_status(struct backlight_device *bd)
int retval;
pdata->msgdata[0] = 0x10;
pdata->msgdata[1] = bd->props->brightness;
pdata->msgdata[1] = bd->props.brightness;
retval = usb_control_msg(
pdata->udev,
......@@ -177,10 +177,9 @@ static int appledisplay_bl_get_brightness(struct backlight_device *bd)
return pdata->msgdata[1];
}
static struct backlight_properties appledisplay_bl_data = {
static struct backlight_ops appledisplay_bl_data = {
.get_brightness = appledisplay_bl_get_brightness,
.update_status = appledisplay_bl_update_status,
.max_brightness = 0xFF
};
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);
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 */
if (pdata->button_pressed)
......@@ -285,6 +284,8 @@ static int appledisplay_probe(struct usb_interface *iface,
goto error;
}
pdata->bd->props.max_brightness = 0xff;
/* Try to get brightness */
brightness = appledisplay_bl_get_brightness(pdata->bd);
......@@ -295,7 +296,7 @@ static int appledisplay_probe(struct usb_interface *iface,
}
/* Set brightness in backlight device */
pdata->bd->props->brightness = brightness;
pdata->bd->props.brightness = brightness;
/* save our data pointer in the interface device */
usb_set_intfdata(iface, pdata);
......
......@@ -1695,8 +1695,6 @@ static int __devinit aty128fb_setup(char *options)
#ifdef CONFIG_FB_ATY128_BACKLIGHT
#define MAX_LEVEL 0xFF
static struct backlight_properties aty128_bl_data;
static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
int level)
{
......@@ -1730,12 +1728,12 @@ static int aty128_bl_update_status(struct backlight_device *bd)
unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL);
int level;
if (bd->props->power != FB_BLANK_UNBLANK ||
bd->props->fb_blank != FB_BLANK_UNBLANK ||
if (bd->props.power != FB_BLANK_UNBLANK ||
bd->props.fb_blank != FB_BLANK_UNBLANK ||
!par->lcd_on)
level = 0;
else
level = bd->props->brightness;
level = bd->props.brightness;
reg |= LVDS_BL_MOD_EN | LVDS_BLON;
if (level > 0) {
......@@ -1779,19 +1777,18 @@ static int aty128_bl_update_status(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,
.update_status = aty128_bl_update_status,
.max_brightness = (FB_BACKLIGHT_LEVELS - 1),
};
static void aty128_bl_set_power(struct fb_info *info, int power)
{
if (info->bl_dev) {
info->bl_dev->props->power = power;
info->bl_dev->props.power = power;
backlight_update_status(info->bl_dev);
}
}
......@@ -1825,8 +1822,9 @@ static void aty128_bl_init(struct aty128fb_par *par)
63 * FB_BACKLIGHT_MAX / MAX_LEVEL,
219 * FB_BACKLIGHT_MAX / MAX_LEVEL);
bd->props->brightness = aty128_bl_data.max_brightness;
bd->props->power = FB_BLANK_UNBLANK;
bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd->props.brightness = bd->props.max_brightness;
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd);
printk("aty128: Backlight initialized (%s)\n", name);
......
......@@ -2114,8 +2114,6 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
#ifdef CONFIG_FB_ATY_BACKLIGHT
#define MAX_LEVEL 0xFF
static struct backlight_properties aty_bl_data;
static int aty_bl_get_level_brightness(struct atyfb_par *par, int level)
{
struct fb_info *info = pci_get_drvdata(par->pdev);
......@@ -2139,11 +2137,11 @@ static int aty_bl_update_status(struct backlight_device *bd)
unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par);
int level;
if (bd->props->power != FB_BLANK_UNBLANK ||
bd->props->fb_blank != FB_BLANK_UNBLANK)
if (bd->props.power != FB_BLANK_UNBLANK ||
bd->props.fb_blank != FB_BLANK_UNBLANK)
level = 0;
else
level = bd->props->brightness;
level = bd->props.brightness;
reg |= (BLMOD_EN | BIASMOD_EN);
if (level > 0) {
......@@ -2160,13 +2158,12 @@ static int aty_bl_update_status(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,
.update_status = aty_bl_update_status,
.max_brightness = (FB_BACKLIGHT_LEVELS - 1),
};
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,
0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL);
bd->props->brightness = aty_bl_data.max_brightness;
bd->props->power = FB_BLANK_UNBLANK;
bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd->props.brightness = bd->props.max_brightness;
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd);
printk("aty: Backlight initialized (%s)\n", name);
......
......@@ -19,8 +19,6 @@
#define MAX_RADEON_LEVEL 0xFF
static struct backlight_properties radeon_bl_data;
struct radeon_bl_privdata {
struct radeonfb_info *rinfo;
uint8_t negative;
......@@ -61,11 +59,11 @@ static int radeon_bl_update_status(struct backlight_device *bd)
* backlight. This provides some greater power saving and the display
* is useless without backlight anyway.
*/
if (bd->props->power != FB_BLANK_UNBLANK ||
bd->props->fb_blank != FB_BLANK_UNBLANK)
if (bd->props.power != FB_BLANK_UNBLANK ||
bd->props.fb_blank != FB_BLANK_UNBLANK)
level = 0;
else
level = bd->props->brightness;
level = bd->props.brightness;
del_timer_sync(&rinfo->lvds_timer);
radeon_engine_idle();
......@@ -126,13 +124,12 @@ static int radeon_bl_update_status(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,
.update_status = radeon_bl_update_status,
.max_brightness = (FB_BACKLIGHT_LEVELS - 1),
};
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,
217 * FB_BACKLIGHT_MAX / MAX_RADEON_LEVEL);
bd->props->brightness = radeon_bl_data.max_brightness;
bd->props->power = FB_BLANK_UNBLANK;
bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd->props.brightness = bd->props.max_brightness;
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd);
printk("radeonfb: Backlight initialized (%s)\n", name);
......
......@@ -35,14 +35,14 @@ static int fb_notifier_callback(struct notifier_block *self,
return 0;
bd = container_of(self, struct backlight_device, fb_notif);
mutex_lock(&bd->props_lock);
if (bd->props)
if (!bd->props->check_fb ||
bd->props->check_fb(evdata->info)) {
bd->props->fb_blank = *(int *)evdata->data;
mutex_lock(&bd->ops_lock);
if (bd->ops)
if (!bd->ops->check_fb ||
bd->ops->check_fb(evdata->info)) {
bd->props.fb_blank = *(int *)evdata->data;
backlight_update_status(bd);
}
mutex_unlock(&bd->props_lock);
mutex_unlock(&bd->ops_lock);
return 0;
}
......@@ -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)
{
int rc = -ENXIO;
struct backlight_device *bd = to_backlight_device(cdev);
mutex_lock(&bd->props_lock);
if (bd->props)
rc = sprintf(buf, "%d\n", bd->props->power);
mutex_unlock(&bd->props_lock);
return rc;
return sprintf(buf, "%d\n", bd->props.power);
}
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,
if (size != count)
return -EINVAL;
mutex_lock(&bd->props_lock);
if (bd->props) {
mutex_lock(&bd->ops_lock);
if (bd->ops) {
pr_debug("backlight: set power to %d\n", power);
bd->props->power = power;
bd->props.power = power;
backlight_update_status(bd);
rc = count;
}
mutex_unlock(&bd->props_lock);
mutex_unlock(&bd->ops_lock);
return rc;
}
static ssize_t backlight_show_brightness(struct class_device *cdev, char *buf)
{
int rc = -ENXIO;
struct backlight_device *bd = to_backlight_device(cdev);
mutex_lock(&bd->props_lock);
if (bd->props)
rc = sprintf(buf, "%d\n", bd->props->brightness);
mutex_unlock(&bd->props_lock);
return rc;
return sprintf(buf, "%d\n", bd->props.brightness);
}
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
if (size != count)
return -EINVAL;
mutex_lock(&bd->props_lock);
if (bd->props) {
if (brightness > bd->props->max_brightness)
mutex_lock(&bd->ops_lock);
if (bd->ops) {
if (brightness > bd->props.max_brightness)
rc = -EINVAL;
else {
pr_debug("backlight: set brightness to %d\n",
brightness);
bd->props->brightness = brightness;
bd->props.brightness = brightness;
backlight_update_status(bd);
rc = count;
}
}
mutex_unlock(&bd->props_lock);
mutex_unlock(&bd->ops_lock);
return rc;
}
static ssize_t backlight_show_max_brightness(struct class_device *cdev, char *buf)
{
int rc = -ENXIO;
struct backlight_device *bd = to_backlight_device(cdev);
mutex_lock(&bd->props_lock);
if (bd->props)
rc = sprintf(buf, "%d\n", bd->props->max_brightness);
mutex_unlock(&bd->props_lock);
return rc;
return sprintf(buf, "%d\n", bd->props.max_brightness);
}
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;
struct backlight_device *bd = to_backlight_device(cdev);
mutex_lock(&bd->props_lock);
if (bd->props && bd->props->get_brightness)
rc = sprintf(buf, "%d\n", bd->props->get_brightness(bd));
mutex_unlock(&bd->props_lock);
mutex_lock(&bd->ops_lock);
if (bd->ops && bd->ops->get_brightness)
rc = sprintf(buf, "%d\n", bd->ops->get_brightness(bd));
mutex_unlock(&bd->ops_lock);
return rc;
}
......@@ -211,7 +193,7 @@ static const struct class_device_attribute bl_class_device_attributes[] = {
* respective framebuffer device).
* @devdata: an optional pointer to be stored in the class_device. The
* 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
* ERR_PTR() or a pointer to the newly allocated device.
......@@ -219,21 +201,20 @@ static const struct class_device_attribute bl_class_device_attributes[] = {
struct backlight_device *backlight_device_register(const char *name,
struct device *dev,
void *devdata,
struct backlight_properties *bp)
struct backlight_ops *ops)
{
int i, rc;
struct backlight_device *new_bd;
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)
return ERR_PTR(-ENOMEM);
mutex_init(&new_bd->update_lock);
mutex_init(&new_bd->props_lock);
new_bd->props = bp;
memset(&new_bd->class_dev, 0, sizeof(new_bd->class_dev));
mutex_init(&new_bd->ops_lock);