Skip to contentSkip to conversation

power: supply: lp8788: make const array name static

PATCH In review Colin Ian King 2 participants 2 messages Oct 5, 2022 – Oct 28, 2022

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

PATCH 1/1 power: supply: lp8788: make const array name static

Don't populate the read-only array name on the stack but instead make it static. Since the data and the pointers don't change also add in a missing const. Also makes the object code a little smaller.

---
 drivers/power/supply/lp8788-charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/lp8788-charger.c +1 -1
index 56c57529c228..802c9491fcdb 100644
@@ -520,7 +520,7 @@ static int lp8788_set_irqs(struct platform_device *pdev,
 static int lp8788_irq_register(struct platform_device *pdev,
 				struct lp8788_charger *pchg)
 {
-	const char *name[] = {
+	static const char * const name[] = {
 		LP8788_CHG_IRQ, LP8788_PRSW_IRQ, LP8788_BATT_IRQ
 	};
 	int i;
Signature · 1 line
2.37.3
#1 lore raw

Hi,

Quoted 6 lines · Colin Ian King

Don't populate the read-only array name on the stack but instead make it static. Since the data and the pointers don't change also add in a missing const. Also makes the object code a little smaller.

---

Thanks, queued.

-- Sebastian

Quoted 19 lines
 drivers/power/supply/lp8788-charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/lp8788-charger.c +1 -1
index 56c57529c228..802c9491fcdb 100644
@@ -520,7 +520,7 @@ static int lp8788_set_irqs(struct platform_device *pdev,
 static int lp8788_irq_register(struct platform_device *pdev,
 				struct lp8788_charger *pchg)
 {
-	const char *name[] = {
+	static const char * const name[] = {
 		LP8788_CHG_IRQ, LP8788_PRSW_IRQ, LP8788_BATT_IRQ
 	};
 	int i;
Signature · 1 line
2.37.3