ath79: rb91x-key: use more devm
Use devm_gpiochip_add_data to get rid of the remove function. No need for it. Also use dev_err_probe to simplify the error path and avoid having to handle -EPROBE_DEFER manually. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://github.com/openwrt/openwrt/pull/16506 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
parent
c38f04a092
commit
dedeb28755
@ -145,7 +145,6 @@ static int gpio_rb91x_key_probe(struct platform_device *pdev)
|
|||||||
struct gpio_chip *gc;
|
struct gpio_chip *gc;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct fwnode_handle *fwnode = dev->fwnode;
|
struct fwnode_handle *fwnode = dev->fwnode;
|
||||||
int r;
|
|
||||||
|
|
||||||
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
||||||
if (!drvdata)
|
if (!drvdata)
|
||||||
@ -155,13 +154,8 @@ static int gpio_rb91x_key_probe(struct platform_device *pdev)
|
|||||||
mutex_init(&drvdata->poll_mutex);
|
mutex_init(&drvdata->poll_mutex);
|
||||||
|
|
||||||
drvdata->gpio = devm_gpiod_get(dev, NULL, GPIOD_OUT_LOW);
|
drvdata->gpio = devm_gpiod_get(dev, NULL, GPIOD_OUT_LOW);
|
||||||
if (IS_ERR(drvdata->gpio)) {
|
if (IS_ERR(drvdata->gpio))
|
||||||
if (PTR_ERR(drvdata->gpio) != -EPROBE_DEFER) {
|
return dev_err_probe(dev, PTR_ERR(drvdata->gpio), "failed to get gpio");
|
||||||
dev_err(dev, "failed to get gpio: %ld\n",
|
|
||||||
PTR_ERR(drvdata->gpio));
|
|
||||||
}
|
|
||||||
return PTR_ERR(drvdata->gpio);
|
|
||||||
}
|
|
||||||
|
|
||||||
gc = &drvdata->gc;
|
gc = &drvdata->gc;
|
||||||
gc->label = GPIO_RB91X_KEY_DRIVER_NAME;
|
gc->label = GPIO_RB91X_KEY_DRIVER_NAME;
|
||||||
@ -176,21 +170,7 @@ static int gpio_rb91x_key_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
platform_set_drvdata(pdev, drvdata);
|
platform_set_drvdata(pdev, drvdata);
|
||||||
|
|
||||||
r = gpiochip_add(&drvdata->gc);
|
return devm_gpiochip_add_data(dev, gc, drvdata);
|
||||||
if (r) {
|
|
||||||
dev_err(dev, "gpiochip_add() failed: %d\n", r);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int gpio_rb91x_key_remove(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
struct gpio_rb91x_key *drvdata = platform_get_drvdata(pdev);
|
|
||||||
|
|
||||||
gpiochip_remove(&drvdata->gc);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id gpio_rb91x_key_match[] = {
|
static const struct of_device_id gpio_rb91x_key_match[] = {
|
||||||
@ -202,7 +182,6 @@ MODULE_DEVICE_TABLE(of, gpio_rb91x_key_match);
|
|||||||
|
|
||||||
static struct platform_driver gpio_rb91x_key_driver = {
|
static struct platform_driver gpio_rb91x_key_driver = {
|
||||||
.probe = gpio_rb91x_key_probe,
|
.probe = gpio_rb91x_key_probe,
|
||||||
.remove = gpio_rb91x_key_remove,
|
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = GPIO_RB91X_KEY_DRIVER_NAME,
|
.name = GPIO_RB91X_KEY_DRIVER_NAME,
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user