[PATCH v2 21/35] mtd: spi-nor: Introduce spi_nor_set_mtd_info()
Michael Walle
michael at walle.cc
Fri Oct 22 04:53:28 PDT 2021
Am 2021-07-27 06:52, schrieb Tudor Ambarus:
> Used to init all the mtd_info fields. Move the mtd_info init
> the last thing in the spi_nor_scan(), so that we avoid superfluous
> initialization of the mtd_info fields in case of errors.
>
> Signed-off-by: Tudor Ambarus <tudor.ambarus at microchip.com>
> ---
> drivers/mtd/spi-nor/core.c | 55 +++++++++++++++++++++-----------------
> 1 file changed, 31 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index 5c8cffb5e6f2..26acfc9901db 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -3124,6 +3124,36 @@ static const struct flash_info
> *spi_nor_get_flash_info(struct spi_nor *nor,
> return info;
> }
>
> +static void spi_nor_set_mtd_info(struct spi_nor *nor)
> +{
> + struct mtd_info *mtd = &nor->mtd;
> + struct device *dev = nor->dev;
> +
> + spi_nor_register_locking_ops(nor);
This ..
> +
> + /* Configure OTP parameters and ops */
> + spi_nor_otp_init(nor);
.. this looks odd here now.
The first could be renamed to express that it only registers
mtd ops.
spi_nor_otp_init() does more - strictly speaking. That is,
it does also check that the otp region length is a power of 2.
At least it should also be renamed. But then I wonder, if in the
future there is more to do in spi_nor_otp_init(), where do we put
that then?
So mhh. I don't know. spi_nor_otp_init() is a more fitting name,
but calling it in spi_nor_set_mtd_info() is odd.
-michael
More information about the linux-mtd
mailing list