Commit beee3909 authored by Timur Tabi's avatar Timur Tabi Committed by Linus Walleij

pinctrl: qcom: qdf2xxx: improve error checking and reporting

The driver doesn't report an error message if the ACPI tables are missing
the num-gpios property (which indicates how many GPIOs there are on this
SOC), and it didn't check to ensure that the mallocs didn't fail.
Signed-off-by: default avatarTimur Tabi <timur@codeaurora.org>
Reviewed-by: default avatarBjörn Andersson <bjorn.andersson@sonymobile.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 57b588c9
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
static struct msm_pinctrl_soc_data qdf2xxx_pinctrl; static struct msm_pinctrl_soc_data qdf2xxx_pinctrl;
/* A reasonable limit to the number of GPIOS */
#define MAX_GPIOS 256
static int qdf2xxx_pinctrl_probe(struct platform_device *pdev) static int qdf2xxx_pinctrl_probe(struct platform_device *pdev)
{ {
struct pinctrl_pin_desc *pins; struct pinctrl_pin_desc *pins;
...@@ -42,11 +45,13 @@ static int qdf2xxx_pinctrl_probe(struct platform_device *pdev) ...@@ -42,11 +45,13 @@ static int qdf2xxx_pinctrl_probe(struct platform_device *pdev)
/* Query the number of GPIOs from ACPI */ /* Query the number of GPIOs from ACPI */
ret = device_property_read_u32(&pdev->dev, "num-gpios", &num_gpios); ret = device_property_read_u32(&pdev->dev, "num-gpios", &num_gpios);
if (ret < 0) if (ret < 0) {
dev_warn(&pdev->dev, "missing num-gpios property\n");
return ret; return ret;
}
if (!num_gpios) { if (!num_gpios || num_gpios > MAX_GPIOS) {
dev_warn(&pdev->dev, "missing num-gpios property\n"); dev_warn(&pdev->dev, "invalid num-gpios property\n");
return -ENODEV; return -ENODEV;
} }
...@@ -55,6 +60,9 @@ static int qdf2xxx_pinctrl_probe(struct platform_device *pdev) ...@@ -55,6 +60,9 @@ static int qdf2xxx_pinctrl_probe(struct platform_device *pdev)
groups = devm_kcalloc(&pdev->dev, num_gpios, groups = devm_kcalloc(&pdev->dev, num_gpios,
sizeof(struct msm_pingroup), GFP_KERNEL); sizeof(struct msm_pingroup), GFP_KERNEL);
if (!pins || !groups)
return -ENOMEM;
for (i = 0; i < num_gpios; i++) { for (i = 0; i < num_gpios; i++) {
pins[i].number = i; pins[i].number = i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment