mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-15 08:44:14 +08:00
spi: spi-altera-dfl: Fix an error handling path
The spi_alloc_master() call is not undone in all error handling paths.
Moreover, there is no .remove function to release the allocated memory.
In order to fix both this issues, switch to devm_spi_alloc_master().
This allows further simplification of the probe.
Fixes: ba2fc167e9
("spi: altera: Add DFL bus driver for Altera API Controller")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/0607bb59f4073f86abe5c585d35245aef0b045c6.1653805901.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
f2906aa863
commit
8e3ca32f46
@ -128,9 +128,9 @@ static int dfl_spi_altera_probe(struct dfl_device *dfl_dev)
|
||||
struct spi_master *master;
|
||||
struct altera_spi *hw;
|
||||
void __iomem *base;
|
||||
int err = -ENODEV;
|
||||
int err;
|
||||
|
||||
master = spi_alloc_master(dev, sizeof(struct altera_spi));
|
||||
master = devm_spi_alloc_master(dev, sizeof(struct altera_spi));
|
||||
if (!master)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -159,10 +159,9 @@ static int dfl_spi_altera_probe(struct dfl_device *dfl_dev)
|
||||
altera_spi_init_master(master);
|
||||
|
||||
err = devm_spi_register_master(dev, master);
|
||||
if (err) {
|
||||
dev_err(dev, "%s failed to register spi master %d\n", __func__, err);
|
||||
goto exit;
|
||||
}
|
||||
if (err)
|
||||
return dev_err_probe(dev, err, "%s failed to register spi master\n",
|
||||
__func__);
|
||||
|
||||
if (dfl_dev->revision == FME_FEATURE_REV_MAX10_SPI_N5010)
|
||||
strscpy(board_info.modalias, "m10-n5010", SPI_NAME_SIZE);
|
||||
@ -179,9 +178,6 @@ static int dfl_spi_altera_probe(struct dfl_device *dfl_dev)
|
||||
}
|
||||
|
||||
return 0;
|
||||
exit:
|
||||
spi_master_put(master);
|
||||
return err;
|
||||
}
|
||||
|
||||
static const struct dfl_device_id dfl_spi_altera_ids[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user