@@ -527,7 +527,6 @@ static int mt6323_led_probe(struct platform_device *pdev)
527527{
528528 struct device * dev = & pdev -> dev ;
529529 struct device_node * np = dev_of_node (dev );
530- struct device_node * child ;
531530 struct mt6397_chip * hw = dev_get_drvdata (dev -> parent );
532531 struct mt6323_leds * leds ;
533532 struct mt6323_led * led ;
@@ -565,28 +564,25 @@ static int mt6323_led_probe(struct platform_device *pdev)
565564 return ret ;
566565 }
567566
568- for_each_available_child_of_node (np , child ) {
567+ for_each_available_child_of_node_scoped (np , child ) {
569568 struct led_init_data init_data = {};
570569 bool is_wled ;
571570
572571 ret = of_property_read_u32 (child , "reg" , & reg );
573572 if (ret ) {
574573 dev_err (dev , "Failed to read led 'reg' property\n" );
575- goto put_child_node ;
574+ return ret ;
576575 }
577576
578577 if (reg >= max_leds || reg >= MAX_SUPPORTED_LEDS ||
579578 leds -> led [reg ]) {
580579 dev_err (dev , "Invalid led reg %u\n" , reg );
581- ret = - EINVAL ;
582- goto put_child_node ;
580+ return - EINVAL ;
583581 }
584582
585583 led = devm_kzalloc (dev , sizeof (* led ), GFP_KERNEL );
586- if (!led ) {
587- ret = - ENOMEM ;
588- goto put_child_node ;
589- }
584+ if (!led )
585+ return - ENOMEM ;
590586
591587 is_wled = of_property_read_bool (child , "mediatek,is-wled" );
592588
@@ -612,7 +608,7 @@ static int mt6323_led_probe(struct platform_device *pdev)
612608 if (ret < 0 ) {
613609 dev_err (leds -> dev ,
614610 "Failed to LED set default from devicetree\n" );
615- goto put_child_node ;
611+ return ret ;
616612 }
617613
618614 init_data .fwnode = of_fwnode_handle (child );
@@ -621,15 +617,11 @@ static int mt6323_led_probe(struct platform_device *pdev)
621617 & init_data );
622618 if (ret ) {
623619 dev_err (dev , "Failed to register LED: %d\n" , ret );
624- goto put_child_node ;
620+ return ret ;
625621 }
626622 }
627623
628624 return 0 ;
629-
630- put_child_node :
631- of_node_put (child );
632- return ret ;
633625}
634626
635627static void mt6323_led_remove (struct platform_device * pdev )
0 commit comments