Skip to content

Commit a63674c

Browse files
committed
mtd: rawnand: Reorganize the nand_chip structure
Reorder fields in this structure and pack entries by theme: * The main descriptive structures * The data interface details * Bad block information * The device layout * Extra buffers matching the device layout * Internal values * External objects like the ECC controller, the ECC engine and a private data pointer. While at it, adapt the documentation style. I changed on purpose the description of @oob_poi which was weird. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Link: https://lore.kernel.org/linux-mtd/20200529111322.7184-7-miquel.raynal@bootlin.com
1 parent 36017af commit a63674c

1 file changed

Lines changed: 76 additions & 90 deletions

File tree

‎include/linux/mtd/rawnand.h‎

Lines changed: 76 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,120 +1055,106 @@ struct nand_manufacturer {
10551055

10561056
/**
10571057
* struct nand_chip - NAND Private Flash Chip Data
1058-
* @base: Inherit from the generic NAND device
1059-
* @ops: NAND chip operations
1060-
* @manufacturer: Manufacturer information
1061-
* @legacy: All legacy fields/hooks. If you develop a new driver,
1062-
* don't even try to use any of these fields/hooks, and if
1063-
* you're modifying an existing driver that is using those
1064-
* fields/hooks, you should consider reworking the driver
1065-
* avoid using them.
1066-
* @ecc: [BOARDSPECIFIC] ECC control structure
1067-
* @buf_align: minimum buffer alignment required by a platform
1068-
* @oob_poi: "poison value buffer," used for laying out OOB data
1069-
* before writing
1070-
* @page_shift: [INTERN] number of address bits in a page (column
1071-
* address bits).
1072-
* @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock
1073-
* @bbt_erase_shift: [INTERN] number of address bits in a bbt entry
1074-
* @chip_shift: [INTERN] number of address bits in one chip
1075-
* @options: [BOARDSPECIFIC] various chip options. They can partly
1076-
* be set to inform nand_scan about special functionality.
1077-
* See the defines for further explanation.
1078-
* @bbt_options: [INTERN] bad block specific options. All options used
1079-
* here must come from bbm.h. By default, these options
1080-
* will be copied to the appropriate nand_bbt_descr's.
1081-
* @badblockpos: [INTERN] position of the bad block marker in the oob
1082-
* area.
1083-
* @badblockbits: [INTERN] minimum number of set bits in a good block's
1084-
* bad block marker position; i.e., BBM == 11110111b is
1085-
* not bad when badblockbits == 7
1086-
* @onfi_timing_mode_default: [INTERN] default ONFI timing mode. This field is
1087-
* set to the actually used ONFI mode if the chip is
1088-
* ONFI compliant or deduced from the datasheet if
1089-
* the NAND chip is not ONFI compliant.
1090-
* @pagemask: [INTERN] page number mask = number of (pages / chip) - 1
1091-
* @data_buf: [INTERN] buffer for data, size is (page size + oobsize).
1092-
* @pagecache: Structure containing page cache related fields
1093-
* @pagecache.bitflips: Number of bitflips of the cached page
1094-
* @pagecache.page: Page number currently in the cache. -1 means no page is
1095-
* currently cached
1096-
* @subpagesize: [INTERN] holds the subpagesize
1097-
* @id: [INTERN] holds NAND ID
1098-
* @parameters: [INTERN] holds generic parameters under an easily
1099-
* readable form.
1100-
* @data_interface: [INTERN] NAND interface timing information
1101-
* @cur_cs: currently selected target. -1 means no target selected,
1102-
* otherwise we should always have cur_cs >= 0 &&
1103-
* cur_cs < nanddev_ntargets(). NAND Controller drivers
1104-
* should not modify this value, but they're allowed to
1105-
* read it.
1106-
* @read_retries: [INTERN] the number of read retry modes supported
1107-
* @lock: lock protecting the suspended field. Also used to
1108-
* serialize accesses to the NAND device.
1109-
* @suspended: set to 1 when the device is suspended, 0 when it's not.
1110-
* @bbt: [INTERN] bad block table pointer
1111-
* @bbt_td: [REPLACEABLE] bad block table descriptor for flash
1112-
* lookup.
1113-
* @bbt_md: [REPLACEABLE] bad block table mirror descriptor
1114-
* @badblock_pattern: [REPLACEABLE] bad block scan pattern used for initial
1115-
* bad block scan.
1116-
* @controller: [REPLACEABLE] a pointer to a hardware controller
1117-
* structure which is shared among multiple independent
1118-
* devices.
1119-
* @priv: [OPTIONAL] pointer to private chip data
1058+
* @base: Inherit from the generic NAND device
1059+
* @id: Holds NAND ID
1060+
* @parameters: Holds generic parameters under an easily readable form
1061+
* @manufacturer: Manufacturer information
1062+
* @ops: NAND chip operations
1063+
* @legacy: All legacy fields/hooks. If you develop a new driver, don't even try
1064+
* to use any of these fields/hooks, and if you're modifying an
1065+
* existing driver that is using those fields/hooks, you should
1066+
* consider reworking the driver and avoid using them.
1067+
* @options: Various chip options. They can partly be set to inform nand_scan
1068+
* about special functionality. See the defines for further
1069+
* explanation.
1070+
* @onfi_timing_mode_default: Default ONFI timing mode. This field is set to the
1071+
* actually used ONFI mode if the chip is ONFI
1072+
* compliant or deduced from the datasheet otherwise
1073+
* @data_interface: NAND interface timing information
1074+
* @bbt_erase_shift: Number of address bits in a bbt entry
1075+
* @bbt_options: Bad block table specific options. All options used here must
1076+
* come from bbm.h. By default, these options will be copied to
1077+
* the appropriate nand_bbt_descr's.
1078+
* @badblockpos: Bad block marker position in the oob area
1079+
* @badblockbits: Minimum number of set bits in a good block's bad block marker
1080+
* position; i.e., BBM = 11110111b is good when badblockbits = 7
1081+
* @bbt_td: Bad block table descriptor for flash lookup
1082+
* @bbt_md: Bad block table mirror descriptor
1083+
* @badblock_pattern: Bad block scan pattern used for initial bad block scan
1084+
* @bbt: Bad block table pointer
1085+
* @page_shift: Number of address bits in a page (column address bits)
1086+
* @phys_erase_shift: Number of address bits in a physical eraseblock
1087+
* @chip_shift: Number of address bits in one chip
1088+
* @pagemask: Page number mask = number of (pages / chip) - 1
1089+
* @subpagesize: Holds the subpagesize
1090+
* @data_buf: Buffer for data, size is (page size + oobsize)
1091+
* @oob_poi: pointer on the OOB area covered by data_buf
1092+
* @pagecache: Structure containing page cache related fields
1093+
* @pagecache.bitflips: Number of bitflips of the cached page
1094+
* @pagecache.page: Page number currently in the cache. -1 means no page is
1095+
* currently cached
1096+
* @buf_align: Minimum buffer alignment required by a platform
1097+
* @lock: Lock protecting the suspended field. Also used to serialize accesses
1098+
* to the NAND device
1099+
* @suspended: Set to 1 when the device is suspended, 0 when it's not
1100+
* @cur_cs: Currently selected target. -1 means no target selected, otherwise we
1101+
* should always have cur_cs >= 0 && cur_cs < nanddev_ntargets().
1102+
* NAND Controller drivers should not modify this value, but they're
1103+
* allowed to read it.
1104+
* @read_retries: The number of read retry modes supported
1105+
* @controller: The hardware controller structure which is shared among multiple
1106+
* independent devices
1107+
* @ecc: The ECC controller structure
1108+
* @priv: Chip private data
11201109
*/
1121-
11221110
struct nand_chip {
11231111
struct nand_device base;
1112+
struct nand_id id;
1113+
struct nand_parameters parameters;
11241114
struct nand_manufacturer manufacturer;
11251115
struct nand_chip_ops ops;
11261116
struct nand_legacy legacy;
1127-
11281117
unsigned int options;
1118+
1119+
/* Data interface */
1120+
int onfi_timing_mode_default;
1121+
struct nand_data_interface data_interface;
1122+
1123+
/* Bad block information */
1124+
unsigned int bbt_erase_shift;
11291125
unsigned int bbt_options;
1126+
unsigned int badblockpos;
1127+
unsigned int badblockbits;
1128+
struct nand_bbt_descr *bbt_td;
1129+
struct nand_bbt_descr *bbt_md;
1130+
struct nand_bbt_descr *badblock_pattern;
1131+
u8 *bbt;
11301132

1133+
/* Device internal layout */
11311134
unsigned int page_shift;
11321135
unsigned int phys_erase_shift;
1133-
unsigned int bbt_erase_shift;
11341136
unsigned int chip_shift;
11351137
unsigned int pagemask;
1136-
u8 *data_buf;
1138+
unsigned int subpagesize;
11371139

1140+
/* Buffers */
1141+
u8 *data_buf;
1142+
u8 *oob_poi;
11381143
struct {
11391144
unsigned int bitflips;
11401145
int page;
11411146
} pagecache;
1147+
unsigned long buf_align;
11421148

1143-
unsigned int subpagesize;
1144-
int onfi_timing_mode_default;
1145-
unsigned int badblockpos;
1146-
unsigned int badblockbits;
1147-
1148-
struct nand_id id;
1149-
struct nand_parameters parameters;
1150-
1151-
struct nand_data_interface data_interface;
1152-
1153-
int cur_cs;
1154-
1155-
int read_retries;
1156-
1149+
/* Internals */
11571150
struct mutex lock;
11581151
unsigned int suspended : 1;
1152+
int cur_cs;
1153+
int read_retries;
11591154

1160-
u8 *oob_poi;
1155+
/* Externals */
11611156
struct nand_controller *controller;
1162-
11631157
struct nand_ecc_ctrl ecc;
1164-
unsigned long buf_align;
1165-
1166-
u8 *bbt;
1167-
struct nand_bbt_descr *bbt_td;
1168-
struct nand_bbt_descr *bbt_md;
1169-
1170-
struct nand_bbt_descr *badblock_pattern;
1171-
11721158
void *priv;
11731159
};
11741160

0 commit comments

Comments
 (0)