Re: [PATCH v2 25/35] mtd: spi-nor: core: Move spi_nor_set_addr_width() in spi_nor_setup()

Michael Walle
2021-10-22T12:13:41Z

Am 2021-07-27 06:52, schrieb Tudor Ambarus:
> spi_nor_setup() configures the SPI NOR memory. Setting the addr width
> is too a configuration, hence we can move the spi_nor_set_addr_width()
> in spi_nor_setup().
>
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>

..

> static int spi_nor_setup(struct spi_nor *nor,
> const struct spi_nor_hwcaps *hwcaps)
> {
> + int ret;
> +
> if (!nor->params->setup)
> - return 0;
> + return spi_nor_set_addr_width(nor);
>
> - return nor->params->setup(nor, hwcaps);
> + ret = nor->params->setup(nor, hwcaps);
> + if (ret)
> + return ret;
> +
> + return spi_nor_set_addr_width(nor);
> }

Why not

static int spi_nor_setup(struct spi_nor *nor,
const struct spi_nor_hwcaps *hwcaps)
{
int ret;

if (nor->params->setup) {
ret = nor->params->setup(nor, hwcaps);
if (ret)
return ret;
}

return spi_nor_set_addr_width(nor)
}

-michael