msi: use for_each_msi_entry_safe iterator macro
Subsystems (6)
PATCH 1/1 msi: use for_each_msi_entry_safe iterator macro
Commit 81b1e6e6a859 ("platform-msi: Free descriptors in platform_msi_domain_free()") introduced for_each_msi_entry_safe as an iterator operating on the msi_list using the safe semantics with a temporary variable.
A handful of locations still used the generic iterator instead of the specific macro. Fix the 3 remaining cases. Add a cocci script which can detect and report any misuse that is introduced in future changes.
---
I noticed that a couple places used the generic _safe iterator. They appear to be code which was written before the commit that introduced the new MSI-specific iterator.
drivers/base/platform-msi.c | 2 +- drivers/bus/fsl-mc/fsl-mc-msi.c | 2 +- drivers/soc/ti/ti_sci_inta_msi.c | 2 +- .../iterators/for_each_msi_entry.cocci | 101 ++++++++++++++++++ 4 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 scripts/coccinelle/iterators/for_each_msi_entry.cocci
drivers/base/platform-msi.c +1 -1
@@ -110,7 +110,7 @@ static void platform_msi_free_descs(struct device *dev, int base, int nvec) {struct msi_desc *desc, *tmp; -list_for_each_entry_safe (desc, tmp,dev_to_msi_list (dev), list) { +for_each_msi_entry_safe (desc, tmp, dev) {if (desc->platform.msi_index >= base && desc->platform.msi_index < (base + nvec)) {list_del (&desc->list);
drivers/bus/fsl-mc/fsl-mc-msi.c +1 -1
@@ -214,7 +214,7 @@ static void fsl_mc_msi_free_descs(struct device *dev) {struct msi_desc *desc, *tmp; -list_for_each_entry_safe (desc, tmp,dev_to_msi_list (dev), list) { +for_each_msi_entry_safe (desc, tmp, dev) {list_del (&desc->list);free_msi_entry (desc); }
drivers/soc/ti/ti_sci_inta_msi.c +1 -1
@@ -64,7 +64,7 @@ static void ti_sci_inta_msi_free_descs(struct device *dev) {struct msi_desc *desc, *tmp; -list_for_each_entry_safe (desc, tmp,dev_to_msi_list (dev), list) { +for_each_msi_entry_safe (desc, tmp, dev) {list_del (&desc->list);free_msi_entry (desc); }
scripts/coccinelle/iterators/for_each_msi_entry.cocci new file +101 -0
101 lines not on this page · raw message
base-commit: 255b2d524884e4ec60333131aa0ca0ef19826dc2
Signature · 1 line
2.29.0
Quoted 18 lines · Jacob Keller
Commit
81b1e6e6a859("platform-msi: Free descriptors inplatform_msi_domain_free()") introducedfor_each_msi_entry_safeas an iterator operating on themsi_listusing the safe semantics with a temporary variable.A handful of locations still used the generic iterator instead of the specific macro. Fix the 3 remaining cases. Add a cocci script which can detect and report any misuse that is introduced in future changes.
Cc Rafael J. Wysocki <[email protected]>Cc Stuart Yoder <[email protected]>Cc Laurentiu Tudor <[email protected]>Cc Nishanth Menon <[email protected]>Cc Tero Kristo <[email protected]>Cc Santosh Shilimkar <[email protected]>Cc Miquel Raynal <[email protected]>Signed-off-by Jacob Keller <[email protected]>---
[..snip..]
Quoted 6 lines
(quoted diff) +0
-0}drivers/soc/ti/ti_sci_inta_msi.c +0
-0
drivers/soc/ti/ti_sci_inta_msi.c static void ti_sci_inta_msi_free_descs(struct device *dev) · line 70
Quoted 8 lines
drivers/soc/ti/ti_sci_inta_msi.c +1
-1@@ -64,7 +64,7 @@ static void ti_sci_inta_msi_free_descs(struct device *dev) {struct msi_desc *desc, *tmp; -list_for_each_entry_safe (desc, tmp,dev_to_msi_list (dev), list) { +for_each_msi_entry_safe (desc, tmp, dev) {list_del (&desc->list);free_msi_entry (desc); }
For ti_sci_inta_msi part:
Thanks and regards,
Lokesh