configs: Review all implementations of board_lcd_initialize(). The NuttX convention is that all internal functions that return errors as an 'int' must return a negated errno value on failure and a non-negative value on success. Most were right but eight of them had cloned logic that returns 1 on success and zero on failure... both of which are interpreted as success by the caller since they are non-negative.

This commit is contained in:
Gregory Nutt 2018-04-21 18:03:01 -06:00
parent 1a879a3b52
commit 505f460b6b
8 changed files with 19 additions and 20 deletions

View File

@ -1,7 +1,7 @@
/************************************************************************************
* configs/hymini-stm32v/src/stm32_r61505u.c
*
* Copyright (C) 2009, 2011, 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2011, 2013, 2018 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* Laurent Latil <laurent@latil.nom.fr>
* C. Faure 2013-05-15
@ -924,13 +924,13 @@ int board_lcd_initialize(void)
/* Check model id */
id=read_reg(0x0);
id = read_reg(0x0);
if (id != LCD_ID)
{
/* Not a R61505U ? */
lcderr("ERROR: board_lcd_initialize: LCD ctrl is not a R61505U");
return ERROR;
return -ENXIO;
}
/* Configure and enable LCD */

View File

@ -376,11 +376,10 @@ int board_app_initialize(uintptr_t arg)
syslog(LOG_INFO, "Initializing TFT LCD module\n");
ret = board_lcd_initialize();
if (ret != OK)
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to initialize TFT LCD module\n");
}
#endif
#ifdef CONFIG_SENSORS_QENCODER

View File

@ -103,13 +103,13 @@ int board_lcd_initialize(void)
if (!g_spidev)
{
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
return 0;
return -ENODEV;
}
stm32_gpiowrite(STM32_LCD_RST, 0);
up_mdelay(1);
stm32_gpiowrite(STM32_LCD_RST, 1);
return 1;
return OK;
}
/****************************************************************************

View File

@ -1,7 +1,7 @@
/****************************************************************************
* config/stm32f103-minimum/src/stm32_max7219.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2017-2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -88,10 +88,10 @@ int board_lcd_initialize(void)
if (!g_spidev)
{
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
return 0;
return -ENODEV;
}
return 1;
return OK;
}
/****************************************************************************

View File

@ -1,7 +1,7 @@
/****************************************************************************
* config/stm32f103-minimum/src/stm32_pcd8544.c
*
* Copyright (C) 2011, 2013, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013, 2015, 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -95,13 +95,13 @@ int board_lcd_initialize(void)
if (!g_spidev)
{
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
return 0;
return -ENODEV;
}
stm32_gpiowrite(STM32_LCD_RST, 0);
up_mdelay(10);
stm32_gpiowrite(STM32_LCD_RST, 1);
return 1;
return OK;
}
/****************************************************************************

View File

@ -88,10 +88,10 @@ int board_lcd_initialize(void)
if (!g_i2c)
{
lcderr("ERROR: Failed to initialize I2C port %d\n", OLED_I2C_PORT);
return 0;
return -ENODEV;
}
return 1;
return OK;
}
/****************************************************************************

View File

@ -103,13 +103,13 @@ int board_lcd_initialize(void)
if (!g_spidev)
{
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
return 0;
return -ENODEV;
}
stm32_gpiowrite(STM32_LCD_RST, 0);
up_mdelay(1);
stm32_gpiowrite(STM32_LCD_RST, 1);
return 1;
return OK;
}
/****************************************************************************

View File

@ -6,7 +6,7 @@
*
* Based on configs/lm3s6965-ek/src/up_oled.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -91,13 +91,13 @@ int board_lcd_initialize(void)
if (!g_spidev)
{
lcderr("ERROR: Failed to initialize SSP port 0\n");
return 0;
return -ENODEV;
}
lpc17_gpiowrite(ZKITARM_OLED_RST, 0);
up_mdelay(1);
lpc17_gpiowrite(ZKITARM_OLED_RST, 1);
return 1;
return OK;
}
/****************************************************************************