From: Can Peng <pengcan@kylinos.cn>
To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com,
Markus.Elfring@web.de, vasant.hegde@amd.com
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
Can Peng <pengcan@kylinos.cn>
Subject: [PATCH v4] iommu: simplify list initialization across the iommu subsystem
Date: Fri, 16 Jan 2026 14:55:54 +0800 [thread overview]
Message-ID: <20260116065554.830579-1-pengcan@kylinos.cn> (raw)
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@kylinos.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
next reply other threads:[~2026-01-16 6:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 6:55 Can Peng [this message]
2026-01-16 8:02 ` Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260116065554.830579-1-pengcan@kylinos.cn \
--to=pengcan@kylinos.cn \
--cc=Markus.Elfring@web.de \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=vasant.hegde@amd.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®