@@ -93,8 +93,8 @@ static int pm8058_led_probe(struct platform_device *pdev)
93
93
struct device_node * np ;
94
94
int ret ;
95
95
struct regmap * map ;
96
- const char * state ;
97
96
enum led_brightness maxbright ;
97
+ enum led_default_state state ;
98
98
99
99
led = devm_kzalloc (dev , sizeof (* led ), GFP_KERNEL );
100
100
if (!led )
@@ -125,25 +125,26 @@ static int pm8058_led_probe(struct platform_device *pdev)
125
125
maxbright = 15 ; /* 4 bits */
126
126
led -> cdev .max_brightness = maxbright ;
127
127
128
- state = of_get_property (np , "default-state" , NULL );
129
- if (state ) {
130
- if (!strcmp (state , "keep" )) {
131
- led -> cdev .brightness = pm8058_led_get (& led -> cdev );
132
- } else if (!strcmp (state , "on" )) {
133
- led -> cdev .brightness = maxbright ;
134
- pm8058_led_set (& led -> cdev , maxbright );
135
- } else {
136
- led -> cdev .brightness = LED_OFF ;
137
- pm8058_led_set (& led -> cdev , LED_OFF );
138
- }
128
+ init_data .fwnode = of_fwnode_handle (np );
129
+
130
+ state = led_init_default_state_get (init_data .fwnode );
131
+ switch (state ) {
132
+ case LEDS_DEFSTATE_ON :
133
+ led -> cdev .brightness = maxbright ;
134
+ pm8058_led_set (& led -> cdev , maxbright );
135
+ break ;
136
+ case LEDS_DEFSTATE_KEEP :
137
+ led -> cdev .brightness = pm8058_led_get (& led -> cdev );
138
+ break ;
139
+ default :
140
+ led -> cdev .brightness = LED_OFF ;
141
+ pm8058_led_set (& led -> cdev , LED_OFF );
139
142
}
140
143
141
144
if (led -> ledtype == PM8058_LED_TYPE_KEYPAD ||
142
145
led -> ledtype == PM8058_LED_TYPE_FLASH )
143
146
led -> cdev .flags = LED_CORE_SUSPENDRESUME ;
144
147
145
- init_data .fwnode = of_fwnode_handle (np );
146
-
147
148
ret = devm_led_classdev_register_ext (dev , & led -> cdev , & init_data );
148
149
if (ret )
149
150
dev_err (dev , "Failed to register LED for %pOF\n" , np );
0 commit comments