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);
/* 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
struct backlight_properties *props;
int brightness;
- props = pmac_backlight->props;
+ props = &pmac_backlight->props;
brightness = props->brightness +
((pmac_backlight_key_queued?-1:1) *
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);
if (pmac_backlight) {
struct backlight_properties *props;
- props = pmac_backlight->props;
+ props = &pmac_backlight->props;
result = props->brightness *
(OLD_BACKLIGHT_MAX + 1) /
static int set_brightness_status(struct backlight_device *bd)
{
- return set_brightness(bd->props->brightness);
+ return set_brightness(bd->props.brightness);
}
static int
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)
asus_backlight_device = NULL;
asus_acpi_exit();
}
+ asus_backlight_device->props.max_brightness = 15;
return 0;
}
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)
return PTR_ERR(ibm_backlight_device);
}
+ ibm_backlight_device->props.max_brightness = 7;
+
return 0;
}
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)
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)
toshiba_backlight_device = NULL;
toshiba_acpi_exit();
}
+ toshiba_backlight_device->props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
}
struct acpi_device *dev;
struct acpi_video_device_brightness *brightness;
struct backlight_device *backlight;
- struct backlight_properties *data;
};
/* bus */
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
-------------------------------------------------------------------------- */
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;
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;
}
#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];
{
struct adb_request req;
unsigned long flags;
- int level = bd->props->brightness;
+ int level = bd->props.brightness;
spin_lock_irqsave(&pmu_backlight_lock, flags);
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) {
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
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 */
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);
*/
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
struct backlight_device *bd = asus_backlight_device;
if (bd) {
- bd->props->power = blank;
+ bd->props.power = blank;
backlight_update_status(bd);
}
}
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);
}
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");
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;
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;
/* 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;
int retval;
pdata->msgdata[0] = 0x10;
- pdata->msgdata[1] = bd->props->brightness;
+ pdata->msgdata[1] = bd->props.brightness;
retval = usb_control_msg(
pdata->udev,
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)
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)
goto error;
}
+ pdata->bd->props.max_brightness = 0xff;
+
/* Try to get brightness */
brightness = appledisplay_bl_get_brightness(pdata->bd);
}
/* 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);
#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)
{
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) {
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);
}
}
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);
#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);
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) {
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)
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);
#define MAX_RADEON_LEVEL 0xFF
-static struct backlight_properties radeon_bl_data;
-
struct radeon_bl_privdata {
struct radeonfb_info *rinfo;
uint8_t negative;
* 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();
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)
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);
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;
}
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)
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)
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,
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;
}
* 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.
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);
+ new_bd->ops = ops;
new_bd->class_dev.class = &backlight_class;
new_bd->class_dev.dev = dev;
strlcpy(new_bd->class_dev.class_id, name, KOBJ_NAME_LEN);
class_device_remove_file(&bd->class_dev,
&bl_class_device_attributes[i]);
- mutex_lock(&bd->props_lock);
- bd->props = NULL;
- mutex_unlock(&bd->props_lock);
+ mutex_lock(&bd->ops_lock);
+ bd->ops = NULL;
+ mutex_unlock(&bd->ops_lock);
backlight_unregister_fb(bd);
static int corgibl_send_intensity(struct backlight_device *bd)
{
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;
- if (bd->props->fb_blank != FB_BLANK_UNBLANK)
+ if (bd->props.fb_blank != FB_BLANK_UNBLANK)
intensity = 0;
if (corgibl_flags & CORGIBL_SUSPENDED)
intensity = 0;
EXPORT_SYMBOL(corgibl_limit_intensity);
-static struct backlight_properties corgibl_data = {
+static struct backlight_ops corgibl_ops = {
.get_brightness = corgibl_get_intensity,
.update_status = corgibl_send_intensity,
};
struct corgibl_machinfo *machinfo = pdev->dev.platform_data;
bl_machinfo = machinfo;
- corgibl_data.max_brightness = machinfo->max_intensity;
if (!machinfo->limit_mask)
machinfo->limit_mask = -1;
corgi_backlight_device = backlight_device_register ("corgi-bl",
- &pdev->dev, NULL, &corgibl_data);
+ &pdev->dev, NULL, &corgibl_ops);
if (IS_ERR (corgi_backlight_device))
return PTR_ERR (corgi_backlight_device);
platform_set_drvdata(pdev, corgi_backlight_device);
- corgibl_data.power = FB_BLANK_UNBLANK;
- corgibl_data.brightness = machinfo->default_intensity;
+ corgi_backlight_device->props.max_brightness = machinfo->max_intensity;
+ corgi_backlight_device->props.power = FB_BLANK_UNBLANK;
+ corgi_backlight_device->props.brightness = machinfo->default_intensity;
corgibl_send_intensity(corgi_backlight_device);
printk("Corgi Backlight Driver Initialized.\n");
{
unsigned long flags;
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;
- if (bd->props->fb_blank != FB_BLANK_UNBLANK)
+ if (bd->props.fb_blank != FB_BLANK_UNBLANK)
intensity = 0;
if (hp680bl_suspended)
intensity = 0;
return current_intensity;
}
-static struct backlight_properties hp680bl_data = {
- .max_brightness = HP680_MAX_INTENSITY,
+static struct backlight_ops hp680bl_ops = {
.get_brightness = hp680bl_get_intensity,
.update_status = hp680bl_set_intensity,
};
struct backlight_device *bd;
bd = backlight_device_register ("hp680-bl", &pdev->dev, NULL,
- &hp680bl_data);
+ &hp680bl_ops);
if (IS_ERR(bd))
return PTR_ERR(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);
return 0;
return 0;
ld = container_of(self, struct lcd_device, fb_notif);
- mutex_lock(&ld->props_lock);
- if (ld->props)
- if (!ld->props->check_fb || ld->props->check_fb(evdata->info))
- ld->props->set_power(ld, *(int *)evdata->data);
- mutex_unlock(&ld->props_lock);
+ mutex_lock(&ld->ops_lock);
+ if (ld->ops)
+ if (!ld->ops->check_fb || ld->ops->check_fb(evdata->info))
+ ld->ops->set_power(ld, *(int *)evdata->data);
+ mutex_unlock(&ld->ops_lock);
return 0;
}
int rc;
struct lcd_device *ld = to_lcd_device(cdev);
- mutex_lock(&ld->props_lock);
- if (ld->props && ld->props->get_power)
- rc = sprintf(buf, "%d\n", ld->props->get_power(ld));
+ mutex_lock(&ld->ops_lock);
+ if (ld->ops && ld->ops->get_power)
+ rc = sprintf(buf, "%d\n", ld->ops->get_power(ld));
else
rc = -ENXIO;
- mutex_unlock(&ld->props_lock);
+ mutex_unlock(&ld->ops_lock);
return rc;
}
if (size != count)
return -EINVAL;
- mutex_lock(&ld->props_lock);
- if (ld->props && ld->props->set_power) {
+ mutex_lock(&ld->ops_lock);
+ if (ld->ops && ld->ops->set_power) {
pr_debug("lcd: set power to %d\n", power);
- ld->props->set_power(ld, power);
+ ld->ops->set_power(ld, power);
rc = count;
}
- mutex_unlock(&ld->props_lock);
+ mutex_unlock(&ld->ops_lock);
return rc;
}
int rc = -ENXIO;
struct lcd_device *ld = to_lcd_device(cdev);
- mutex_lock(&ld->props_lock);
- if (ld->props && ld->props->get_contrast)
- rc = sprintf(buf, "%d\n", ld->props->get_contrast(ld));
- mutex_unlock(&ld->props_lock);
+ mutex_lock(&ld->ops_lock);
+ if (ld->ops && ld->ops->get_contrast)
+ rc = sprintf(buf, "%d\n", ld->ops->get_contrast(ld));
+ mutex_unlock(&ld->ops_lock);
return rc;
}
if (size != count)
return -EINVAL;
- mutex_lock(&ld->props_lock);
- if (ld->props && ld->props->set_contrast) {
+ mutex_lock(&ld->ops_lock);
+ if (ld->ops && ld->ops->set_contrast) {
pr_debug("lcd: set contrast to %d\n", contrast);
- ld->props->set_contrast(ld, contrast);
+ ld->ops->set_contrast(ld, contrast);
rc = count;
}
- mutex_unlock(&ld->props_lock);
+ mutex_unlock(&ld->ops_lock);
return rc;
}
static ssize_t lcd_show_max_contrast(struct class_device *cdev, char *buf)
{
- int rc = -ENXIO;
struct lcd_device *ld = to_lcd_device(cdev);
- mutex_lock(&ld->props_lock);
- if (ld->props)
- rc = sprintf(buf, "%d\n", ld->props->max_contrast);
- mutex_unlock(&ld->props_lock);
-
- return rc;
+ return sprintf(buf, "%d\n", ld->props.max_contrast);
}
static void lcd_class_release(struct class_device *dev)
* respective framebuffer device).
* @devdata: an optional pointer to be stored in the class_device. The
* 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()
* or a pointer to the newly allocated device.
*/
struct lcd_device *lcd_device_register(const char *name, void *devdata,
- struct lcd_properties *lp)
+ struct lcd_ops *ops)
{
int i, rc;
struct lcd_device *new_ld;
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)
return ERR_PTR(-ENOMEM);
- mutex_init(&new_ld->props_lock);
+ mutex_init(&new_ld->ops_lock);
mutex_init(&new_ld->update_lock);
- new_ld->props = lp;
- memset(&new_ld->class_dev, 0, sizeof(new_ld->class_dev));
+ new_ld->ops = ops;
new_ld->class_dev.class = &lcd_class;
strlcpy(new_ld->class_dev.class_id, name, KOBJ_NAME_LEN);
class_set_devdata(&new_ld->class_dev, devdata);
class_device_remove_file(&ld->class_dev,
&lcd_class_device_attributes[i]);
- mutex_lock(&ld->props_lock);
- ld->props = NULL;
- mutex_unlock(&ld->props_lock);
+ mutex_lock(&ld->ops_lock);
+ ld->ops = NULL;
+ mutex_unlock(&ld->ops_lock);
lcd_unregister_fb(ld);
class_device_unregister(&ld->class_dev);
}
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;
- if (bd->props->fb_blank != FB_BLANK_UNBLANK)
+ if (bd->props.fb_blank != FB_BLANK_UNBLANK)
intensity = 0;
if (locomolcd_flags & LOCOMOLCD_SUSPENDED)
intensity = 0;
return current_intensity;
}
-static struct backlight_properties locomobl_data = {
+static struct backlight_ops locomobl_data = {
.get_brightness = locomolcd_get_intensity,
.update_status = locomolcd_set_intensity,
- .max_brightness = 4,
};
#ifdef CONFIG_PM
return PTR_ERR (locomolcd_bl_device);
/* 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);
return 0;
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;
- if (bd->props->fb_blank != FB_BLANK_UNBLANK)
+ if (bd->props.fb_blank != FB_BLANK_UNBLANK)
intensity = 0;
pci_write_config_byte(pmu_dev, PMU_LPCR, 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,
.update_status = progearbl_set_intensity,
};
progear_backlight_device = backlight_device_register("progear-bl",
&pdev->dev, NULL,
- &progearbl_data);
+ &progearbl_ops);
if (IS_ERR(progear_backlight_device))
return PTR_ERR(progear_backlight_device);
platform_set_drvdata(pdev, progear_backlight_device);
- progearbl_data.power = FB_BLANK_UNBLANK;
- progearbl_data.brightness = HW_LEVEL_MAX - HW_LEVEL_MIN;
- progearbl_data.max_brightness = HW_LEVEL_MAX - HW_LEVEL_MIN;
+ progear_backlight_device->props.power = FB_BLANK_UNBLANK;
+ progear_backlight_device->props.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);
return 0;
/* turn on the backlight */
mutex_lock(&pmac_backlight_mutex);
if (pmac_backlight) {
- pmac_backlight->props->power = FB_BLANK_UNBLANK;
+ pmac_backlight->props.power = FB_BLANK_UNBLANK;
backlight_update_status(pmac_backlight);
}
mutex_unlock(&pmac_backlight_mutex);
if (!par->FlatPanel)
return 0;
- 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;
tmp_pmc = NV_RD32(par->PMC, 0x10F0) & 0x0000FFFF;
tmp_pcrt = NV_RD32(par->PCRTC0, 0x081C) & 0xFFFFFFFC;
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,
.update_status = nvidia_bl_update_status,
- .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
};
void nvidia_bl_init(struct nvidia_par *par)
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)) {
info->bl_dev = NULL;
printk(KERN_WARNING "nvidia: Backlight registration failed\n");
0x158 * FB_BACKLIGHT_MAX / MAX_LEVEL,
0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL);
- bd->props->brightness = nvidia_bl_data.max_brightness;
- bd->props->power = FB_BLANK_UNBLANK;
+ bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
+ bd->props.brightness = nvidia_bl_data.max_brightness;
+ bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd);
printk("nvidia: Backlight initialized (%s)\n", name);
U032 tmp_pcrt, tmp_pmc;
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;
tmp_pmc = par->riva.PMC[0x10F0/4] & 0x0000FFFF;
tmp_pcrt = par->riva.PCRTC0[0x081C/4] & 0xFFFFFFFC;
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,
.update_status = riva_bl_update_status,
- .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
};
static void riva_bl_init(struct riva_par *par)
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)) {
info->bl_dev = NULL;
printk(KERN_WARNING "riva: Backlight registration failed\n");
MIN_LEVEL * FB_BACKLIGHT_MAX / MAX_LEVEL,
FB_BACKLIGHT_MAX);
- bd->props->brightness = riva_bl_data.max_brightness;
- bd->props->power = FB_BLANK_UNBLANK;
+ bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
+ bd->props.brightness = riva_bl_data.max_brightness;
+ bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd);
printk("riva: Backlight initialized (%s)\n", name);
/* Notes on locking:
*
- * backlight_device->props_lock is an internal backlight lock protecting the
- * props field and no code outside the core should need to touch it.
+ * backlight_device->ops_lock is an internal backlight lock protecting the
+ * 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
* most drivers seem to need this and historically get it wrong.
struct backlight_device;
struct fb_info;
-/* This structure defines all the properties of a backlight
- (usually attached to a LCD). */
-struct backlight_properties {
+struct backlight_ops {
/* Notify the backlight driver some property has changed */
int (*update_status)(struct backlight_device *);
/* Return the current backlight brightness (accounting for power,
/* 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. */
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) */
int brightness;
/* Maximal value for brightness (read-only) */
};
struct backlight_device {
- /* This protects the 'props' field. If 'props' 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 props_lock;
- /* If this is NULL, the backing module is unloaded */
- struct backlight_properties *props;
+ /* Backlight properties */
+ struct backlight_properties props;
+
/* Serialise access to update_status method */
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 */
struct notifier_block fb_notif;
/* The class device structure */
static inline void backlight_update_status(struct backlight_device *bd)
{
mutex_lock(&bd->update_lock);
- if (bd->props && bd->props->update_status)
- bd->props->update_status(bd);
+ if (bd->ops && bd->ops->update_status)
+ bd->ops->update_status(bd);
mutex_unlock(&bd->update_lock);
}
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);
#define to_backlight_device(obj) container_of(obj, struct backlight_device, class_dev)
/* 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.
*
* Access to set_power() is serialised by the update_lock mutex since
struct lcd_device;
struct fb_info;
-/* This structure defines all the properties of a LCD flat panel. */
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
power on, flat panel power off, 4: full off), see FB_BLANK_XXX */
int (*get_power)(struct lcd_device *);
/* Enable or disable power to the LCD (0: on; 4: off, see FB_BLANK_XXX) */
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) */
int (*get_contrast)(struct lcd_device *);
/* Set LCD panel contrast */
};
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()
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 */
- struct lcd_properties *props;
+ struct lcd_ops *ops;
/* Serialise access to set_power method */
struct mutex update_lock;
/* The framebuffer notifier block */
static inline void lcd_set_power(struct lcd_device *ld, int power)
{
mutex_lock(&ld->update_lock);
- if (ld->props && ld->props->set_power)
- ld->props->set_power(ld, power);
+ if (ld->ops && ld->ops->set_power)
+ ld->ops->set_power(ld, power);
mutex_unlock(&ld->update_lock);
}
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);
#define to_lcd_device(obj) container_of(obj, struct lcd_device, class_dev)