History

mtd: rawnand: Allocate the interface configurations dynamically

Instead of manipulating the statically allocated structure and copy timings around, allocate one at identification time and save it in the nand_chip structure once it has been initialized. All NAND chips using the same interface configuration during reset and startup, we define a helper to retrieve a single reset interface configuration object, shared across all NAND chips. We use a second pointer to always have a reference on the currently applied interface configuration, which may either point to the "best interface configuration" or to the "default reset interface configuration".

Miquel Raynal committed 6 years ago

Commit 35b6bcc1 parent a69ad114 files · +67 −35Browse files

Showing the changes to include/linux (1 of 4 files). Show all

Unified · Split

include/linux/mtd/rawnand.h+8−3
@@ -1069,7 +1069,11 @@ struct nand_manufacturer { · 1068 unmodified lines
10691069 * @options: Various chip options. They can partly be set to inform nand_scan
10701070 * about special functionality. See the defines for further
10711071 * explanation.
1072− * @interface_config: NAND interface timing information
1072+ * @current_interface_config: The currently used NAND interface configuration
1073+ * @best_interface_config: The best NAND interface configuration which fits both
1074+ * the NAND chip and NAND controller constraints. If
1075+ * unset, the default reset interface configuration must
1076+ * be used.
10731077 * @bbt_erase_shift: Number of address bits in a bbt entry
10741078 * @bbt_options: Bad block table specific options. All options used here must
10751079 * come from bbm.h. By default, these options will be copied to
@@ -1116,7 +1120,8 @@ struct nand_chip { · 40 unmodified lines
11161120 unsigned int options;
11171121
11181122 /* Data interface */
1119− struct nand_interface_config interface_config;
1123+ const struct nand_interface_config *current_interface_config;
1124+ struct nand_interface_config *best_interface_config;
11201125
11211126 /* Bad block information */
11221127 unsigned int bbt_erase_shift;
@@ -1209,7 +1214,7 @@ static inline struct device_node *nand_get_flash_node(struct nand_chip *chip) · 86 unmodified lines
12091214 static inline const struct nand_interface_config *
12101215 nand_get_interface_config(struct nand_chip *chip)
12111216 {
1212− return &chip->interface_config;
1217+ return chip->current_interface_config;
12131218 }
12141219
12151220 /*