Skip to contentSkip to conversation

gpio-sta2x11: don't use pdata if null

PATCH Applied Alessandro Rubini 2 participants 2 messages May 27, 2012 – Jul 5, 2012 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio-sta2x11: don't use pdata if null

If there is no platform data available, the driver shouldn't use the pointer or it will oops. Since things will mostly work nonetheless, (the BIOS may have set up the pins properly), I'd better not fail the probe even in this case.

---

(yes, I'm aware I have to patch this file to use irq_domain_add_linear)

 drivers/gpio/gpio-sta2x11.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/gpio/gpio-sta2x11.c +3 -2
index 38416be..6064fb3 100644
@@ -383,8 +383,9 @@ static int __devinit gsta_probe(struct platform_device *dev)
 	}
 	spin_lock_init(&chip->lock);
 	gsta_gpio_setup(chip);
-	for (i = 0; i < GSTA_NR_GPIO; i++)
-		gsta_set_config(chip, i, gpio_pdata->pinconfig[i]);
+	if (gpio_pdata)
+		for (i = 0; i < GSTA_NR_GPIO; i++)
+			gsta_set_config(chip, i, gpio_pdata->pinconfig[i]);
 
 	/* 384 was used in previous code: be compatible for other drivers */
 	err = irq_alloc_descs(-1, 384, GSTA_NR_GPIO, NUMA_NO_NODE);
Signature · 1 line
1.7.7.2