diff options
Diffstat (limited to 'drivers/video/backlight/hp680_bl.c')
| -rw-r--r-- | drivers/video/backlight/hp680_bl.c | 91 |
1 files changed, 49 insertions, 42 deletions
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c index fe1488374f6..8ea42b8d9bc 100644 --- a/drivers/video/backlight/hp680_bl.c +++ b/drivers/video/backlight/hp680_bl.c @@ -18,27 +18,26 @@ #include <linux/fb.h> #include <linux/backlight.h> -#include <asm/cpu/dac.h> -#include <asm/hp6xx/hp6xx.h> +#include <cpu/dac.h> +#include <mach/hp6xx.h> #include <asm/hd64461.h> #define HP680_MAX_INTENSITY 255 #define HP680_DEFAULT_INTENSITY 10 static int hp680bl_suspended; -static int current_intensity = 0; +static int current_intensity; static DEFINE_SPINLOCK(bl_lock); -static struct backlight_device *hp680_backlight_device; static void hp680bl_send_intensity(struct backlight_device *bd) { 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; @@ -65,25 +64,28 @@ static void hp680bl_send_intensity(struct backlight_device *bd) } -#ifdef CONFIG_PM -static int hp680bl_suspend(struct platform_device *dev, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int hp680bl_suspend(struct device *dev) { + struct backlight_device *bd = dev_get_drvdata(dev); + hp680bl_suspended = 1; - hp680bl_send_intensity(hp680_backlight_device); + hp680bl_send_intensity(bd); return 0; } -static int hp680bl_resume(struct platform_device *dev) +static int hp680bl_resume(struct device *dev) { + struct backlight_device *bd = dev_get_drvdata(dev); + hp680bl_suspended = 0; - hp680bl_send_intensity(hp680_backlight_device); + hp680bl_send_intensity(bd); return 0; } -#else -#define hp680bl_suspend NULL -#define hp680bl_resume NULL #endif +static SIMPLE_DEV_PM_OPS(hp680bl_pm_ops, hp680bl_suspend, hp680bl_resume); + static int hp680bl_set_intensity(struct backlight_device *bd) { hp680bl_send_intensity(bd); @@ -95,29 +97,39 @@ static int hp680bl_get_intensity(struct backlight_device *bd) return current_intensity; } -static struct backlight_properties hp680bl_data = { - .owner = THIS_MODULE, - .max_brightness = HP680_MAX_INTENSITY, +static const struct backlight_ops hp680bl_ops = { .get_brightness = hp680bl_get_intensity, .update_status = hp680bl_set_intensity, }; -static int __init hp680bl_probe(struct platform_device *dev) +static int hp680bl_probe(struct platform_device *pdev) { - hp680_backlight_device = backlight_device_register ("hp680-bl", - NULL, &hp680bl_data); - if (IS_ERR (hp680_backlight_device)) - return PTR_ERR (hp680_backlight_device); + struct backlight_properties props; + struct backlight_device *bd; + + memset(&props, 0, sizeof(struct backlight_properties)); + props.type = BACKLIGHT_RAW; + props.max_brightness = HP680_MAX_INTENSITY; + bd = devm_backlight_device_register(&pdev->dev, "hp680-bl", &pdev->dev, + NULL, &hp680bl_ops, &props); + if (IS_ERR(bd)) + return PTR_ERR(bd); - hp680_backlight_device->props->brightness = HP680_DEFAULT_INTENSITY; - hp680bl_send_intensity(hp680_backlight_device); + platform_set_drvdata(pdev, bd); + + bd->props.brightness = HP680_DEFAULT_INTENSITY; + hp680bl_send_intensity(bd); return 0; } -static int hp680bl_remove(struct platform_device *dev) +static int hp680bl_remove(struct platform_device *pdev) { - backlight_device_unregister(hp680_backlight_device); + struct backlight_device *bd = platform_get_drvdata(pdev); + + bd->props.brightness = 0; + bd->props.power = 0; + hp680bl_send_intensity(bd); return 0; } @@ -125,10 +137,9 @@ static int hp680bl_remove(struct platform_device *dev) static struct platform_driver hp680bl_driver = { .probe = hp680bl_probe, .remove = hp680bl_remove, - .suspend = hp680bl_suspend, - .resume = hp680bl_resume, .driver = { .name = "hp680-bl", + .pm = &hp680bl_pm_ops, }, }; @@ -139,25 +150,21 @@ static int __init hp680bl_init(void) int ret; ret = platform_driver_register(&hp680bl_driver); - if (!ret) { - hp680bl_device = platform_device_alloc("hp680-bl", -1); - if (!hp680bl_device) - return -ENOMEM; - - ret = platform_device_add(hp680bl_device); - - if (ret) { - platform_device_put(hp680bl_device); - platform_driver_unregister(&hp680bl_driver); - } + if (ret) + return ret; + hp680bl_device = platform_device_register_simple("hp680-bl", -1, + NULL, 0); + if (IS_ERR(hp680bl_device)) { + platform_driver_unregister(&hp680bl_driver); + return PTR_ERR(hp680bl_device); } - return ret; + return 0; } static void __exit hp680bl_exit(void) { platform_device_unregister(hp680bl_device); - platform_driver_unregister(&hp680bl_driver); + platform_driver_unregister(&hp680bl_driver); } module_init(hp680bl_init); |
