* [PATCH v2] iommu: simplify list initialization in iommu_create_device_direct_mappings() and iommu_group_show_resv_regions()
@ 2026-01-12 3:21 Can Peng
2026-01-12 5:29 ` Vasant Hegde
2026-01-12 12:30 ` Markus Elfring
0 siblings, 2 replies; 4+ messages in thread
From: Can Peng @ 2026-01-12 3:21 UTC (permalink / raw)
To: joro, will, robin.murphy, Markus.Elfring; +Cc: iommu, linux-kernel, Can Peng
Use LIST_HEAD() to declare and initialize list heads in both
iommu_create_device_direct_mappings() and iommu_group_show_resv_regions()
instead of separate declaration and INIT_LIST_HEAD(). This simplifies the
code by combining declaration and initialization into a single idiomatic
form, improving readability without changing functionality.
Signed-off-by: Can Peng <pengcan@kylinos.cn>
---
>> Use LIST_HEAD() to declare and initialize the 'mappings' list head in
>> iommu_create_device_direct_mappings() instead of separate declaration and
>> INIT_LIST_HEAD(). This simplifies the code by combining declaration and
>> initialization into a single idiomatic form, improving readability without
>> changing functionality.
>…
>
>How do you think about to repeat the mentioned transformation approach for the implementation
>of the function “iommu_group_show_resv_regions”?
>https://elixir.bootlin.com/linux/v6.19-rc4/source/drivers/iommu/iommu.c#L949-L969
Changes since v1:
- Extend the cleanup to iommu_group_show_resv_regions() as suggested by
reviewer, applying the same LIST_HEAD() pattern consistently across
the file.
Best regards,
Can Peng
drivers/iommu/iommu.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 2ca990dfbb88..b9ffd001b4b3 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -950,10 +950,9 @@ static ssize_t iommu_group_show_resv_regions(struct iommu_group *group,
char *buf)
{
struct iommu_resv_region *region, *next;
- struct list_head group_resv_regions;
+ LIST_HEAD(group_resv_regions);
int offset = 0;
- INIT_LIST_HEAD(&group_resv_regions);
iommu_get_group_resv_regions(group, &group_resv_regions);
list_for_each_entry_safe(region, next, &group_resv_regions, list) {
@@ -1173,12 +1172,11 @@ static int iommu_create_device_direct_mappings(struct iommu_domain *domain,
struct device *dev)
{
struct iommu_resv_region *entry;
- struct list_head mappings;
+ LIST_HEAD(mappings);
unsigned long pg_size;
int ret = 0;
pg_size = domain->pgsize_bitmap ? 1UL << __ffs(domain->pgsize_bitmap) : 0;
- INIT_LIST_HEAD(&mappings);
if (WARN_ON_ONCE(iommu_is_dma_domain(domain) && !pg_size))
return -EINVAL;
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] iommu: simplify list initialization in iommu_create_device_direct_mappings() and iommu_group_show_resv_regions()
2026-01-12 3:21 [PATCH v2] iommu: simplify list initialization in iommu_create_device_direct_mappings() and iommu_group_show_resv_regions() Can Peng
@ 2026-01-12 5:29 ` Vasant Hegde
2026-01-12 12:30 ` Markus Elfring
1 sibling, 0 replies; 4+ messages in thread
From: Vasant Hegde @ 2026-01-12 5:29 UTC (permalink / raw)
To: Can Peng, joro, will, robin.murphy, Markus.Elfring; +Cc: iommu, linux-kernel
On 1/12/2026 8:51 AM, Can Peng wrote:
> Use LIST_HEAD() to declare and initialize list heads in both
> iommu_create_device_direct_mappings() and iommu_group_show_resv_regions()
> instead of separate declaration and INIT_LIST_HEAD(). This simplifies the
> code by combining declaration and initialization into a single idiomatic
> form, improving readability without changing functionality.
>
> Signed-off-by: Can Peng <pengcan@kylinos.cn>
Patch looks good.
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
-Vasant
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] iommu: simplify list initialization in iommu_create_device_direct_mappings() and iommu_group_show_resv_regions()
2026-01-12 3:21 [PATCH v2] iommu: simplify list initialization in iommu_create_device_direct_mappings() and iommu_group_show_resv_regions() Can Peng
2026-01-12 5:29 ` Vasant Hegde
@ 2026-01-12 12:30 ` Markus Elfring
2026-01-13 10:04 ` Vasant Hegde
1 sibling, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2026-01-12 12:30 UTC (permalink / raw)
To: Can Peng, iommu, cocci, Jörg Rödel, Robin Murphy,
Vasant Hegde, Will Deacon
Cc: LKML, kernel-janitors
> Changes since v1:
> - Extend the cleanup to iommu_group_show_resv_regions() as suggested by
> reviewer, applying the same LIST_HEAD() pattern consistently across
> the file.
Thanks for your interest in further code adjustments.
* I wonder how they fit to the feedback “Applied, thanks.” by Jörg Rödel
from 2026-01-10.
https://lore.kernel.org/lkml/stpavkxy3sbevk7zmt4kxyecqy5gc6phubvcfutbtnuk7vphlh@a7aimtvk423i/
https://lkml.org/lkml/2026/1/10/235
* A shorter summary phrase might become more desirable for this patch variant.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.19-rc4#n687
* Will development interests grow also for another transformation approach
like the following by the means of the semantic patch language (Coccinelle software)?
@replacement@
expression e;
identifier i;
@@
-struct list_head i;
... when exists
when != i = e
-INIT_LIST_HEAD
+LIST_HEAD
(
- &
i
);
I determined that 175 source files of the software “Linux next-20260109” contain
corresponding update candidates.
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] iommu: simplify list initialization in iommu_create_device_direct_mappings() and iommu_group_show_resv_regions()
2026-01-12 12:30 ` Markus Elfring
@ 2026-01-13 10:04 ` Vasant Hegde
0 siblings, 0 replies; 4+ messages in thread
From: Vasant Hegde @ 2026-01-13 10:04 UTC (permalink / raw)
To: Markus Elfring, Can Peng, iommu, cocci, Jörg Rödel,
Robin Murphy, Will Deacon
Cc: LKML, kernel-janitors
On 1/12/2026 6:00 PM, Markus Elfring wrote:
>> Changes since v1:
>> - Extend the cleanup to iommu_group_show_resv_regions() as suggested by
>> reviewer, applying the same LIST_HEAD() pattern consistently across
>> the file.
>
> Thanks for your interest in further code adjustments.
>
> * I wonder how they fit to the feedback “Applied, thanks.” by Jörg Rödel
> from 2026-01-10.
> https://lore.kernel.org/lkml/stpavkxy3sbevk7zmt4kxyecqy5gc6phubvcfutbtnuk7vphlh@a7aimtvk423i/
> https://lkml.org/lkml/2026/1/10/235
Right. Patch is already applied. @Can, Please rebase patch on top of iommu/next
branch.
>
> * A shorter summary phrase might become more desirable for this patch variant.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.19-rc4#n687
>
> * Will development interests grow also for another transformation approach
> like the following by the means of the semantic patch language (Coccinelle software)?
>
>
> @replacement@
> expression e;
> identifier i;
> @@
> -struct list_head i;
> ... when exists
> when != i = e
> -INIT_LIST_HEAD
> +LIST_HEAD
> (
> - &
> i
> );
>
>
> I determined that 175 source files of the software “Linux next-20260109” contain
> corresponding update candidates.
Interesting! Thanks for the stat.
-Vasant
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-13 10:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-12 3:21 [PATCH v2] iommu: simplify list initialization in iommu_create_device_direct_mappings() and iommu_group_show_resv_regions() Can Peng
2026-01-12 5:29 ` Vasant Hegde
2026-01-12 12:30 ` Markus Elfring
2026-01-13 10:04 ` Vasant Hegde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®