[openwrt/openwrt] ath79: gpio-rb91x-key: use devm for mutex_init
LEDE Commits
lede-commits at lists.infradead.org
Tue Oct 8 10:35:59 PDT 2024
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/084665698b113811c8c9017631068dc3e452efa4
commit 084665698b113811c8c9017631068dc3e452efa4
Author: Rosen Penev <rosenp at gmail.com>
AuthorDate: Fri Oct 4 13:20:13 2024 -0700
ath79: gpio-rb91x-key: use devm for mutex_init
mutex_destroy is not called in any error paths or in _remove. Just use
devm to do so.
Removed a pointless platform_set_devdata call. Not needed with all of
the devm conversions.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
Link: https://github.com/openwrt/openwrt/pull/16630
Signed-off-by: Robert Marko <robimarko at gmail.com>
---
target/linux/ath79/files/drivers/gpio/gpio-rb91x-key.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/target/linux/ath79/files/drivers/gpio/gpio-rb91x-key.c b/target/linux/ath79/files/drivers/gpio/gpio-rb91x-key.c
index 4b21c93469..b2c8e63305 100644
--- a/target/linux/ath79/files/drivers/gpio/gpio-rb91x-key.c
+++ b/target/linux/ath79/files/drivers/gpio/gpio-rb91x-key.c
@@ -144,13 +144,19 @@ static int gpio_rb91x_key_probe(struct platform_device *pdev)
struct gpio_rb91x_key *drvdata;
struct gpio_chip *gc;
struct device *dev = &pdev->dev;
+ int err;
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
if (!drvdata)
return -ENOMEM;
- mutex_init(&drvdata->mutex);
- mutex_init(&drvdata->poll_mutex);
+ err = devm_mutex_init(dev, &drvdata->mutex);
+ if (err)
+ return err;
+
+ err = devm_mutex_init(dev, &drvdata->poll_mutex);
+ if (err)
+ return err;
drvdata->gpio = devm_gpiod_get(dev, NULL, GPIOD_OUT_LOW);
if (IS_ERR(drvdata->gpio))
@@ -167,8 +173,6 @@ static int gpio_rb91x_key_probe(struct platform_device *pdev)
gc->direction_output = gpio_rb91x_key_direction_output;
gc->direction_input = gpio_rb91x_key_direction_input;
- platform_set_drvdata(pdev, drvdata);
-
return devm_gpiochip_add_data(dev, gc, drvdata);
}
More information about the lede-commits
mailing list