Commit 7158c86e authored by Tudor Ambarus's avatar Tudor Ambarus
Browse files

mtd: spi-nor: core: Use container_of to get the pointer to struct spi_nor



"struct mtd_info mtd" is member of "struct spi_nor", there's no need
to use "mtd->priv". Get the pointer to the containing struct spi_nor
by using container_of. While here, make the function inline and
get rid of the __maybe_unused.

Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: default avatarMichael Walle <michael@walle.cc>
Reviewed-by: default avatarPratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20211029172633.886453-3-tudor.ambarus@microchip.com
parent a360ae43
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -3134,7 +3134,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,

	if (!mtd->name)
		mtd->name = dev_name(dev);
	mtd->priv = nor;
	mtd->type = MTD_NORFLASH;
	mtd->writesize = nor->params->writesize;
	mtd->flags = MTD_CAP_NORFLASH;
+2 −2
Original line number Diff line number Diff line
@@ -551,9 +551,9 @@ void spi_nor_try_unlock_all(struct spi_nor *nor);
void spi_nor_register_locking_ops(struct spi_nor *nor);
void spi_nor_otp_init(struct spi_nor *nor);

static struct spi_nor __maybe_unused *mtd_to_spi_nor(struct mtd_info *mtd)
static inline struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd)
{
	return mtd->priv;
	return container_of(mtd, struct spi_nor, mtd);
}

#endif /* __LINUX_MTD_SPI_NOR_INTERNAL_H */