Skip to content

Commit 3e85be9

Browse files
mwalleambarus
authored andcommitted
mtd: spi-nor: add SNOR_ID() and SNOR_OTP()
After all the preparation, it is now time to introduce the new macros to specify flashes in our database: SNOR_ID() and SNOR_OTP(). An flash_info entry might now look like: { .id = SNOR_ID(0xef, 0x60, 0x16), .otp = SNOR_OTP(256, 3, 0x1000, 0x1000), .flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB, } Signed-off-by: Michael Walle <mwalle@kernel.org> Link: https://lore.kernel.org/r/20230807-mtd-flash-info-db-rework-v3-15-e60548861b10@kernel.org Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent 83e62ff commit 3e85be9

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

drivers/mtd/spi-nor/core.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,20 @@ struct flash_info {
561561
const struct spi_nor_fixups *fixups;
562562
};
563563

564+
#define SNOR_ID(...) \
565+
(&(const struct spi_nor_id){ \
566+
.bytes = (const u8[]){ __VA_ARGS__ }, \
567+
.len = sizeof((u8[]){ __VA_ARGS__ }), \
568+
})
569+
570+
#define SNOR_OTP(_len, _n_regions, _base, _offset) \
571+
(&(const struct spi_nor_otp_organization){ \
572+
.len = (_len), \
573+
.base = (_base), \
574+
.offset = (_offset), \
575+
.n_regions = (_n_regions), \
576+
})
577+
564578
#define SPI_NOR_ID_2ITEMS(_id) ((_id) >> 8) & 0xff, (_id) & 0xff
565579
#define SPI_NOR_ID_3ITEMS(_id) ((_id) >> 16) & 0xff, SPI_NOR_ID_2ITEMS(_id)
566580

0 commit comments

Comments
 (0)