Skip to contentSkip to conversation

mfd: arizona: Add sensible return value to some error paths

PATCH Superseded Charles Keepax 2 participants 3 messages Aug 12, 2016 – Aug 31, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: arizona: Add sensible return value to some error paths

There are some cases in arizona_dev_init, such as where we don't recognise the chip ID, in which we head to the error path without setting a sensible error code in ret. This would lead to the chip silently failing probe, as it would still return 0. Fix this up by adding appropriate sets of the return value.

---
 drivers/mfd/arizona-core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mfd/arizona-core.c +3 -0
index e4f97b3..34a2c26 100644
@@ -1121,6 +1121,7 @@ int arizona_dev_init(struct arizona *arizona)
 		break;
 	default:
 		dev_err(arizona->dev, "Unknown device ID: %x\n", reg);
+		ret = -EINVAL;
 		goto err_reset;
 	}
 
@@ -1280,12 +1281,14 @@ int arizona_dev_init(struct arizona *arizona)
 		break;
 	default:
 		dev_err(arizona->dev, "Unknown device ID %x\n", reg);
+		ret = -EINVAL;
 		goto err_reset;
 	}
 
 	if (!subdevs) {
 		dev_err(arizona->dev,
 			"No kernel support for device ID %x\n", reg);
+		ret = -EINVAL;
 		goto err_reset;
 	}
 
Signature · 1 line
2.1.4
#1 lore raw
Quoted 16 lines · Charles Keepax

There are some cases in arizona_dev_init, such as where we don't recognise the chip ID, in which we head to the error path without setting a sensible error code in ret. This would lead to the chip silently failing probe, as it would still return 0. Fix this up by adding appropriate sets of the return value.

---
 drivers/mfd/arizona-core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mfd/arizona-core.c +0 -0
index e4f97b3..34a2c26 100644

drivers/mfd/arizona-core.c int arizona_dev_init(struct arizona *arizona) · line 1124

Quoted 4 lines
drivers/mfd/arizona-core.c +1 -0
@@ -1121,6 +1121,7 @@ int arizona_dev_init(struct arizona *arizona)
 		break;
 	default:
 		dev_err(arizona->dev, "Unknown device ID: %x\n", reg);
+		ret = -EINVAL;

-EINVAL doesn't seem right here.

-ENODEV perhaps?

Quoted 18 lines
drivers/mfd/arizona-core.c +2 -0
 		goto err_reset;
 	}
 
@@ -1280,12 +1281,14 @@ int arizona_dev_init(struct arizona *arizona)
 		break;
 	default:
 		dev_err(arizona->dev, "Unknown device ID %x\n", reg);
+		ret = -EINVAL;
 		goto err_reset;
 	}
 
 	if (!subdevs) {
 		dev_err(arizona->dev,
 			"No kernel support for device ID %x\n", reg);
+		ret = -EINVAL;
 		goto err_reset;
 	}
 
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#2 lore raw
Quoted 24 lines · Lee Jones
Quoted 20 lines · Charles Keepax

There are some cases in arizona_dev_init, such as where we don't recognise the chip ID, in which we head to the error path without setting a sensible error code in ret. This would lead to the chip silently failing probe, as it would still return 0. Fix this up by adding appropriate sets of the return value.

---
 drivers/mfd/arizona-core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mfd/arizona-core.c +1 -0
index e4f97b3..34a2c26 100644
@@ -1121,6 +1121,7 @@ int arizona_dev_init(struct arizona *arizona)
 		break;
 	default:
 		dev_err(arizona->dev, "Unknown device ID: %x\n", reg);
+		ret = -EINVAL;

Review

Quoted 3 lines
(quoted diff) +0 -2
-EINVAL doesn't seem right here.
 
-ENODEV perhaps?

Yeah that does seem better, I will fire out another version.

Thanks,
Charles