siox: bus-gpio: Simplify using devm_siox_* functions
With the devm variant of siox_master_allocate() and siox_master_register() the remove callback can be dropped. This also simplifies the error paths in the probe function. Acked-by: Thorsten Scherer <t.scherer@eckelmann.de> Link: https://lore.kernel.org/r/e3c598de536deadc7efef9c21ccb49d31eb240a9.1708328466.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This commit is contained in:
parent
91d5bb579c
commit
db418d5f1c
@ -91,65 +91,42 @@ static int siox_gpio_probe(struct platform_device *pdev)
|
||||
int ret;
|
||||
struct siox_master *smaster;
|
||||
|
||||
smaster = siox_master_alloc(&pdev->dev, sizeof(*ddata));
|
||||
if (!smaster) {
|
||||
dev_err(dev, "failed to allocate siox master\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
smaster = devm_siox_master_alloc(dev, sizeof(*ddata));
|
||||
if (!smaster)
|
||||
return dev_err_probe(dev, -ENOMEM,
|
||||
"failed to allocate siox master\n");
|
||||
|
||||
platform_set_drvdata(pdev, smaster);
|
||||
ddata = siox_master_get_devdata(smaster);
|
||||
|
||||
ddata->din = devm_gpiod_get(dev, "din", GPIOD_IN);
|
||||
if (IS_ERR(ddata->din)) {
|
||||
ret = dev_err_probe(dev, PTR_ERR(ddata->din),
|
||||
"Failed to get din GPIO\n");
|
||||
goto err;
|
||||
}
|
||||
if (IS_ERR(ddata->din))
|
||||
return dev_err_probe(dev, PTR_ERR(ddata->din),
|
||||
"Failed to get din GPIO\n");
|
||||
|
||||
ddata->dout = devm_gpiod_get(dev, "dout", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(ddata->dout)) {
|
||||
ret = dev_err_probe(dev, PTR_ERR(ddata->dout),
|
||||
"Failed to get dout GPIO\n");
|
||||
goto err;
|
||||
}
|
||||
if (IS_ERR(ddata->dout))
|
||||
return dev_err_probe(dev, PTR_ERR(ddata->dout),
|
||||
"Failed to get dout GPIO\n");
|
||||
|
||||
ddata->dclk = devm_gpiod_get(dev, "dclk", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(ddata->dclk)) {
|
||||
ret = dev_err_probe(dev, PTR_ERR(ddata->dclk),
|
||||
"Failed to get dclk GPIO\n");
|
||||
goto err;
|
||||
}
|
||||
if (IS_ERR(ddata->dclk))
|
||||
return dev_err_probe(dev, PTR_ERR(ddata->dclk),
|
||||
"Failed to get dclk GPIO\n");
|
||||
|
||||
ddata->dld = devm_gpiod_get(dev, "dld", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(ddata->dld)) {
|
||||
ret = dev_err_probe(dev, PTR_ERR(ddata->dld),
|
||||
"Failed to get dld GPIO\n");
|
||||
goto err;
|
||||
}
|
||||
if (IS_ERR(ddata->dld))
|
||||
return dev_err_probe(dev, PTR_ERR(ddata->dld),
|
||||
"Failed to get dld GPIO\n");
|
||||
|
||||
smaster->pushpull = siox_gpio_pushpull;
|
||||
/* XXX: determine automatically like spi does */
|
||||
smaster->busno = 0;
|
||||
|
||||
ret = siox_master_register(smaster);
|
||||
if (ret) {
|
||||
dev_err_probe(dev, ret,
|
||||
"Failed to register siox master\n");
|
||||
err:
|
||||
siox_master_put(smaster);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int siox_gpio_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct siox_master *master = platform_get_drvdata(pdev);
|
||||
|
||||
siox_master_unregister(master);
|
||||
|
||||
siox_master_put(master);
|
||||
ret = devm_siox_master_register(dev, smaster);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret,
|
||||
"Failed to register siox master\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -162,7 +139,6 @@ MODULE_DEVICE_TABLE(of, siox_gpio_dt_ids);
|
||||
|
||||
static struct platform_driver siox_gpio_driver = {
|
||||
.probe = siox_gpio_probe,
|
||||
.remove = siox_gpio_remove,
|
||||
|
||||
.driver = {
|
||||
.name = DRIVER_NAME,
|
||||
|
Loading…
Reference in New Issue
Block a user