@@ -61,7 +61,8 @@ static int syscon_led_probe(struct platform_device *pdev)
61
61
struct device * parent ;
62
62
struct regmap * map ;
63
63
struct syscon_led * sled ;
64
- const char * state ;
64
+ enum led_default_state state ;
65
+ u32 value ;
65
66
int ret ;
66
67
67
68
parent = dev -> parent ;
@@ -86,34 +87,30 @@ static int syscon_led_probe(struct platform_device *pdev)
86
87
if (of_property_read_u32 (np , "mask" , & sled -> mask ))
87
88
return - EINVAL ;
88
89
89
- state = of_get_property (np , "default-state" , NULL );
90
- if (state ) {
91
- if (!strcmp (state , "keep" )) {
92
- u32 val ;
93
-
94
- ret = regmap_read (map , sled -> offset , & val );
95
- if (ret < 0 )
96
- return ret ;
97
- sled -> state = !!(val & sled -> mask );
98
- } else if (!strcmp (state , "on" )) {
99
- sled -> state = true;
100
- ret = regmap_update_bits (map , sled -> offset ,
101
- sled -> mask ,
102
- sled -> mask );
103
- if (ret < 0 )
104
- return ret ;
105
- } else {
106
- sled -> state = false;
107
- ret = regmap_update_bits (map , sled -> offset ,
108
- sled -> mask , 0 );
109
- if (ret < 0 )
110
- return ret ;
111
- }
90
+ init_data .fwnode = of_fwnode_handle (np );
91
+
92
+ state = led_init_default_state_get (init_data .fwnode );
93
+ switch (state ) {
94
+ case LEDS_DEFSTATE_ON :
95
+ ret = regmap_update_bits (map , sled -> offset , sled -> mask , sled -> mask );
96
+ if (ret < 0 )
97
+ return ret ;
98
+ sled -> state = true;
99
+ break ;
100
+ case LEDS_DEFSTATE_KEEP :
101
+ ret = regmap_read (map , sled -> offset , & value );
102
+ if (ret < 0 )
103
+ return ret ;
104
+ sled -> state = !!(value & sled -> mask );
105
+ break ;
106
+ default :
107
+ ret = regmap_update_bits (map , sled -> offset , sled -> mask , 0 );
108
+ if (ret < 0 )
109
+ return ret ;
110
+ sled -> state = false;
112
111
}
113
112
sled -> cdev .brightness_set = syscon_led_set ;
114
113
115
- init_data .fwnode = of_fwnode_handle (np );
116
-
117
114
ret = devm_led_classdev_register_ext (dev , & sled -> cdev , & init_data );
118
115
if (ret < 0 )
119
116
return ret ;
0 commit comments