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".
Showing the changes to include/linux (1 of 4 files). Show all
Unified · Split
| @@ -1069,7 +1069,11 @@ struct nand_manufacturer { · 1068 unmodified lines | ||
| 1069 | 1069 | * @options: Various chip options. They can partly be set to inform nand_scan |
| 1070 | 1070 | * about special functionality. See the defines for further |
| 1071 | 1071 | * 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. | |
| 1073 | 1077 | * @bbt_erase_shift: Number of address bits in a bbt entry |
| 1074 | 1078 | * @bbt_options: Bad block table specific options. All options used here must |
| 1075 | 1079 | * come from bbm.h. By default, these options will be copied to |
| @@ -1116,7 +1120,8 @@ struct nand_chip { · 40 unmodified lines | ||
| 1116 | 1120 | unsigned int options; |
| 1117 | 1121 | |
| 1118 | 1122 | /* 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; | |
| 1120 | 1125 | |
| 1121 | 1126 | /* Bad block information */ |
| 1122 | 1127 | 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 | ||
| 1209 | 1214 | static inline const struct nand_interface_config * |
| 1210 | 1215 | nand_get_interface_config(struct nand_chip *chip) |
| 1211 | 1216 | { |
| 1212 | − return &chip->interface_config; | |
| 1217 | + return chip->current_interface_config; | |
| 1213 | 1218 | } |
| 1214 | 1219 | |
| 1215 | 1220 | /* |