diff options
| author | Alexey Romanov <[email protected]> | 2024-07-18 08:46:05 +0300 |
|---|---|---|
| committer | Michael Trimarchi <[email protected]> | 2024-08-08 09:27:50 +0200 |
| commit | e108d10d8c89aa65c8b41db5c43407fd0d4a09fe (patch) | |
| tree | 7446a0da25cfd90573e09032b09be0fb67ab337c /include/linux | |
| parent | c29a6daec184dd429bfccee42179bb5b079843b8 (diff) | |
drivers: introduce mtdblock abstraction
MTD block - abstraction over MTD subsystem, allowing
to read and write in blocks using BLK UCLASS.
Signed-off-by: Alexey Romanov <[email protected]>
Signed-off-by: Michael Trimarchi <[email protected]>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/mtd/mtd.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 983a55ce70e..6751fb52c5a 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -26,6 +26,7 @@ #include <dm/device.h> #endif #include <dm/ofnode.h> +#include <blk.h> #define MAX_MTD_DEVICES 32 #endif @@ -412,6 +413,30 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); +#if CONFIG_IS_ENABLED(MTD_BLOCK) +static inline struct mtd_info *blk_desc_to_mtd(struct blk_desc *bdesc) +{ + void *priv = dev_get_priv(bdesc->bdev); + + if (!priv) + return NULL; + + return *((struct mtd_info **)priv); +} + +int mtd_bind(struct udevice *dev, struct mtd_info **mtd); +#else +static inline struct mtd_info *blk_desc_to_mtd(struct blk_desc *bdesc) +{ + return NULL; +} + +static inline int mtd_bind(struct udevice *dev, struct mtd_info **mtd) +{ + return -EOPNOTSUPP; +} +#endif + int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops); int mtd_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops); |
