[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260116065554.830579-1-pengcan@kylinos.cn>
Date: Fri, 16 Jan 2026 14:55:54 +0800
From: Can Peng <pengcan@...inos.cn>
To: joro@...tes.org,
will@...nel.org,
robin.murphy@....com,
Markus.Elfring@....de,
vasant.hegde@....com
Cc: iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org,
Can Peng <pengcan@...inos.cn>
Subject: [PATCH v4] iommu: simplify list initialization across the iommu subsystem
Replace separate list head declarations and INIT_LIST_HEAD() calls with
the combined LIST_HEAD() macro throughout the iommu directory.
Using LIST_HEAD() merges declaration and initialization into a single
statement, improving code readability and reducing boilerplate without
altering any functionality.
No functional change intended.
Signed-off-by: Can Peng <pengcan@...inos.cn>
---
Changes since previous version:
Rebased on top of iommu/next as requested by Vasant Hegde.
Adjusted commit message to be shorter and clearer, following Markus Elfring's suggestion.
Retained the LIST_HEAD() cleanup pattern consistently across the iommu directory.
Notes on prior discussion (from chat history):
The earlier version was reviewed positively:
Link: https://lore.kernel.org/all/4526ca31-71a4-4b3f-b378-32546eb8133d@amd.com/
Markus Elfring suggested using a more concise summary and
recommended the use of Coccinelle for this kind of transformation.
Best regards,
Can Peng
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 +--
drivers/iommu/arm/arm-smmu/arm-smmu.c | 3 +--
drivers/iommu/iommu.c | 6 ++----
drivers/iommu/iommufd/eventq.c | 3 +--
4 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index fc5a705f6cb3..a772010b5331 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -4659,10 +4659,9 @@ static void __iomem *arm_smmu_ioremap(struct device *dev, resource_size_t start,
static void arm_smmu_rmr_install_bypass_ste(struct arm_smmu_device *smmu)
{
- struct list_head rmr_list;
+ LIST_HEAD(rmr_list);
struct iommu_resv_region *e;
- INIT_LIST_HEAD(&rmr_list);
iort_get_rmr_sids(dev_fwnode(smmu->dev), &rmr_list);
list_for_each_entry(e, &rmr_list, list) {
diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 5e690cf85ec9..d7e58ac1e14a 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -2072,12 +2072,11 @@ static int arm_smmu_device_dt_probe(struct arm_smmu_device *smmu,
static void arm_smmu_rmr_install_bypass_smr(struct arm_smmu_device *smmu)
{
- struct list_head rmr_list;
+ LIST_HEAD(rmr_list);
struct iommu_resv_region *e;
int idx, cnt = 0;
u32 reg;
- INIT_LIST_HEAD(&rmr_list);
iort_get_rmr_sids(dev_fwnode(smmu->dev), &rmr_list);
/*
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 4926a43118e6..2652ab6f5dde 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -932,7 +932,7 @@ int iommu_get_group_resv_regions(struct iommu_group *group,
mutex_lock(&group->mutex);
for_each_group_device(group, device) {
- struct list_head dev_resv_regions;
+ LIST_HEAD(dev_resv_regions);
/*
* Non-API groups still expose reserved_regions in sysfs,
@@ -941,7 +941,6 @@ int iommu_get_group_resv_regions(struct iommu_group *group,
if (!dev_has_iommu(device->dev))
break;
- INIT_LIST_HEAD(&dev_resv_regions);
iommu_get_resv_regions(device->dev, &dev_resv_regions);
ret = iommu_insert_device_resv_regions(&dev_resv_regions, head);
iommu_put_resv_regions(device->dev, &dev_resv_regions);
@@ -957,10 +956,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) {
diff --git a/drivers/iommu/iommufd/eventq.c b/drivers/iommu/iommufd/eventq.c
index e23d9ee4fe38..95a9ee581072 100644
--- a/drivers/iommu/iommufd/eventq.c
+++ b/drivers/iommu/iommufd/eventq.c
@@ -21,12 +21,11 @@ void iommufd_auto_response_faults(struct iommufd_hw_pagetable *hwpt,
{
struct iommufd_fault *fault = hwpt->fault;
struct iopf_group *group, *next;
- struct list_head free_list;
+ LIST_HEAD(free_list);
unsigned long index;
if (!fault || !handle)
return;
- INIT_LIST_HEAD(&free_list);
mutex_lock(&fault->mutex);
spin_lock(&fault->common.lock);
--
2.25.1
Powered by blists - more mailing lists