Skip to contentSkip to conversation

drivers/iommu: Constify structs

PATCH Applied Rikard Falkeborn 4 participants 6 messages May 25, 2020 – May 27, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover drivers/iommu: Constify structs

Constify some structs with function pointers to allow the compiler to put them in read-only memory. There is not dependency between the patches.

Rikard Falkeborn (2):
iommu/hyper-v: Constify hyperv_ir_domain_ops
iommu/sun50i: Constify sun50i_iommu_ops

 drivers/iommu/hyperv-iommu.c | 2 +-
 drivers/iommu/sun50i-iommu.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/2 iommu/hyper-v: Constify hyperv_ir_domain_ops

The struct hyperv_ir_domain_ops is not modified and can be made const to allow the compiler to put it in read-only memory.

Before:
text data bss dec hex filename
2916 1180 1120 5216 1460 drivers/iommu/hyperv-iommu.o

After:
text data bss dec hex filename
3044 1052 1120 5216 1460 drivers/iommu/hyperv-iommu.o

---
 drivers/iommu/hyperv-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/hyperv-iommu.c +1 -1
index a386b83e0e34..3c0c67a99c7b 100644
@@ -131,7 +131,7 @@ static int hyperv_irq_remapping_activate(struct irq_domain *domain,
 	return 0;
 }
 
-static struct irq_domain_ops hyperv_ir_domain_ops = {
+static const struct irq_domain_ops hyperv_ir_domain_ops = {
 	.alloc = hyperv_irq_remapping_alloc,
 	.free = hyperv_irq_remapping_free,
 	.activate = hyperv_irq_remapping_activate,
Signature · 1 line
2.26.2
maintainer Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] iommu/hyper-v: Constify hyperv_ir_domain_ops

Quoted 7 lines · Rikard Falkeborn

The struct hyperv_ir_domain_ops is not modified and can be made const to allow the compiler to put it in read-only memory.

Before:
text data bss dec hex filename
2916 1180 1120 5216 1460 drivers/iommu/hyperv-iommu.o

Quoted 5 lines

After:
text data bss dec hex filename
3044 1052 1120 5216 1460 drivers/iommu/hyperv-iommu.o

Quoted 20 lines
---
 drivers/iommu/hyperv-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/hyperv-iommu.c +1 -1
index a386b83e0e34..3c0c67a99c7b 100644
@@ -131,7 +131,7 @@ static int hyperv_irq_remapping_activate(struct irq_domain *domain,
 	return 0;
 }
 
-static struct irq_domain_ops hyperv_ir_domain_ops = {
+static const struct irq_domain_ops hyperv_ir_domain_ops = {
 	.alloc = hyperv_irq_remapping_alloc,
 	.free = hyperv_irq_remapping_free,
 	.activate = hyperv_irq_remapping_activate,
Signature · 1 line
2.26.2
#3 lore raw

PATCH 2/2 iommu/sun50i: Constify sun50i_iommu_ops

In reply to Rikard Falkeborn

The struct sun50i_iommu_ops is not modified and can be made const to allow the compiler to put it in read-only memory.

Before:
text data bss dec hex filename
14358 2501 64 16923 421b drivers/iommu/sun50i-iommu.o

After:
text data bss dec hex filename
14726 2117 64 16907 420b drivers/iommu/sun50i-iommu.o

---
 drivers/iommu/sun50i-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/sun50i-iommu.c +1 -1
index 1fa09ddcebd4..fce605e96aa2 100644
@@ -771,7 +771,7 @@ static int sun50i_iommu_of_xlate(struct device *dev,
 	return iommu_fwspec_add_ids(dev, &id, 1);
 }
 
-static struct iommu_ops sun50i_iommu_ops = {
+static const struct iommu_ops sun50i_iommu_ops = {
 	.pgsize_bitmap	= SZ_4K,
 	.attach_dev	= sun50i_iommu_attach_device,
 	.detach_dev	= sun50i_iommu_detach_device,
Signature · 1 line
2.26.2
Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] iommu/sun50i: Constify sun50i_iommu_ops

Quoted 7 lines · Rikard Falkeborn

The struct sun50i_iommu_ops is not modified and can be made const to allow the compiler to put it in read-only memory.

Before:
text data bss dec hex filename
14358 2501 64 16923 421b drivers/iommu/sun50i-iommu.o

Quoted 5 lines

After:
text data bss dec hex filename
14726 2117 64 16907 420b drivers/iommu/sun50i-iommu.o

Thanks!
Maxime

maintainer Applied
#5 lore raw
In reply to Rikard Falkeborn
Quoted 11 lines · Rikard Falkeborn

Constify some structs with function pointers to allow the compiler to put them in read-only memory. There is not dependency between the patches.

Rikard Falkeborn (2):
iommu/hyper-v: Constify hyperv_ir_domain_ops
iommu/sun50i: Constify sun50i_iommu_ops

 drivers/iommu/hyperv-iommu.c | 2 +-
 drivers/iommu/sun50i-iommu.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Applied both, thanks.