Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+24 -15
+24 -15
drivers/video/backlight/hp680_bl.c
··· 28 28 static int hp680bl_suspended; 29 29 static int current_intensity = 0; 30 30 static DEFINE_SPINLOCK(bl_lock); 31 - static struct backlight_device *hp680_backlight_device; 32 31 33 32 static void hp680bl_send_intensity(struct backlight_device *bd) 34 33 { ··· 65 66 66 67 67 68 #ifdef CONFIG_PM 68 - static int hp680bl_suspend(struct platform_device *dev, pm_message_t state) 69 + static int hp680bl_suspend(struct platform_device *pdev, pm_message_t state) 69 70 { 71 + struct backlight_device *bd = platform_get_drvdata(pdev); 72 + 70 73 hp680bl_suspended = 1; 71 - hp680bl_send_intensity(hp680_backlight_device); 74 + hp680bl_send_intensity(bd); 72 75 return 0; 73 76 } 74 77 75 - static int hp680bl_resume(struct platform_device *dev) 78 + static int hp680bl_resume(struct platform_device *pdev) 76 79 { 80 + struct backlight_device *bd = platform_get_drvdata(pdev); 81 + 77 82 hp680bl_suspended = 0; 78 - hp680bl_send_intensity(hp680_backlight_device); 83 + hp680bl_send_intensity(bd); 79 84 return 0; 80 85 } 81 86 #else ··· 104 101 .update_status = hp680bl_set_intensity, 105 102 }; 106 103 107 - static int __init hp680bl_probe(struct platform_device *dev) 104 + static int __init hp680bl_probe(struct platform_device *pdev) 108 105 { 109 - hp680_backlight_device = backlight_device_register ("hp680-bl", 110 - &dev->dev, NULL, &hp680bl_data); 111 - if (IS_ERR (hp680_backlight_device)) 112 - return PTR_ERR (hp680_backlight_device); 106 + struct backlight_device *bd; 113 107 114 - hp680_backlight_device->props->brightness = HP680_DEFAULT_INTENSITY; 115 - hp680bl_send_intensity(hp680_backlight_device); 108 + bd = backlight_device_register ("hp680-bl", &pdev->dev, NULL, 109 + &hp680bl_data); 110 + if (IS_ERR(bd)) 111 + return PTR_ERR(bd); 112 + 113 + platform_set_drvdata(pdev, bd); 114 + 115 + bd->props->brightness = HP680_DEFAULT_INTENSITY; 116 + hp680bl_send_intensity(bd); 116 117 117 118 return 0; 118 119 } 119 120 120 - static int hp680bl_remove(struct platform_device *dev) 121 + static int hp680bl_remove(struct platform_device *pdev) 121 122 { 123 + struct backlight_device *bd = platform_get_drvdata(pdev); 124 + 122 125 hp680bl_data.brightness = 0; 123 126 hp680bl_data.power = 0; 124 - hp680bl_send_intensity(hp680_backlight_device); 127 + hp680bl_send_intensity(bd); 125 128 126 - backlight_device_unregister(hp680_backlight_device); 129 + backlight_device_unregister(bd); 127 130 128 131 return 0; 129 132 }