Skip to content

Commit

Permalink
spi: fsl-espi: improve return value handling in fsl_espi_probe
Browse files Browse the repository at this point in the history
The return value of fsl_espi_probe (currently struct spi_master *)
is just used for checking whether an error occurred.
Change the return value type to int and simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Heiner Kallweit authored and Mark Brown committed Sep 24, 2016
1 parent acf6921 commit 604042a
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions drivers/spi/spi-fsl-espi.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,22 +538,20 @@ static size_t fsl_espi_max_message_size(struct spi_device *spi)
return SPCOM_TRANLEN_MAX;
}

static struct spi_master * fsl_espi_probe(struct device *dev,
struct resource *mem, unsigned int irq)
static int fsl_espi_probe(struct device *dev, struct resource *mem,
unsigned int irq)
{
struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
struct spi_master *master;
struct mpc8xxx_spi *mpc8xxx_spi;
struct device_node *nc;
const __be32 *prop;
u32 regval, csmode;
int i, len, ret = 0;
int i, len, ret;

master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi));
if (!master) {
ret = -ENOMEM;
goto err;
}
if (!master)
return -ENOMEM;

dev_set_drvdata(dev, master);

Expand Down Expand Up @@ -647,16 +645,15 @@ static struct spi_master * fsl_espi_probe(struct device *dev,
pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);

return master;
return 0;

err_pm:
pm_runtime_put_noidle(dev);
pm_runtime_disable(dev);
pm_runtime_set_suspended(dev);
err_probe:
spi_master_put(master);
err:
return ERR_PTR(ret);
return ret;
}

static int of_fsl_espi_get_chipselects(struct device *dev)
Expand All @@ -682,7 +679,6 @@ static int of_fsl_espi_probe(struct platform_device *ofdev)
{
struct device *dev = &ofdev->dev;
struct device_node *np = ofdev->dev.of_node;
struct spi_master *master;
struct resource mem;
unsigned int irq;
int ret;
Expand All @@ -703,11 +699,7 @@ static int of_fsl_espi_probe(struct platform_device *ofdev)
if (!irq)
return -EINVAL;

master = fsl_espi_probe(dev, &mem, irq);
if (IS_ERR(master))
return PTR_ERR(master);

return 0;
return fsl_espi_probe(dev, &mem, irq);
}

static int of_fsl_espi_remove(struct platform_device *dev)
Expand Down

0 comments on commit 604042a

Please sign in to comment.