Commit db418d5f authored by Uwe Kleine-König's avatar Uwe Kleine-König

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: default avatarThorsten Scherer <t.scherer@eckelmann.de>
Link: https://lore.kernel.org/r/e3c598de536deadc7efef9c21ccb49d31eb240a9.1708328466.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 91d5bb57
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment