diff options
author | Milo Kim <milo.kim@ti.com> | 2015-08-25 01:54:12 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-08-25 14:36:24 -0400 |
commit | 804486b19de92449203f95027c2b207d8c5d5c79 (patch) | |
tree | d1119a87d91e9a01dfb225ea677d01b976fd218e /drivers/regulator/lp872x.c | |
parent | d9ffae15f7b1933c71dfb7c5e8ef61296d2833d7 (diff) |
regulator: lp872x: handle error case
If memory allocation gets failed on parsing the DT, then it returns error
'-ENOMEM' explicitly. Then, the driver exists from the _probe().
Signed-off-by: Milo Kim <milo.kim@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/lp872x.c')
-rw-r--r-- | drivers/regulator/lp872x.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index 9142c1adc70c..8702e7384af7 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c | |||
@@ -849,7 +849,7 @@ static struct lp872x_platform_data | |||
849 | 849 | ||
850 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | 850 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); |
851 | if (!pdata) | 851 | if (!pdata) |
852 | goto out; | 852 | return ERR_PTR(-ENOMEM); |
853 | 853 | ||
854 | of_property_read_u8(np, "ti,general-config", &pdata->general_config); | 854 | of_property_read_u8(np, "ti,general-config", &pdata->general_config); |
855 | if (of_find_property(np, "ti,update-config", NULL)) | 855 | if (of_find_property(np, "ti,update-config", NULL)) |
@@ -857,7 +857,7 @@ static struct lp872x_platform_data | |||
857 | 857 | ||
858 | pdata->dvs = devm_kzalloc(dev, sizeof(struct lp872x_dvs), GFP_KERNEL); | 858 | pdata->dvs = devm_kzalloc(dev, sizeof(struct lp872x_dvs), GFP_KERNEL); |
859 | if (!pdata->dvs) | 859 | if (!pdata->dvs) |
860 | goto out; | 860 | return ERR_PTR(-ENOMEM); |
861 | 861 | ||
862 | pdata->dvs->gpio = of_get_named_gpio(np, "ti,dvs-gpio", 0); | 862 | pdata->dvs->gpio = of_get_named_gpio(np, "ti,dvs-gpio", 0); |
863 | of_property_read_u8(np, "ti,dvs-vsel", (u8 *)&pdata->dvs->vsel); | 863 | of_property_read_u8(np, "ti,dvs-vsel", (u8 *)&pdata->dvs->vsel); |
@@ -910,11 +910,14 @@ static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id) | |||
910 | [LP8725] = LP8725_NUM_REGULATORS, | 910 | [LP8725] = LP8725_NUM_REGULATORS, |
911 | }; | 911 | }; |
912 | 912 | ||
913 | if (cl->dev.of_node) | 913 | if (cl->dev.of_node) { |
914 | pdata = lp872x_populate_pdata_from_dt(&cl->dev, | 914 | pdata = lp872x_populate_pdata_from_dt(&cl->dev, |
915 | (enum lp872x_id)id->driver_data); | 915 | (enum lp872x_id)id->driver_data); |
916 | else | 916 | if (IS_ERR(pdata)) |
917 | return PTR_ERR(pdata); | ||
918 | } else { | ||
917 | pdata = dev_get_platdata(&cl->dev); | 919 | pdata = dev_get_platdata(&cl->dev); |
920 | } | ||
918 | 921 | ||
919 | lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL); | 922 | lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL); |
920 | if (!lp) | 923 | if (!lp) |