diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-10-29 15:26:37 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-11-06 14:08:10 +0100 |
commit | 5f605dc6168c2508e44ce81c7b169095849488ea (patch) | |
tree | 58339e4c36848213e0998b9903d676f7c4887d60 /include | |
parent | 068d7560c79f79674faf0267a319e4dc9b9bce8f (diff) | |
download | barebox-5f605dc6168c2508e44ce81c7b169095849488ea.tar.gz barebox-5f605dc6168c2508e44ce81c7b169095849488ea.tar.xz |
mtd: nand: Pass struct nand_chip around
Traditionally Linux passed a struct mtd_info * around as context
between the different functions. This has been changed to a struct
nand_chip *. Do the same for barebox as well as another step towards
updating the NAND layer to current Linux.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/mtd/nand.h | 97 | ||||
-rw-r--r-- | include/linux/mtd/nand_bch.h | 14 | ||||
-rw-r--r-- | include/linux/mtd/nand_ecc.h | 6 |
3 files changed, 59 insertions, 58 deletions
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index a8a22210ca..e23b3446a7 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -23,28 +23,29 @@ #include <linux/mtd/bbm.h> struct mtd_info; +struct nand_chip; struct nand_flash_dev; /* Scan and identify a NAND device */ -extern int nand_scan(struct mtd_info *mtd, int max_chips); +extern int nand_scan(struct nand_chip *chip, int max_chips); /* * Separate phases of nand_scan(), allowing board driver to intervene * and override command or ECC setup according to flash type. */ -extern int nand_scan_ident(struct mtd_info *mtd, int max_chips, +extern int nand_scan_ident(struct nand_chip *chip, int max_chips, struct nand_flash_dev *table); -extern int nand_scan_tail(struct mtd_info *mtd); +extern int nand_scan_tail(struct nand_chip *chip); /* Free resources held by the NAND device */ -extern void nand_release(struct mtd_info *mtd); +extern void nand_release(struct nand_chip *chip); /* Internal helper for board drivers which need to override command function */ -extern void nand_wait_ready(struct mtd_info *mtd); +extern void nand_wait_ready(struct nand_chip *chip); /* locks all blocks present in the device */ -extern int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len); +extern int nand_lock(struct nand_chip *chip, loff_t ofs, uint64_t len); /* unlocks specified locked blocks */ -extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len); +extern int nand_unlock(struct nand_chip *chip, loff_t ofs, uint64_t len); extern int nand_check_erased_ecc_chunk(void *data, int datalen, void *ecc, int ecclen, @@ -346,31 +347,28 @@ struct nand_ecc_ctrl { int postpad; struct nand_ecclayout *layout; void *priv; - void (*hwctl)(struct mtd_info *mtd, int mode); - int (*calculate)(struct mtd_info *mtd, const uint8_t *dat, + void (*hwctl)(struct nand_chip *chip, int mode); + int (*calculate)(struct nand_chip *chip, const uint8_t *dat, uint8_t *ecc_code); - int (*correct)(struct mtd_info *mtd, uint8_t *dat, uint8_t *read_ecc, + int (*correct)(struct nand_chip *chip, uint8_t *dat, uint8_t *read_ecc, uint8_t *calc_ecc); - int (*read_page_raw)(struct mtd_info *mtd, struct nand_chip *chip, + int (*read_page_raw)(struct nand_chip *chip, uint8_t *buf, int oob_required, int page); - int (*write_page_raw)(struct mtd_info *mtd, struct nand_chip *chip, + int (*write_page_raw)(struct nand_chip *chip, const uint8_t *buf, int oob_required); - int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip, + int (*read_page)(struct nand_chip *chip, uint8_t *buf, int oob_required, int page); - int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip, + int (*read_subpage)(struct nand_chip *chip, uint32_t offs, uint32_t len, uint8_t *buf, int page); - int (*write_subpage)(struct mtd_info *mtd, struct nand_chip *chip, + int (*write_subpage)(struct nand_chip *chip, uint32_t offset, uint32_t data_len, const uint8_t *data_buf, int oob_required); - int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, + int (*write_page)(struct nand_chip *chip, const uint8_t *buf, int oob_required); - int (*write_oob_raw)(struct mtd_info *mtd, struct nand_chip *chip, - int page); - int (*read_oob_raw)(struct mtd_info *mtd, struct nand_chip *chip, - int page); - int (*read_oob)(struct mtd_info *mtd, struct nand_chip *chip, int page); - int (*write_oob)(struct mtd_info *mtd, struct nand_chip *chip, - int page); + int (*write_oob_raw)(struct nand_chip *chip, int page); + int (*read_oob_raw)(struct nand_chip *chip, int page); + int (*read_oob)(struct nand_chip *chip, int page); + int (*write_oob)(struct nand_chip *chip, int page); }; /** @@ -473,27 +471,25 @@ struct nand_chip { void __iomem *IO_ADDR_R; void __iomem *IO_ADDR_W; - uint8_t (*read_byte)(struct mtd_info *mtd); - u16 (*read_word)(struct mtd_info *mtd); - void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len); - void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len); - void (*select_chip)(struct mtd_info *mtd, int chip); - int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip); - int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); - void (*cmd_ctrl)(struct mtd_info *mtd, int dat, unsigned int ctrl); - int (*init_size)(struct mtd_info *mtd, struct nand_chip *this, - u8 *id_data); - int (*dev_ready)(struct mtd_info *mtd); - void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, + uint8_t (*read_byte)(struct nand_chip *chip); + u16 (*read_word)(struct nand_chip *chip); + void (*write_buf)(struct nand_chip *chip, const uint8_t *buf, int len); + void (*read_buf)(struct nand_chip *chip, uint8_t *buf, int len); + void (*select_chip)(struct nand_chip *_chip, int chip); + int (*block_bad)(struct nand_chip *chip, loff_t ofs, int getchip); + int (*block_markbad)(struct nand_chip *chip, loff_t ofs); + void (*cmd_ctrl)(struct nand_chip *chip, int dat, unsigned int ctrl); + int (*dev_ready)(struct nand_chip *chip); + void (*cmdfunc)(struct nand_chip *chip, unsigned command, int column, int page_addr); - int(*waitfunc)(struct mtd_info *mtd, struct nand_chip *this); - int (*scan_bbt)(struct mtd_info *mtd); - int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, + int(*waitfunc)(struct nand_chip *chip); + int (*scan_bbt)(struct nand_chip *chip); + int (*write_page)(struct nand_chip *chip, uint32_t offset, int data_len, const uint8_t *buf, int oob_required, int page, int cached, int raw); - int (*onfi_set_features)(struct mtd_info *mtd, struct nand_chip *chip, + int (*onfi_set_features)(struct nand_chip *chip, int feature_addr, uint8_t *subfeature_para); - int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip, + int (*onfi_get_features)(struct nand_chip *chip, int feature_addr, uint8_t *subfeature_para); int chip_delay; @@ -629,16 +625,16 @@ struct nand_manufacturers { extern struct nand_flash_dev nand_flash_ids[]; extern struct nand_manufacturers nand_manuf_ids[]; -extern int nand_update_bbt(struct mtd_info *mtd, loff_t offs); -extern int nand_default_bbt(struct mtd_info *mtd); -extern int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs); -extern int nand_markgood_bbt(struct mtd_info *mtd, loff_t offs); -extern int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt); -extern int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, +extern int nand_update_bbt(struct nand_chip *chip, loff_t offs); +extern int nand_default_bbt(struct nand_chip *chip); +extern int nand_markbad_bbt(struct nand_chip *chip, loff_t offs); +extern int nand_markgood_bbt(struct nand_chip *chip, loff_t offs); +extern int nand_isbad_bbt(struct nand_chip *chip, loff_t offs, int allowbbt); +extern int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr, int allowbbt); -extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len, +extern int nand_do_read(struct nand_chip *chip, loff_t from, size_t len, size_t *retlen, uint8_t *buf); -extern int add_mtd_nand_device(struct mtd_info *mtd, char *devname); +extern int add_mtd_nand_device(struct nand_chip *chip, char *devname); /** * struct platform_nand_chip - chip level device structure @@ -798,4 +794,9 @@ static inline struct nand_chip *mtd_to_nand(struct mtd_info *mtd) return container_of(mtd, struct nand_chip, mtd); } +static inline struct mtd_info *nand_to_mtd(struct nand_chip *chip) +{ + return &chip->mtd; +} + #endif /* __LINUX_MTD_NAND_H */ diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h index 5465ddd132..eee80a558c 100644 --- a/include/linux/mtd/nand_bch.h +++ b/include/linux/mtd/nand_bch.h @@ -11,7 +11,7 @@ #ifndef __MTD_NAND_BCH_H__ #define __MTD_NAND_BCH_H__ -struct mtd_info; +struct nand_chip; struct nand_bch_control; #if defined(CONFIG_NAND_ECC_BCH) @@ -21,18 +21,18 @@ static inline int mtd_nand_has_bch(void) { return 1; } /* * Calculate BCH ecc code */ -int nand_bch_calculate_ecc(struct mtd_info *mtd, const u_char *dat, +int nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat, u_char *ecc_code); /* * Detect and correct bit errors */ -int nand_bch_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, +int nand_bch_correct_data(struct nand_chip *chip, u_char *dat, u_char *read_ecc, u_char *calc_ecc); /* * Initialize BCH encoder/decoder */ -struct nand_bch_control *nand_bch_init(struct mtd_info *mtd); +struct nand_bch_control *nand_bch_init(struct nand_chip *chip); /* * Release BCH encoder/decoder resources */ @@ -43,20 +43,20 @@ void nand_bch_free(struct nand_bch_control *nbc); static inline int mtd_nand_has_bch(void) { return 0; } static inline int -nand_bch_calculate_ecc(struct mtd_info *mtd, const u_char *dat, +nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat, u_char *ecc_code) { return -1; } static inline int -nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, +nand_bch_correct_data(struct nand_chip *chip, unsigned char *buf, unsigned char *read_ecc, unsigned char *calc_ecc) { return -1; } -static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd) +static inline struct nand_bch_control *nand_bch_init(struct nand_chip *chip) { return NULL; } diff --git a/include/linux/mtd/nand_ecc.h b/include/linux/mtd/nand_ecc.h index 12c5bc342e..1dc779581f 100644 --- a/include/linux/mtd/nand_ecc.h +++ b/include/linux/mtd/nand_ecc.h @@ -15,16 +15,16 @@ #ifndef __MTD_NAND_ECC_H__ #define __MTD_NAND_ECC_H__ -struct mtd_info; +struct nand_chip; /* * Calculate 3 byte ECC code for 256 byte block */ -int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code); +int nand_calculate_ecc(struct nand_chip *chip, const u_char *dat, u_char *ecc_code); /* * Detect and correct a 1 bit error for 256 byte block */ -int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc); +int nand_correct_data(struct nand_chip *chip, u_char *dat, u_char *read_ecc, u_char *calc_ecc); #endif /* __MTD_NAND_ECC_H__ */ |