[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2067dfae-5399-434e-afc3-ca6a5816f78f@web.de>
Date: Fri, 16 Jan 2026 09:02:30 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: Can Peng <pengcan@...inos.cn>, iommu@...ts.linux.dev,
Jörg Rödel <joro@...tes.org>,
Robin Murphy <robin.murphy@....com>, Vasant Hegde <vasant.hegde@....com>,
Will Deacon <will@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>, kernel-janitors@...r.kernel.org
Subject: Re: [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.
…
> Markus Elfring suggested using a more concise summary and
> recommended the use of Coccinelle for this kind of transformation.
Some development tools can help to achieve desirable changes in more convenient ways
and that possible adjustments would become more complete eventually.
…
> +++ 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);
…
> +++ 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);
…
Does anything hinder to apply LIST_HEAD() calls at other source code positions?
May variable scopes be reduced for more use cases?
Regards,
Markus
Powered by blists - more mailing lists