Skip to content

Commit 1f9f758

Browse files
committed
drivers: mipi_dsi: stm32: don't mix HAL return value and errno
Correct mipi_dsi_stm32_host_init() and mipi_dsi_stm32_attach() to return a valid errno instead of mixing HAL return values and errno return values. Clarify HAL return value is of type HAL_StatusTypeDef and not an int in mipi_dsi_stm32_transfer(). Signed-off-by: Etienne Carriere <[email protected]>
1 parent db3641d commit 1f9f758

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

drivers/mipi_dsi/dsi_stm32.c

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ static int mipi_dsi_stm32_host_init(const struct device *dev)
137137
{
138138
const struct mipi_dsi_stm32_config *config = dev->config;
139139
struct mipi_dsi_stm32_data *data = dev->data;
140+
HAL_StatusTypeDef hal_ret;
140141
uint32_t hse_clock;
141142
int ret;
142143

@@ -184,46 +185,46 @@ static int mipi_dsi_stm32_host_init(const struct device *dev)
184185
LOG_WRN("DSI TX escape clock disabled.");
185186
}
186187

187-
ret = HAL_DSI_Init(&data->hdsi, &data->pll_init);
188-
if (ret != HAL_OK) {
189-
LOG_ERR("DSI init failed! (%d)", ret);
190-
return -ret;
188+
hal_ret = HAL_DSI_Init(&data->hdsi, &data->pll_init);
189+
if (hal_ret != HAL_OK) {
190+
LOG_ERR("DSI init failed! (%d)", hal_ret);
191+
return -EIO;
191192
}
192193

193194
if (data->host_timeouts) {
194-
ret = HAL_DSI_ConfigHostTimeouts(&data->hdsi, data->host_timeouts);
195-
if (ret != HAL_OK) {
196-
LOG_ERR("Set DSI host timeouts failed! (%d)", ret);
197-
return -ret;
195+
hal_ret = HAL_DSI_ConfigHostTimeouts(&data->hdsi, data->host_timeouts);
196+
if (hal_ret != HAL_OK) {
197+
LOG_ERR("Set DSI host timeouts failed! (%d)", hal_ret);
198+
return -EIO;
198199
}
199200
}
200201

201202
if (data->phy_timings) {
202-
ret = HAL_DSI_ConfigPhyTimer(&data->hdsi, data->phy_timings);
203-
if (ret != HAL_OK) {
204-
LOG_ERR("Set DSI PHY timings failed! (%d)", ret);
205-
return -ret;
203+
hal_ret = HAL_DSI_ConfigPhyTimer(&data->hdsi, data->phy_timings);
204+
if (hal_ret != HAL_OK) {
205+
LOG_ERR("Set DSI PHY timings failed! (%d)", hal_ret);
206+
return -EIO;
206207
}
207208
}
208209

209-
ret = HAL_DSI_ConfigFlowControl(&data->hdsi, DSI_FLOW_CONTROL_BTA);
210-
if (ret != HAL_OK) {
211-
LOG_ERR("Setup DSI flow control failed! (%d)", ret);
212-
return -ret;
210+
hal_ret = HAL_DSI_ConfigFlowControl(&data->hdsi, DSI_FLOW_CONTROL_BTA);
211+
if (hal_ret != HAL_OK) {
212+
LOG_ERR("Setup DSI flow control failed! (%d)", hal_ret);
213+
return -EIO;
213214
}
214215

215216
if (config->lp_rx_filter_freq) {
216-
ret = HAL_DSI_SetLowPowerRXFilter(&data->hdsi, config->lp_rx_filter_freq);
217-
if (ret != HAL_OK) {
218-
LOG_ERR("Setup DSI LP RX filter failed! (%d)", ret);
217+
hal_ret = HAL_DSI_SetLowPowerRXFilter(&data->hdsi, config->lp_rx_filter_freq);
218+
if (hal_ret != HAL_OK) {
219+
LOG_ERR("Setup DSI LP RX filter failed! (%d)", hal_ret);
219220
return -ret;
220221
}
221222
}
222223

223-
ret = HAL_DSI_ConfigErrorMonitor(&data->hdsi, config->active_errors);
224-
if (ret != HAL_OK) {
225-
LOG_ERR("Setup DSI error monitor failed! (%d)", ret);
226-
return -ret;
224+
hal_ret = HAL_DSI_ConfigErrorMonitor(&data->hdsi, config->active_errors);
225+
if (hal_ret != HAL_OK) {
226+
LOG_ERR("Setup DSI error monitor failed! (%d)", hal_ret);
227+
return -EIO;
227228
}
228229

229230
return 0;
@@ -236,7 +237,7 @@ static int mipi_dsi_stm32_attach(const struct device *dev, uint8_t channel,
236237
const struct mipi_dsi_stm32_config *config = dev->config;
237238
struct mipi_dsi_stm32_data *data = dev->data;
238239
DSI_VidCfgTypeDef *vcfg = &data->vid_cfg;
239-
int ret;
240+
HAL_StatusTypeDef ret;
240241

241242
if (!(mdev->mode_flags & MIPI_DSI_MODE_VIDEO)) {
242243
LOG_ERR("DSI host supports video mode only!");
@@ -286,7 +287,7 @@ static int mipi_dsi_stm32_attach(const struct device *dev, uint8_t channel,
286287
ret = HAL_DSI_ConfigVideoMode(&data->hdsi, vcfg);
287288
if (ret != HAL_OK) {
288289
LOG_ERR("Setup DSI video mode failed! (%d)", ret);
289-
return -ret;
290+
return -EIO;
290291
}
291292

292293
if (IS_ENABLED(CONFIG_MIPI_DSI_LOG_LEVEL_DBG)) {
@@ -296,14 +297,14 @@ static int mipi_dsi_stm32_attach(const struct device *dev, uint8_t channel,
296297
ret = HAL_DSI_Start(&data->hdsi);
297298
if (ret != HAL_OK) {
298299
LOG_ERR("Start DSI host failed! (%d)", ret);
299-
return -ret;
300+
return -EIO;
300301
}
301302

302303
if (config->test_pattern >= 0) {
303304
ret = HAL_DSI_PatternGeneratorStart(&data->hdsi, 0, config->test_pattern);
304305
if (ret != HAL_OK) {
305306
LOG_ERR("Start DSI pattern generator failed! (%d)", ret);
306-
return -ret;
307+
return -EIO;
307308
}
308309
}
309310

@@ -314,10 +315,10 @@ static ssize_t mipi_dsi_stm32_transfer(const struct device *dev, uint8_t channel
314315
struct mipi_dsi_msg *msg)
315316
{
316317
struct mipi_dsi_stm32_data *data = dev->data;
318+
HAL_StatusTypeDef ret;
317319
uint32_t param1 = 0;
318320
uint32_t param2 = 0;
319321
ssize_t len;
320-
int ret;
321322

322323
switch (msg->type) {
323324
case MIPI_DSI_DCS_READ:

0 commit comments

Comments
 (0)