aboutsummaryrefslogtreecommitdiffstats
path: root/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0067-ti-st-use-proper-way-to-get-shutdown-gpio.patch
blob: 4d9905480fcae60b06c20e288a0b50347e093af4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From 36a9b5317c58a1cdcb8a6fa05416efd524480fbe Mon Sep 17 00:00:00 2001
From: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Date: Wed, 2 Aug 2017 17:39:56 +0300
Subject: [PATCH] ti-st: use proper way to get shutdown gpio

Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
---
 drivers/misc/ti-st/st_kim.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
index cb2734568471..03b21d314b0b 100644
--- a/drivers/misc/ti-st/st_kim.c
+++ b/drivers/misc/ti-st/st_kim.c
@@ -32,6 +32,8 @@
 #include <linux/sched.h>
 #include <linux/sysfs.h>
 #include <linux/tty.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 
 #include <linux/skbuff.h>
 #include <linux/ti_wilink_st.h>
@@ -749,18 +751,29 @@ static struct ti_st_plat_data *get_platform_data(struct device *dev)
 
 	dt_pdata = kzalloc(sizeof(*dt_pdata), GFP_KERNEL);
 
-	if (!dt_pdata)
+	if (!dt_pdata) {
 		pr_err("Can't allocate device_tree platform data\n");
+		return NULL;
+	}
 
 	dt_property = of_get_property(np, "dev_name", &len);
-	if (dt_property)
-		memcpy(&dt_pdata->dev_name, dt_property, len);
-	of_property_read_u32(np, "nshutdown_gpio",
-			     (u32 *)&dt_pdata->nshutdown_gpio);
+	if (!dt_property) {
+		dev_err(dev, "failed to get tty name\n");
+		goto err;
+	}
+	memcpy(&dt_pdata->dev_name, dt_property, len);
+	dt_pdata->nshutdown_gpio = of_get_named_gpio(np, "shutdown-gpios", 0);
+	if (!gpio_is_valid(dt_pdata->nshutdown_gpio)) {
+		dev_err(dev, "failed to get shutdown gpio\n");
+		goto err;
+	}
 	of_property_read_u32(np, "flow_cntrl", (u32 *)&dt_pdata->flow_cntrl);
 	of_property_read_u32(np, "baud_rate", (u32 *)&dt_pdata->baud_rate);
 
 	return dt_pdata;
+err:
+	kfree(dt_pdata);
+	return NULL;
 }
 
 static struct dentry *kim_debugfs_dir;
-- 
2.13.0