@@ -96,7 +96,8 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
96
96
{
97
97
struct led_init_data init_data = {};
98
98
struct bcm6358_led * led ;
99
- const char * state ;
99
+ enum led_default_state state ;
100
+ unsigned long val ;
100
101
int rc ;
101
102
102
103
led = devm_kzalloc (dev , sizeof (* led ), GFP_KERNEL );
@@ -110,29 +111,28 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
110
111
if (of_property_read_bool (nc , "active-low" ))
111
112
led -> active_low = true;
112
113
113
- if (!of_property_read_string (nc , "default-state" , & state )) {
114
- if (!strcmp (state , "on" )) {
114
+ init_data .fwnode = of_fwnode_handle (nc );
115
+
116
+ state = led_init_default_state_get (init_data .fwnode );
117
+ switch (state ) {
118
+ case LEDS_DEFSTATE_ON :
119
+ led -> cdev .brightness = LED_FULL ;
120
+ break ;
121
+ case LEDS_DEFSTATE_KEEP :
122
+ val = bcm6358_led_read (led -> mem + BCM6358_REG_MODE );
123
+ val &= BIT (led -> pin );
124
+ if ((led -> active_low && !val ) || (!led -> active_low && val ))
115
125
led -> cdev .brightness = LED_FULL ;
116
- } else if (!strcmp (state , "keep" )) {
117
- unsigned long val ;
118
- val = bcm6358_led_read (led -> mem + BCM6358_REG_MODE );
119
- val &= BIT (led -> pin );
120
- if ((led -> active_low && !val ) ||
121
- (!led -> active_low && val ))
122
- led -> cdev .brightness = LED_FULL ;
123
- else
124
- led -> cdev .brightness = LED_OFF ;
125
- } else {
126
+ else
126
127
led -> cdev .brightness = LED_OFF ;
127
- }
128
- } else {
128
+ break ;
129
+ default :
129
130
led -> cdev .brightness = LED_OFF ;
130
131
}
131
132
132
133
bcm6358_led_set (& led -> cdev , led -> cdev .brightness );
133
134
134
135
led -> cdev .brightness_set = bcm6358_led_set ;
135
- init_data .fwnode = of_fwnode_handle (nc );
136
136
137
137
rc = devm_led_classdev_register_ext (dev , & led -> cdev , & init_data );
138
138
if (rc < 0 )
0 commit comments