@@ -29,12 +29,12 @@ struct rt8555_priv {
29
29
static int rt8555_bl_update_status (struct backlight_device * bl_dev )
30
30
{
31
31
struct rt8555_priv * priv = bl_get_data (bl_dev );
32
- unsigned int brightness = min (backlight_get_brightness (bl_dev ), RT8555_MAX_BRIGHTNESS );
32
+ unsigned int brightness = min (backlight_get_brightness (bl_dev ), priv -> bl -> props . max_brightness );
33
33
int ret ;
34
34
35
35
/* Enable the IC before setting the brightness */
36
36
if (brightness )
37
- if (!IS_ERR (priv -> enable ))
37
+ if (!IS_ERR_OR_NULL (priv -> enable ))
38
38
gpiod_set_value (priv -> enable , 1 );
39
39
40
40
@@ -48,7 +48,7 @@ static int rt8555_bl_update_status(struct backlight_device *bl_dev)
48
48
49
49
/* Disable the IC after setting it to 0 */
50
50
if (brightness == 0 )
51
- if (!IS_ERR (priv -> enable ))
51
+ if (!IS_ERR_OR_NULL (priv -> enable ))
52
52
gpiod_set_value (priv -> enable , 0 );
53
53
54
54
return 0 ;
@@ -61,7 +61,7 @@ static int rt8555_bl_get_brightness(struct backlight_device *bl_dev)
61
61
62
62
/* If the RT8555 is disabled, there's no reason to turn it on just to read
63
63
* it back */
64
- if (!IS_ERR (priv -> enable ))
64
+ if (!IS_ERR_OR_NULL (priv -> enable ))
65
65
if (gpiod_get_value (priv -> enable ) == 0 )
66
66
return 0 ;
67
67
@@ -103,9 +103,15 @@ static int rt8555_bl_probe(struct i2c_client *client)
103
103
priv -> dev = & client -> dev ;
104
104
105
105
priv -> enable = devm_gpiod_get_optional (& client -> dev , NULL , GPIOD_OUT_HIGH );
106
- if (!IS_ERR (priv -> enable ))
106
+ if (!IS_ERR_OR_NULL (priv -> enable ))
107
107
gpiod_set_value (priv -> enable , 1 );
108
108
109
+ priv -> regmap = devm_regmap_init_i2c (client , & rt8555_regmap_config );
110
+ if (!priv -> regmap ) {
111
+ dev_err (& client -> dev , "Failed to init regmap\n" );
112
+ return - ENODEV ;
113
+ }
114
+
109
115
ret = device_property_read_u32 (& client -> dev , "max-brightness" , & brightness );
110
116
if (ret )
111
117
brightness = RT8555_MAX_BRIGHTNESS ;
@@ -144,7 +150,7 @@ static void rt8555_bl_remove(struct i2c_client *client)
144
150
bl_dev -> props .brightness = 0 ;
145
151
backlight_update_status (priv -> bl );
146
152
147
- if (!IS_ERR (priv -> enable ))
153
+ if (!IS_ERR_OR_NULL (priv -> enable ))
148
154
gpiod_set_value (priv -> enable , 0 );
149
155
}
150
156
0 commit comments