[PATCH 1/3] ti-st: st_kim: use ERR_PTR(-ENOMEM) instead of NULL

From: JÃrg Billeter
Date: Wed Jun 24 2015 - 07:27:07 EST


This allows return of other error codes.

Signed-off-by: JÃrg Billeter <j@xxxxxxxxx>
---
drivers/misc/ti-st/st_kim.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
index 5027b8f..af71584 100644
--- a/drivers/misc/ti-st/st_kim.c
+++ b/drivers/misc/ti-st/st_kim.c
@@ -752,8 +752,11 @@ static struct ti_st_plat_data *get_platform_data(struct device *dev)
int len;

dt_pdata = kzalloc(sizeof(*dt_pdata), GFP_KERNEL);
- if (!dt_pdata)
- return NULL;
+
+ if (!dt_pdata) {
+ pr_err("Can't allocate device_tree platform data\n");
+ return ERR_PTR(-ENOMEM);
+ }

dt_property = of_get_property(np, "dev_name", &len);
if (dt_property)
@@ -773,10 +776,13 @@ static int kim_probe(struct platform_device *pdev)
struct ti_st_plat_data *pdata;
int err;

- if (pdev->dev.of_node)
+ if (pdev->dev.of_node) {
pdata = get_platform_data(&pdev->dev);
- else
+ if (IS_ERR(pdata))
+ return PTR_ERR(pdata);
+ } else {
pdata = pdev->dev.platform_data;
+ }

if (pdata == NULL) {
dev_err(&pdev->dev, "Platform Data is missing\n");
--
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/