Skip to contentSkip to conversation

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

PATCH Applied Charles Keepax 2 participants 2 messages Aug 31, 2016

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

PATCH v2 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.

Whilst adding these update the existing paths that do return an error when the chip is not recognised to use ENODEV, which seems like a better fit.

---

Changes since v1:
- Update return codes to use ENODEV rather than EINVAL.

Thanks,
Charles

 drivers/mfd/arizona-core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mfd/arizona-core.c +4 -1
index e4f97b3..cdbb8a2 100644
@@ -1035,7 +1035,7 @@ int arizona_dev_init(struct arizona *arizona)
 	default:
 		dev_err(arizona->dev, "Unknown device type %d\n",
 			arizona->type);
-		return -EINVAL;
+		return -ENODEV;
 	}
 
 	/* Mark DCVDD as external, LDO1 driver will clear if internal */
@@ -1121,6 +1121,7 @@ int arizona_dev_init(struct arizona *arizona)
 		break;
 	default:
 		dev_err(arizona->dev, "Unknown device ID: %x\n", reg);
+		ret = -ENODEV;
 		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 = -ENODEV;
 		goto err_reset;
 	}
 
 	if (!subdevs) {
 		dev_err(arizona->dev,
 			"No kernel support for device ID %x\n", reg);
+		ret = -ENODEV;
 		goto err_reset;
 	}
 
Signature · 1 line
2.1.4
Applied
#1 lore raw
Quoted 13 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.

Whilst adding these update the existing paths that do return an error when the chip is not recognised to use ENODEV, which seems like a better fit.

---

Quoted 8 lines

Changes since v1:
- Update return codes to use ENODEV rather than EINVAL.

Thanks,
Charles

 drivers/mfd/arizona-core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Applied, thanks.

Quoted 36 lines
drivers/mfd/arizona-core.c +4 -1
index e4f97b3..cdbb8a2 100644
@@ -1035,7 +1035,7 @@ int arizona_dev_init(struct arizona *arizona)
 	default:
 		dev_err(arizona->dev, "Unknown device type %d\n",
 			arizona->type);
-		return -EINVAL;
+		return -ENODEV;
 	}
 
 	/* Mark DCVDD as external, LDO1 driver will clear if internal */
@@ -1121,6 +1121,7 @@ int arizona_dev_init(struct arizona *arizona)
 		break;
 	default:
 		dev_err(arizona->dev, "Unknown device ID: %x\n", reg);
+		ret = -ENODEV;
 		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 = -ENODEV;
 		goto err_reset;
 	}
 
 	if (!subdevs) {
 		dev_err(arizona->dev,
 			"No kernel support for device ID %x\n", reg);
+		ret = -ENODEV;
 		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