Skip to contentSkip to conversation

MIPS: Constify static irq_domain_ops structs

PATCH In review Rikard Falkeborn 2 participants 5 messages Feb 7, 2022 – Feb 22, 2022 MIPS

lore
Share & tools
lore
#0 lore raw

cover MIPS: Constify static irq_domain_ops structs

Constify a number of static irq_domain_ops structs that were never modified. This allows the compiler to put them in read-only memory.

Rikard Falkeborn (3):
MIPS: OCTEON: Constify static irq_domain_ops
MIPS: ath25: Constify static irq_domain_ops
MIPS: pci-ar2315: Constify static irq_domain_ops

 arch/mips/ath25/ar2315.c             |  2 +-
 arch/mips/ath25/ar5312.c             |  2 +-
 arch/mips/cavium-octeon/octeon-irq.c | 10 +++++-----
 arch/mips/pci/pci-ar2315.c           |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/3 MIPS: OCTEON: Constify static irq_domain_ops

The only usage of these structs is to pass their address to either irq_domain_add_tree() or irq_domain_create_linear(), both which takes pointers to const struct irq_domain_ops. Make them const to allow the compiler to put them in read-only memory.

---
 arch/mips/cavium-octeon/octeon-irq.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/mips/cavium-octeon/octeon-irq.c +5 -5
index 844f882096e6..07d7ff5a981d 100644
@@ -1274,13 +1274,13 @@ static int octeon_irq_gpio_map(struct irq_domain *d,
 	return r;
 }
 
-static struct irq_domain_ops octeon_irq_domain_ciu_ops = {
+static const struct irq_domain_ops octeon_irq_domain_ciu_ops = {
 	.map = octeon_irq_ciu_map,
 	.unmap = octeon_irq_free_cd,
 	.xlate = octeon_irq_ciu_xlat,
 };
 
-static struct irq_domain_ops octeon_irq_domain_gpio_ops = {
+static const struct irq_domain_ops octeon_irq_domain_gpio_ops = {
 	.map = octeon_irq_gpio_map,
 	.unmap = octeon_irq_free_cd,
 	.xlate = octeon_irq_gpio_xlat,
@@ -1974,7 +1974,7 @@ static int octeon_irq_ciu2_map(struct irq_domain *d,
 	return 0;
 }
 
-static struct irq_domain_ops octeon_irq_domain_ciu2_ops = {
+static const struct irq_domain_ops octeon_irq_domain_ciu2_ops = {
 	.map = octeon_irq_ciu2_map,
 	.unmap = octeon_irq_free_cd,
 	.xlate = octeon_irq_ciu2_xlat,
@@ -2226,7 +2226,7 @@ static int octeon_irq_cib_map(struct irq_domain *d,
 	return 0;
 }
 
-static struct irq_domain_ops octeon_irq_domain_cib_ops = {
+static const struct irq_domain_ops octeon_irq_domain_cib_ops = {
 	.map = octeon_irq_cib_map,
 	.unmap = octeon_irq_free_cd,
 	.xlate = octeon_irq_cib_xlat,
@@ -2578,7 +2578,7 @@ static int octeon_irq_ciu3_map(struct irq_domain *d,
 	return octeon_irq_ciu3_mapx(d, virq, hw, &octeon_irq_chip_ciu3);
 }
 
-static struct irq_domain_ops octeon_dflt_domain_ciu3_ops = {
+static const struct irq_domain_ops octeon_dflt_domain_ciu3_ops = {
 	.map = octeon_irq_ciu3_map,
 	.unmap = octeon_irq_free_cd,
 	.xlate = octeon_irq_ciu3_xlat,
Signature · 1 line
2.35.1
#2 lore raw

PATCH 2/3 MIPS: ath25: Constify static irq_domain_ops

In reply to Rikard Falkeborn

The only usage of these structs is to pass their address to either irq_domain_add_tree() or irq_domain_create_linear(), both which takes pointers to const struct irq_domain_ops. Make them const to allow the compiler to put them in read-only memory.

---
 arch/mips/ath25/ar2315.c | 2 +-
 arch/mips/ath25/ar5312.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/ath25/ar2315.c +1 -1
index 76e43a73ba1b..8ccf167c167e 100644
@@ -112,7 +112,7 @@ static int ar2315_misc_irq_map(struct irq_domain *d, unsigned irq,
 	return 0;
 }
 
-static struct irq_domain_ops ar2315_misc_irq_domain_ops = {
+static const struct irq_domain_ops ar2315_misc_irq_domain_ops = {
 	.map = ar2315_misc_irq_map,
 };
 
arch/mips/ath25/ar5312.c +1 -1
index 822b639dbd1e..cfa103518113 100644
@@ -116,7 +116,7 @@ static int ar5312_misc_irq_map(struct irq_domain *d, unsigned irq,
 	return 0;
 }
 
-static struct irq_domain_ops ar5312_misc_irq_domain_ops = {
+static const struct irq_domain_ops ar5312_misc_irq_domain_ops = {
 	.map = ar5312_misc_irq_map,
 };
 
Signature · 1 line
2.35.1
#3 lore raw

PATCH 3/3 MIPS: pci-ar2315: Constify static irq_domain_ops

In reply to Rikard Falkeborn

The only usage of ar2315_pci_irq_domain_ops is to pass its address to irq_domain_add_linear() which takes a pointer to const struct irq_domain_ops. Make it const to allow the compiler to put it in read-only memory.

---
 arch/mips/pci/pci-ar2315.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/pci/pci-ar2315.c +1 -1
index 9a4bfb4e63e3..30e0922f4cea 100644
@@ -384,7 +384,7 @@ static int ar2315_pci_irq_map(struct irq_domain *d, unsigned irq,
 	return 0;
 }
 
-static struct irq_domain_ops ar2315_pci_irq_domain_ops = {
+static const struct irq_domain_ops ar2315_pci_irq_domain_ops = {
 	.map = ar2315_pci_irq_map,
 };
 
Signature · 1 line
2.35.1
#4 lore raw
In reply to Rikard Falkeborn
Quoted 8 lines · Rikard Falkeborn

Constify a number of static irq_domain_ops structs that were never modified. This allows the compiler to put them in read-only memory.

Rikard Falkeborn (3):
MIPS: OCTEON: Constify static irq_domain_ops
MIPS: ath25: Constify static irq_domain_ops
MIPS: pci-ar2315: Constify static irq_domain_ops

Quoted 5 lines
 arch/mips/ath25/ar2315.c             |  2 +-
 arch/mips/ath25/ar5312.c             |  2 +-
 arch/mips/cavium-octeon/octeon-irq.c | 10 +++++-----
 arch/mips/pci/pci-ar2315.c           |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

series applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]