/*
  * Copyright (C) 2021 Rafał Miłecki <rafal@milecki.pl>
  */
+#include <linux/cleanup.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/leds.h>
 {
        struct bcm63138_led *led = container_of(led_cdev, struct bcm63138_led, cdev);
        struct bcm63138_leds *leds = led->leds;
-       unsigned long flags;
 
-       spin_lock_irqsave(&leds->lock, flags);
+       guard(spinlock_irqsave)(&leds->lock);
 
        bcm63138_leds_enable_led(leds, led, value);
        if (!value)
                bcm63138_leds_set_flash_rate(leds, led, 0);
        else
                bcm63138_leds_set_bright(leds, led, value);
-
-       spin_unlock_irqrestore(&leds->lock, flags);
 }
 
 static int bcm63138_leds_blink_set(struct led_classdev *led_cdev,
 {
        struct bcm63138_led *led = container_of(led_cdev, struct bcm63138_led, cdev);
        struct bcm63138_leds *leds = led->leds;
-       unsigned long flags;
        u8 value;
 
        if (!*delay_on && !*delay_off) {
                return -EINVAL;
        }
 
-       spin_lock_irqsave(&leds->lock, flags);
+       guard(spinlock_irqsave)(&leds->lock);
 
        bcm63138_leds_enable_led(leds, led, BCM63138_MAX_BRIGHTNESS);
        bcm63138_leds_set_flash_rate(leds, led, value);
 
-       spin_unlock_irqrestore(&leds->lock, flags);
-
        return 0;
 }
 
        struct device_node *np = dev_of_node(&pdev->dev);
        struct device *dev = &pdev->dev;
        struct bcm63138_leds *leds;
-       struct device_node *child;
 
        leds = devm_kzalloc(dev, sizeof(*leds), GFP_KERNEL);
        if (!leds)
        bcm63138_leds_write(leds, BCM63138_SERIAL_LED_POLARITY, 0);
        bcm63138_leds_write(leds, BCM63138_PARALLEL_LED_POLARITY, 0);
 
-       for_each_available_child_of_node(np, child) {
+       for_each_available_child_of_node_scoped(np, child) {
                bcm63138_leds_create_led(leds, child);
        }