aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2431-amdgpu-dc-cleanup-construct-returns-in-gpio.patch
blob: 0fc0b34fe2a5f9d62e58eaf7d2795ea6598eb5ef (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
From 7ae78f973420cb42b4cdbaf493b5b99fd055dff2 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Fri, 29 Sep 2017 14:34:38 +1000
Subject: [PATCH 2431/4131] amdgpu/dc: cleanup construct returns in gpio.

This is similiar to previous patches, don't return when we don't
need to, also do error checking before allocating memory, makes
it simpler to cleanup after.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
---
 drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c  | 33 +++++++------------
 drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.c |  4 +--
 drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.h |  2 +-
 drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c  | 47 ++++++++++-----------------
 4 files changed, 30 insertions(+), 56 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
index 7b6efa4..310f489 100644
--- a/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
+++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
@@ -199,25 +199,14 @@ static const struct hw_gpio_pin_funcs funcs = {
 	.close = dal_hw_gpio_close,
 };
 
-static bool construct(
+static void construct(
 	struct hw_ddc *ddc,
 	enum gpio_id id,
 	uint32_t en,
 	struct dc_context *ctx)
 {
-	if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) {
-		ASSERT_CRITICAL(false);
-		return false;
-	}
-
-	if (!dal_hw_gpio_construct(&ddc->base, id, en, ctx)) {
-		ASSERT_CRITICAL(false);
-		return false;
-	}
-
+	dal_hw_gpio_construct(&ddc->base, id, en, ctx);
 	ddc->base.base.funcs = &funcs;
-
-	return true;
 }
 
 struct hw_gpio_pin *dal_hw_ddc_create(
@@ -225,19 +214,19 @@ struct hw_gpio_pin *dal_hw_ddc_create(
 	enum gpio_id id,
 	uint32_t en)
 {
-	struct hw_ddc *pin = kzalloc(sizeof(struct hw_ddc), GFP_KERNEL);
+	struct hw_ddc *pin;
 
-	if (!pin) {
+	if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) {
 		ASSERT_CRITICAL(false);
 		return NULL;
 	}
 
-	if (construct(pin, id, en, ctx))
-		return &pin->base.base;
-
-	ASSERT_CRITICAL(false);
-
-	kfree(pin);
+	pin = kzalloc(sizeof(struct hw_ddc), GFP_KERNEL);
+	if (!pin) {
+		ASSERT_CRITICAL(false);
+		return NULL;
+	}
 
-	return NULL;
+	construct(pin, id, en, ctx);
+	return &pin->base.base;
 }
diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.c
index 4cdcdfb..6605108 100644
--- a/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.c
+++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.c
@@ -176,7 +176,7 @@ enum gpio_result dal_hw_gpio_config_mode(
 	}
 }
 
-bool dal_hw_gpio_construct(
+void dal_hw_gpio_construct(
 	struct hw_gpio *pin,
 	enum gpio_id id,
 	uint32_t en,
@@ -194,8 +194,6 @@ bool dal_hw_gpio_construct(
 	pin->store.mux = 0;
 
 	pin->mux_supported = false;
-
-	return true;
 }
 
 void dal_hw_gpio_destruct(
diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.h b/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.h
index fb41ee2..bca0cef 100644
--- a/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.h
+++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.h
@@ -109,7 +109,7 @@ struct hw_gpio {
 #define HW_GPIO_FROM_BASE(hw_gpio_pin) \
 	container_of((hw_gpio_pin), struct hw_gpio, base)
 
-bool dal_hw_gpio_construct(
+void dal_hw_gpio_construct(
 	struct hw_gpio *pin,
 	enum gpio_id id,
 	uint32_t en,
diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c
index 0c255c0..784fecc 100644
--- a/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c
+++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c
@@ -41,15 +41,13 @@
 #define REG(reg)\
 	(hpd->regs->reg)
 
-static bool dal_hw_hpd_construct(
+static void dal_hw_hpd_construct(
 	struct hw_hpd *pin,
 	enum gpio_id id,
 	uint32_t en,
 	struct dc_context *ctx)
 {
-	if (!dal_hw_gpio_construct(&pin->base, id, en, ctx))
-		return false;
-	return true;
+	dal_hw_gpio_construct(&pin->base, id, en, ctx);
 }
 
 static void dal_hw_hpd_destruct(
@@ -126,30 +124,14 @@ static const struct hw_gpio_pin_funcs funcs = {
 	.close = dal_hw_gpio_close,
 };
 
-static bool construct(
+static void construct(
 	struct hw_hpd *hpd,
 	enum gpio_id id,
 	uint32_t en,
 	struct dc_context *ctx)
 {
-	if (id != GPIO_ID_HPD) {
-		ASSERT_CRITICAL(false);
-		return false;
-	}
-
-	if ((en < GPIO_HPD_MIN) || (en > GPIO_HPD_MAX)) {
-		ASSERT_CRITICAL(false);
-		return false;
-	}
-
-	if (!dal_hw_hpd_construct(hpd, id, en, ctx)) {
-		ASSERT_CRITICAL(false);
-		return false;
-	}
-
+	dal_hw_hpd_construct(hpd, id, en, ctx);
 	hpd->base.base.funcs = &funcs;
-
-	return true;
 }
 
 struct hw_gpio_pin *dal_hw_hpd_create(
@@ -157,19 +139,24 @@ struct hw_gpio_pin *dal_hw_hpd_create(
 	enum gpio_id id,
 	uint32_t en)
 {
-	struct hw_hpd *hpd = kzalloc(sizeof(struct hw_hpd), GFP_KERNEL);
+	struct hw_hpd *hpd;
 
-	if (!hpd) {
+	if (id != GPIO_ID_HPD) {
 		ASSERT_CRITICAL(false);
 		return NULL;
 	}
 
-	if (construct(hpd, id, en, ctx))
-		return &hpd->base.base;
-
-	ASSERT_CRITICAL(false);
+	if ((en < GPIO_HPD_MIN) || (en > GPIO_HPD_MAX)) {
+		ASSERT_CRITICAL(false);
+		return NULL;
+	}
 
-	kfree(hpd);
+	hpd = kzalloc(sizeof(struct hw_hpd), GFP_KERNEL);
+	if (!hpd) {
+		ASSERT_CRITICAL(false);
+		return NULL;
+	}
 
-	return NULL;
+	construct(hpd, id, en, ctx);
+	return &hpd->base.base;
 }
-- 
2.7.4