Skip to contentSkip to conversation

drm: etnaviv: constify etnaviv_iommu_ops structures

PATCH In review Bhumika Goyal 2 participants 2 messages Jan 15, 2017 – Jan 16, 2017

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

PATCH 1/1 drm: etnaviv: constify etnaviv_iommu_ops structures

Declare etnaviv_iommu_ops structure as const as it is only used when the reference of one of its field is stored in the ops field of a iommu_domain structure. This ops field is of type const, so etnaviv_iommu_ops structures having similar properties can be declared const too.
Done using Coccinelle:

@r1 disable optional_qualifier@
identifier i;
position p;
@@
static struct etnaviv_iommu_ops i@p={...};

@ok1@
identifier r1.i;
position p;
struct etnaviv_iommu_domain x;
@@
x.domain.ops=&[email protected];

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct etnaviv_iommu_ops i;

Before and after size details of .o file remains the same after cross compiling for arm architecture.

---
 drivers/gpu/drm/etnaviv/etnaviv_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/etnaviv/etnaviv_iommu.c +1 -1
index 81f1583..7a7c97f 100644
@@ -184,7 +184,7 @@ static void etnaviv_iommuv1_dump(struct iommu_domain *domain, void *buf)
 	memcpy(buf, etnaviv_domain->pgtable.pgtable, PT_SIZE);
 }
 
-static struct etnaviv_iommu_ops etnaviv_iommu_ops = {
+static const struct etnaviv_iommu_ops etnaviv_iommu_ops = {
 	.ops = {
 		.domain_free = etnaviv_domain_free,
 		.map = etnaviv_iommuv1_map,
Signature · 1 line
1.9.1
maintainer
#1 lore raw

Am Montag, den 16.01.2017, 00:20 +0530 schrieb Bhumika Goyal:

Quoted 32 lines

Declare etnaviv_iommu_ops structure as const as it is only used when the reference of one of its field is stored in the ops field of a iommu_domain structure. This ops field is of type const, so etnaviv_iommu_ops structures having similar properties can be declared const too.
Done using Coccinelle:

@r1 disable optional_qualifier@
identifier i;
position p;
@@
static struct etnaviv_iommu_ops i@p={...};

@ok1@
identifier r1.i;
position p;
struct etnaviv_iommu_domain x;
@@
x.domain.ops=&[email protected];

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct etnaviv_iommu_ops i;

Quoted 4 lines

Before and after size details of .o file remains the same after cross compiling for arm architecture.

Thanks, I've applied this patch to my tree.

Quoted 17 lines
---
 drivers/gpu/drm/etnaviv/etnaviv_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/etnaviv/etnaviv_iommu.c +1 -1
index 81f1583..7a7c97f 100644
@@ -184,7 +184,7 @@ static void etnaviv_iommuv1_dump(struct iommu_domain *domain, void *buf)
 	memcpy(buf, etnaviv_domain->pgtable.pgtable, PT_SIZE);
 }
 
-static struct etnaviv_iommu_ops etnaviv_iommu_ops = {
+static const struct etnaviv_iommu_ops etnaviv_iommu_ops = {
 	.ops = {
 		.domain_free = etnaviv_domain_free,
 		.map = etnaviv_iommuv1_map,