2828static int hp680bl_suspended ;
2929static int current_intensity = 0 ;
3030static DEFINE_SPINLOCK (bl_lock );
31- static struct backlight_device * hp680_backlight_device ;
3231
3332static void hp680bl_send_intensity (struct backlight_device * bd )
3433{
@@ -66,17 +65,21 @@ static void hp680bl_send_intensity(struct backlight_device *bd)
6665
6766
6867#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 )
7069{
70+ struct backlight_device * bd = platform_get_drvdata (pdev );
71+
7172 hp680bl_suspended = 1 ;
72- hp680bl_send_intensity (hp680_backlight_device );
73+ hp680bl_send_intensity (bd );
7374 return 0 ;
7475}
7576
76- static int hp680bl_resume (struct platform_device * dev )
77+ static int hp680bl_resume (struct platform_device * pdev )
7778{
79+ struct backlight_device * bd = platform_get_drvdata (pdev );
80+
7881 hp680bl_suspended = 0 ;
79- hp680bl_send_intensity (hp680_backlight_device );
82+ hp680bl_send_intensity (bd );
8083 return 0 ;
8184}
8285#else
@@ -101,26 +104,32 @@ static struct backlight_properties hp680bl_data = {
101104 .update_status = hp680bl_set_intensity ,
102105};
103106
104- static int __init hp680bl_probe (struct platform_device * dev )
107+ static int __init hp680bl_probe (struct platform_device * pdev )
105108{
106- hp680_backlight_device = backlight_device_register ("hp680-bl" ,
107- & dev -> dev , NULL , & hp680bl_data );
108- if (IS_ERR (hp680_backlight_device ))
109- return PTR_ERR (hp680_backlight_device );
109+ struct backlight_device * bd ;
110+
111+ bd = backlight_device_register ("hp680-bl" , & pdev -> dev , NULL ,
112+ & hp680bl_data );
113+ if (IS_ERR (bd ))
114+ return PTR_ERR (bd );
110115
111- hp680_backlight_device -> props -> brightness = HP680_DEFAULT_INTENSITY ;
112- hp680bl_send_intensity (hp680_backlight_device );
116+ platform_set_drvdata (pdev , bd );
117+
118+ bd -> props -> brightness = HP680_DEFAULT_INTENSITY ;
119+ hp680bl_send_intensity (bd );
113120
114121 return 0 ;
115122}
116123
117- static int hp680bl_remove (struct platform_device * dev )
124+ static int hp680bl_remove (struct platform_device * pdev )
118125{
126+ struct backlight_device * bd = platform_get_drvdata (pdev );
127+
119128 hp680bl_data .brightness = 0 ;
120129 hp680bl_data .power = 0 ;
121- hp680bl_send_intensity (hp680_backlight_device );
130+ hp680bl_send_intensity (bd );
122131
123- backlight_device_unregister (hp680_backlight_device );
132+ backlight_device_unregister (bd );
124133
125134 return 0 ;
126135}
0 commit comments