From: Rosen Penev Date: Fri, 2 Aug 2024 22:13:43 +0000 (-0700) Subject: kernel: leds-ws2812b: use devm functions X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=63a92188fb3b044991f990484432ef4372040eb5;p=openwrt%2Fstaging%2Fstintel.git kernel: leds-ws2812b: use devm functions Avoids having to free manually. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/16587 Signed-off-by: Robert Marko --- diff --git a/package/kernel/leds-ws2812b/src/leds-ws2812b.c b/package/kernel/leds-ws2812b/src/leds-ws2812b.c index 0dba128c1f..69bc575ba2 100644 --- a/package/kernel/leds-ws2812b/src/leds-ws2812b.c +++ b/package/kernel/leds-ws2812b/src/leds-ws2812b.c @@ -117,7 +117,7 @@ static int ws2812b_probe(struct spi_device *spi) priv->data_len = num_leds * WS2812B_BYTES_PER_COLOR * WS2812B_NUM_COLORS + WS2812B_RESET_LEN; - priv->data_buf = kzalloc(priv->data_len, GFP_KERNEL); + priv->data_buf = devm_kzalloc(dev, priv->data_len, GFP_KERNEL); if (!priv->data_buf) return -ENOMEM; @@ -171,7 +171,7 @@ static int ws2812b_probe(struct spi_device *spi) priv->leds[cur_led].cascade = cascade; - ret = led_classdev_multicolor_register_ext( + ret = devm_led_classdev_multicolor_register_ext( dev, &priv->leds[cur_led].mc_cdev, &init_data); if (ret) { dev_err(dev, "registration of %s failed.", @@ -185,10 +185,7 @@ static int ws2812b_probe(struct spi_device *spi) return 0; ERR_UNREG_LEDS: - for (; cur_led >= 0; cur_led--) - led_classdev_multicolor_unregister(&priv->leds[cur_led].mc_cdev); mutex_destroy(&priv->mutex); - kfree(priv->data_buf); return ret; } @@ -199,11 +196,7 @@ static int ws2812b_remove(struct spi_device *spi) #endif { struct ws2812b_priv *priv = spi_get_drvdata(spi); - int cur_led; - for (cur_led = priv->num_leds - 1; cur_led >= 0; cur_led--) - led_classdev_multicolor_unregister(&priv->leds[cur_led].mc_cdev); - kfree(priv->data_buf); mutex_destroy(&priv->mutex); #if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)