Skip to content

Commit

Permalink
ath79: gpio-rb91x-key: use devm for mutex_init
Browse files Browse the repository at this point in the history
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 <[email protected]>
Link: openwrt/openwrt#16630
Signed-off-by: Robert Marko <[email protected]>
  • Loading branch information
neheb authored and robimarko committed Oct 8, 2024
1 parent a35bfa6 commit 0846656
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions target/linux/ath79/files/drivers/gpio/gpio-rb91x-key.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);
}

Expand Down

0 comments on commit 0846656

Please sign in to comment.