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) ...@@ -91,65 +91,42 @@ static int siox_gpio_probe(struct platform_device *pdev)
int ret; int ret;
struct siox_master *smaster; struct siox_master *smaster;
smaster = siox_master_alloc(&pdev->dev, sizeof(*ddata)); smaster = devm_siox_master_alloc(dev, sizeof(*ddata));
if (!smaster) { if (!smaster)
dev_err(dev, "failed to allocate siox master\n"); return dev_err_probe(dev, -ENOMEM,
return -ENOMEM; "failed to allocate siox master\n");
}
platform_set_drvdata(pdev, smaster); platform_set_drvdata(pdev, smaster);
ddata = siox_master_get_devdata(smaster); ddata = siox_master_get_devdata(smaster);
ddata->din = devm_gpiod_get(dev, "din", GPIOD_IN); ddata->din = devm_gpiod_get(dev, "din", GPIOD_IN);
if (IS_ERR(ddata->din)) { if (IS_ERR(ddata->din))
ret = dev_err_probe(dev, PTR_ERR(ddata->din), return dev_err_probe(dev, PTR_ERR(ddata->din),
"Failed to get din GPIO\n"); "Failed to get din GPIO\n");
goto err;
}
ddata->dout = devm_gpiod_get(dev, "dout", GPIOD_OUT_LOW); ddata->dout = devm_gpiod_get(dev, "dout", GPIOD_OUT_LOW);
if (IS_ERR(ddata->dout)) { if (IS_ERR(ddata->dout))
ret = dev_err_probe(dev, PTR_ERR(ddata->dout), return dev_err_probe(dev, PTR_ERR(ddata->dout),
"Failed to get dout GPIO\n"); "Failed to get dout GPIO\n");
goto err;
}
ddata->dclk = devm_gpiod_get(dev, "dclk", GPIOD_OUT_LOW); ddata->dclk = devm_gpiod_get(dev, "dclk", GPIOD_OUT_LOW);
if (IS_ERR(ddata->dclk)) { if (IS_ERR(ddata->dclk))
ret = dev_err_probe(dev, PTR_ERR(ddata->dclk), return dev_err_probe(dev, PTR_ERR(ddata->dclk),
"Failed to get dclk GPIO\n"); "Failed to get dclk GPIO\n");
goto err;
}
ddata->dld = devm_gpiod_get(dev, "dld", GPIOD_OUT_LOW); ddata->dld = devm_gpiod_get(dev, "dld", GPIOD_OUT_LOW);
if (IS_ERR(ddata->dld)) { if (IS_ERR(ddata->dld))
ret = dev_err_probe(dev, PTR_ERR(ddata->dld), return dev_err_probe(dev, PTR_ERR(ddata->dld),
"Failed to get dld GPIO\n"); "Failed to get dld GPIO\n");
goto err;
}
smaster->pushpull = siox_gpio_pushpull; smaster->pushpull = siox_gpio_pushpull;
/* XXX: determine automatically like spi does */ /* XXX: determine automatically like spi does */
smaster->busno = 0; smaster->busno = 0;
ret = siox_master_register(smaster); ret = devm_siox_master_register(dev, smaster);
if (ret) { if (ret)
dev_err_probe(dev, ret, return dev_err_probe(dev, ret,
"Failed to register siox master\n"); "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);
return 0; return 0;
} }
...@@ -162,7 +139,6 @@ MODULE_DEVICE_TABLE(of, siox_gpio_dt_ids); ...@@ -162,7 +139,6 @@ MODULE_DEVICE_TABLE(of, siox_gpio_dt_ids);
static struct platform_driver siox_gpio_driver = { static struct platform_driver siox_gpio_driver = {
.probe = siox_gpio_probe, .probe = siox_gpio_probe,
.remove = siox_gpio_remove,
.driver = { .driver = {
.name = DRIVER_NAME, .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