Skip to contentSkip to conversation

regulator: da9052: remove null pointer check on array pdata->regulators

PATCH In review Colin King 2 participants 2 messages Sep 8, 2016 – Sep 12, 2016

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 regulator: da9052: remove null pointer check on array pdata->regulators

From: Colin Ian King <[email protected]>

pdata->regulators is an array of DA9052_MAX_REGULATORS struct regulator_init_data pointers hence cannot be null, so the null pointer check on pdata->regulators is redundant. Remove it.

---
 drivers/regulator/da9052-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/da9052-regulator.c +1 -1
index 9ececfe..37e4025 100644
@@ -420,7 +420,7 @@ static int da9052_regulator_probe(struct platform_device *pdev)
 	config.dev = &pdev->dev;
 	config.driver_data = regulator;
 	config.regmap = da9052->regmap;
-	if (pdata && pdata->regulators) {
+	if (pdata) {
 		config.init_data = pdata->regulators[cell->id];
 	} else {
 #ifdef CONFIG_OF
Signature · 1 line
2.9.3
maintainer
#1 lore raw

drivers/regulator/da9052-regulator.c static int da9052_regulator_probe(struct platform_device *pdev) · line 423

Quoted 6 lines · Colin King

pdata->regulators is an array of DA9052_MAX_REGULATORS struct regulator_init_data pointers hence cannot be null, so the null pointer check on pdata->regulators is redundant. Remove it.

drivers/regulator/da9052-regulator.c +1 -1
-	if (pdata && pdata->regulators) {
+	if (pdata) {

What is the benefit of this change? Due to the way C handles arrays and pointers one can't immediately tell without opening up the header file if regulators is a pointer to an array or an embedded array so it's more work to read and since this is the probe path it's unlikely to be a meaningful speed improvement even if the compiler doesn't figure it out at build time.