Introduce an mci_for_each_dimm() iterator. It returns a pointer to a struct dimm_info. This makes the declaration and use of an index obsolete and avoids access to internal data of struct mci (direct array access etc). [ bp: push the struct dimm_info *dimm; declaration into the CONFIG_EDAC_DEBUG block. ]
Showing the changes to include/linux (1 of 5 files). Show all
Unified · Split
| @@ -599,6 +599,13 @@ struct mem_ctl_info { · 598 unmodified lines | |||
| 599 | u16 fake_inject_count; | 599 | u16 fake_inject_count; |
| 600 | }; | 600 | }; |
| 601 | 601 | ||
| 602 | #define mci_for_each_dimm(mci, dimm) \ | ||
| 603 | for ((dimm) = (mci)->dimms[0]; \ | ||
| 604 | (dimm); \ | ||
| 605 | (dimm) = (dimm)->idx + 1 < (mci)->tot_dimms \ | ||
| 606 | ? (mci)->dimms[(dimm)->idx + 1] \ | ||
| 607 | : NULL) | ||
| 608 | |||
| 602 | /** | 609 | /** |
| 603 | * edac_get_dimm_by_index - Get DIMM info at @index from a memory | 610 | * edac_get_dimm_by_index - Get DIMM info at @index from a memory |
| 604 | * controller | 611 | * controller |