diff options
| author | Richard Purdie <rpurdie@rpsys.net> | 2007-02-07 19:33:24 -0500 |
|---|---|---|
| committer | Richard Purdie <rpurdie@rpsys.net> | 2007-02-20 03:38:44 -0500 |
| commit | a8db3c1948eb30cd6988b5b96b654f591e6280b1 (patch) | |
| tree | b1950b1bd1f72a6b67c927cf14e7112fd6628be9 /drivers/video/backlight | |
| parent | da7a747125ff80e13c00b231602e7c86b6bb8741 (diff) | |
backlight: Minor code cleanups for hp680_bl.c
Since people use this code as an example, clean it up to
to use platform_*_drvdata instead of a global variable.
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Diffstat (limited to 'drivers/video/backlight')
| -rw-r--r-- | drivers/video/backlight/hp680_bl.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c index 074625a46e3d..e7444c8f289d 100644 --- a/drivers/video/backlight/hp680_bl.c +++ b/drivers/video/backlight/hp680_bl.c | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | static int hp680bl_suspended; | 28 | static int hp680bl_suspended; |
| 29 | static int current_intensity = 0; | 29 | static int current_intensity = 0; |
| 30 | static DEFINE_SPINLOCK(bl_lock); | 30 | static DEFINE_SPINLOCK(bl_lock); |
| 31 | static struct backlight_device *hp680_backlight_device; | ||
| 32 | 31 | ||
| 33 | static void hp680bl_send_intensity(struct backlight_device *bd) | 32 | static void hp680bl_send_intensity(struct backlight_device *bd) |
| 34 | { | 33 | { |
| @@ -66,17 +65,21 @@ static void hp680bl_send_intensity(struct backlight_device *bd) | |||
| 66 | 65 | ||
| 67 | 66 | ||
| 68 | #ifdef CONFIG_PM | 67 | #ifdef CONFIG_PM |
| 69 | static int hp680bl_suspend(struct platform_device *dev, pm_message_t state) | 68 | static int hp680bl_suspend(struct platform_device *pdev, pm_message_t state) |
| 70 | { | 69 | { |
| 70 | struct backlight_device *bd = platform_get_drvdata(pdev); | ||
| 71 | |||
| 71 | hp680bl_suspended = 1; | 72 | hp680bl_suspended = 1; |
| 72 | hp680bl_send_intensity(hp680_backlight_device); | 73 | hp680bl_send_intensity(bd); |
| 73 | return 0; | 74 | return 0; |
| 74 | } | 75 | } |
| 75 | 76 | ||
| 76 | static int hp680bl_resume(struct platform_device *dev) | 77 | static int hp680bl_resume(struct platform_device *pdev) |
| 77 | { | 78 | { |
| 79 | struct backlight_device *bd = platform_get_drvdata(pdev); | ||
| 80 | |||
| 78 | hp680bl_suspended = 0; | 81 | hp680bl_suspended = 0; |
| 79 | hp680bl_send_intensity(hp680_backlight_device); | 82 | hp680bl_send_intensity(bd); |
| 80 | return 0; | 83 | return 0; |
| 81 | } | 84 | } |
| 82 | #else | 85 | #else |
| @@ -101,26 +104,32 @@ static struct backlight_properties hp680bl_data = { | |||
| 101 | .update_status = hp680bl_set_intensity, | 104 | .update_status = hp680bl_set_intensity, |
| 102 | }; | 105 | }; |
| 103 | 106 | ||
| 104 | static int __init hp680bl_probe(struct platform_device *dev) | 107 | static int __init hp680bl_probe(struct platform_device *pdev) |
| 105 | { | 108 | { |
| 106 | hp680_backlight_device = backlight_device_register ("hp680-bl", | 109 | struct backlight_device *bd; |
| 107 | &dev->dev, NULL, &hp680bl_data); | 110 | |
| 108 | if (IS_ERR (hp680_backlight_device)) | 111 | bd = backlight_device_register ("hp680-bl", &pdev->dev, NULL, |
| 109 | return PTR_ERR (hp680_backlight_device); | 112 | &hp680bl_data); |
| 113 | if (IS_ERR(bd)) | ||
| 114 | return PTR_ERR(bd); | ||
| 110 | 115 | ||
| 111 | hp680_backlight_device->props->brightness = HP680_DEFAULT_INTENSITY; | 116 | platform_set_drvdata(pdev, bd); |
| 112 | hp680bl_send_intensity(hp680_backlight_device); | 117 | |
| 118 | bd->props->brightness = HP680_DEFAULT_INTENSITY; | ||
| 119 | hp680bl_send_intensity(bd); | ||
| 113 | 120 | ||
| 114 | return 0; | 121 | return 0; |
| 115 | } | 122 | } |
| 116 | 123 | ||
| 117 | static int hp680bl_remove(struct platform_device *dev) | 124 | static int hp680bl_remove(struct platform_device *pdev) |
| 118 | { | 125 | { |
| 126 | struct backlight_device *bd = platform_get_drvdata(pdev); | ||
| 127 | |||
| 119 | hp680bl_data.brightness = 0; | 128 | hp680bl_data.brightness = 0; |
| 120 | hp680bl_data.power = 0; | 129 | hp680bl_data.power = 0; |
| 121 | hp680bl_send_intensity(hp680_backlight_device); | 130 | hp680bl_send_intensity(bd); |
| 122 | 131 | ||
| 123 | backlight_device_unregister(hp680_backlight_device); | 132 | backlight_device_unregister(bd); |
| 124 | 133 | ||
| 125 | return 0; | 134 | return 0; |
| 126 | } | 135 | } |
