22/*
33 * Copyright (C) 2021 Rafał Miłecki <[email protected] > 44 */
5+ #include <linux/cleanup.h>
56#include <linux/delay.h>
67#include <linux/io.h>
78#include <linux/leds.h>
@@ -125,17 +126,14 @@ static void bcm63138_leds_brightness_set(struct led_classdev *led_cdev,
125126{
126127 struct bcm63138_led * led = container_of (led_cdev , struct bcm63138_led , cdev );
127128 struct bcm63138_leds * leds = led -> leds ;
128- unsigned long flags ;
129129
130- spin_lock_irqsave ( & leds -> lock , flags );
130+ guard ( spinlock_irqsave )( & leds -> lock );
131131
132132 bcm63138_leds_enable_led (leds , led , value );
133133 if (!value )
134134 bcm63138_leds_set_flash_rate (leds , led , 0 );
135135 else
136136 bcm63138_leds_set_bright (leds , led , value );
137-
138- spin_unlock_irqrestore (& leds -> lock , flags );
139137}
140138
141139static int bcm63138_leds_blink_set (struct led_classdev * led_cdev ,
@@ -144,7 +142,6 @@ static int bcm63138_leds_blink_set(struct led_classdev *led_cdev,
144142{
145143 struct bcm63138_led * led = container_of (led_cdev , struct bcm63138_led , cdev );
146144 struct bcm63138_leds * leds = led -> leds ;
147- unsigned long flags ;
148145 u8 value ;
149146
150147 if (!* delay_on && !* delay_off ) {
@@ -179,13 +176,11 @@ static int bcm63138_leds_blink_set(struct led_classdev *led_cdev,
179176 return - EINVAL ;
180177 }
181178
182- spin_lock_irqsave ( & leds -> lock , flags );
179+ guard ( spinlock_irqsave )( & leds -> lock );
183180
184181 bcm63138_leds_enable_led (leds , led , BCM63138_MAX_BRIGHTNESS );
185182 bcm63138_leds_set_flash_rate (leds , led , value );
186183
187- spin_unlock_irqrestore (& leds -> lock , flags );
188-
189184 return 0 ;
190185}
191186
@@ -259,7 +254,6 @@ static int bcm63138_leds_probe(struct platform_device *pdev)
259254 struct device_node * np = dev_of_node (& pdev -> dev );
260255 struct device * dev = & pdev -> dev ;
261256 struct bcm63138_leds * leds ;
262- struct device_node * child ;
263257
264258 leds = devm_kzalloc (dev , sizeof (* leds ), GFP_KERNEL );
265259 if (!leds )
@@ -280,7 +274,7 @@ static int bcm63138_leds_probe(struct platform_device *pdev)
280274 bcm63138_leds_write (leds , BCM63138_SERIAL_LED_POLARITY , 0 );
281275 bcm63138_leds_write (leds , BCM63138_PARALLEL_LED_POLARITY , 0 );
282276
283- for_each_available_child_of_node (np , child ) {
277+ for_each_available_child_of_node_scoped (np , child ) {
284278 bcm63138_leds_create_led (leds , child );
285279 }
286280
0 commit comments