6
6
7
7
*/
8
8
9
+ #include <linux/cleanup.h>
9
10
#include <linux/err.h>
10
11
#include <linux/gpio/consumer.h>
11
12
#include <linux/leds-expresswire.h>
@@ -208,7 +209,6 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
208
209
struct ktd2692_led_config_data * cfg )
209
210
{
210
211
struct device_node * np = dev_of_node (dev );
211
- struct device_node * child_node ;
212
212
int ret ;
213
213
214
214
if (!np )
@@ -239,7 +239,8 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
239
239
}
240
240
}
241
241
242
- child_node = of_get_next_available_child (np , NULL );
242
+ struct device_node * child_node __free (device_node ) =
243
+ of_get_next_available_child (np , NULL );
243
244
if (!child_node ) {
244
245
dev_err (dev , "No DT child node found for connected LED.\n" );
245
246
return - EINVAL ;
@@ -252,26 +253,24 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
252
253
& cfg -> movie_max_microamp );
253
254
if (ret ) {
254
255
dev_err (dev , "failed to parse led-max-microamp\n" );
255
- goto err_parse_dt ;
256
+ return ret ;
256
257
}
257
258
258
259
ret = of_property_read_u32 (child_node , "flash-max-microamp" ,
259
260
& cfg -> flash_max_microamp );
260
261
if (ret ) {
261
262
dev_err (dev , "failed to parse flash-max-microamp\n" );
262
- goto err_parse_dt ;
263
+ return ret ;
263
264
}
264
265
265
266
ret = of_property_read_u32 (child_node , "flash-max-timeout-us" ,
266
267
& cfg -> flash_max_timeout );
267
268
if (ret ) {
268
269
dev_err (dev , "failed to parse flash-max-timeout-us\n" );
269
- goto err_parse_dt ;
270
+ return ret ;
270
271
}
271
272
272
- err_parse_dt :
273
- of_node_put (child_node );
274
- return ret ;
273
+ return 0 ;
275
274
}
276
275
277
276
static const struct led_flash_ops flash_ops = {
0 commit comments