mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:38:03 +00:00
gpio: menz127: simplify error path and remove remove()
Use devres to drop all goto labels from probe() and remove the driver remove() callback. While at it: drop the unnecessary dev_info() message as not only should the driver be quiet when successful, the message is also wrong: the device was probed at this point, the driver had been registered earlier. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20241014092227.78886-1-brgl@bgdev.pl Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
9a94580120
commit
3bd13ae04c
@ -127,6 +127,13 @@ static int men_z127_set_config(struct gpio_chip *gc, unsigned offset,
|
|||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void men_z127_release_mem(void *data)
|
||||||
|
{
|
||||||
|
struct resource *res = data;
|
||||||
|
|
||||||
|
mcb_release_mem(res);
|
||||||
|
}
|
||||||
|
|
||||||
static int men_z127_probe(struct mcb_device *mdev,
|
static int men_z127_probe(struct mcb_device *mdev,
|
||||||
const struct mcb_device_id *id)
|
const struct mcb_device_id *id)
|
||||||
{
|
{
|
||||||
@ -140,17 +147,19 @@ static int men_z127_probe(struct mcb_device *mdev,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
men_z127_gpio->mem = mcb_request_mem(mdev, dev_name(dev));
|
men_z127_gpio->mem = mcb_request_mem(mdev, dev_name(dev));
|
||||||
if (IS_ERR(men_z127_gpio->mem)) {
|
if (IS_ERR(men_z127_gpio->mem))
|
||||||
dev_err(dev, "failed to request device memory");
|
return dev_err_probe(dev, PTR_ERR(men_z127_gpio->mem),
|
||||||
return PTR_ERR(men_z127_gpio->mem);
|
"failed to request device memory");
|
||||||
}
|
|
||||||
|
|
||||||
men_z127_gpio->reg_base = ioremap(men_z127_gpio->mem->start,
|
ret = devm_add_action_or_reset(dev, men_z127_release_mem,
|
||||||
resource_size(men_z127_gpio->mem));
|
men_z127_gpio->mem);
|
||||||
if (men_z127_gpio->reg_base == NULL) {
|
if (ret)
|
||||||
ret = -ENXIO;
|
return ret;
|
||||||
goto err_release;
|
|
||||||
}
|
men_z127_gpio->reg_base = devm_ioremap(dev, men_z127_gpio->mem->start,
|
||||||
|
resource_size(men_z127_gpio->mem));
|
||||||
|
if (men_z127_gpio->reg_base == NULL)
|
||||||
|
return -ENXIO;
|
||||||
|
|
||||||
mcb_set_drvdata(mdev, men_z127_gpio);
|
mcb_set_drvdata(mdev, men_z127_gpio);
|
||||||
|
|
||||||
@ -161,34 +170,16 @@ static int men_z127_probe(struct mcb_device *mdev,
|
|||||||
men_z127_gpio->reg_base + MEN_Z127_GPIODR,
|
men_z127_gpio->reg_base + MEN_Z127_GPIODR,
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_unmap;
|
return ret;
|
||||||
|
|
||||||
men_z127_gpio->gc.set_config = men_z127_set_config;
|
men_z127_gpio->gc.set_config = men_z127_set_config;
|
||||||
|
|
||||||
ret = gpiochip_add_data(&men_z127_gpio->gc, men_z127_gpio);
|
ret = devm_gpiochip_add_data(dev, &men_z127_gpio->gc, men_z127_gpio);
|
||||||
if (ret) {
|
if (ret)
|
||||||
dev_err(dev, "failed to register MEN 16Z127 GPIO controller");
|
return dev_err_probe(dev, ret,
|
||||||
goto err_unmap;
|
"failed to register MEN 16Z127 GPIO controller");
|
||||||
}
|
|
||||||
|
|
||||||
dev_info(dev, "MEN 16Z127 GPIO driver registered");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_unmap:
|
|
||||||
iounmap(men_z127_gpio->reg_base);
|
|
||||||
err_release:
|
|
||||||
mcb_release_mem(men_z127_gpio->mem);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void men_z127_remove(struct mcb_device *mdev)
|
|
||||||
{
|
|
||||||
struct men_z127_gpio *men_z127_gpio = mcb_get_drvdata(mdev);
|
|
||||||
|
|
||||||
gpiochip_remove(&men_z127_gpio->gc);
|
|
||||||
iounmap(men_z127_gpio->reg_base);
|
|
||||||
mcb_release_mem(men_z127_gpio->mem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct mcb_device_id men_z127_ids[] = {
|
static const struct mcb_device_id men_z127_ids[] = {
|
||||||
@ -202,7 +193,6 @@ static struct mcb_driver men_z127_driver = {
|
|||||||
.name = "z127-gpio",
|
.name = "z127-gpio",
|
||||||
},
|
},
|
||||||
.probe = men_z127_probe,
|
.probe = men_z127_probe,
|
||||||
.remove = men_z127_remove,
|
|
||||||
.id_table = men_z127_ids,
|
.id_table = men_z127_ids,
|
||||||
};
|
};
|
||||||
module_mcb_driver(men_z127_driver);
|
module_mcb_driver(men_z127_driver);
|
||||||
|
Loading…
Reference in New Issue
Block a user