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:
parent
1a879a3b52
commit
505f460b6b
@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/hymini-stm32v/src/stm32_r61505u.c
|
* 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>
|
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Laurent Latil <laurent@latil.nom.fr>
|
* Laurent Latil <laurent@latil.nom.fr>
|
||||||
* C. Faure 2013-05-15
|
* C. Faure 2013-05-15
|
||||||
@ -924,13 +924,13 @@ int board_lcd_initialize(void)
|
|||||||
|
|
||||||
/* Check model id */
|
/* Check model id */
|
||||||
|
|
||||||
id=read_reg(0x0);
|
id = read_reg(0x0);
|
||||||
if (id != LCD_ID)
|
if (id != LCD_ID)
|
||||||
{
|
{
|
||||||
/* Not a R61505U ? */
|
/* Not a R61505U ? */
|
||||||
|
|
||||||
lcderr("ERROR: board_lcd_initialize: LCD ctrl is not a R61505U");
|
lcderr("ERROR: board_lcd_initialize: LCD ctrl is not a R61505U");
|
||||||
return ERROR;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure and enable LCD */
|
/* Configure and enable LCD */
|
||||||
|
@ -376,11 +376,10 @@ int board_app_initialize(uintptr_t arg)
|
|||||||
syslog(LOG_INFO, "Initializing TFT LCD module\n");
|
syslog(LOG_INFO, "Initializing TFT LCD module\n");
|
||||||
|
|
||||||
ret = board_lcd_initialize();
|
ret = board_lcd_initialize();
|
||||||
if (ret != OK)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR, "ERROR: Failed to initialize TFT LCD module\n");
|
syslog(LOG_ERR, "ERROR: Failed to initialize TFT LCD module\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SENSORS_QENCODER
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
|
@ -103,13 +103,13 @@ int board_lcd_initialize(void)
|
|||||||
if (!g_spidev)
|
if (!g_spidev)
|
||||||
{
|
{
|
||||||
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
|
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
|
||||||
return 0;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
stm32_gpiowrite(STM32_LCD_RST, 0);
|
stm32_gpiowrite(STM32_LCD_RST, 0);
|
||||||
up_mdelay(1);
|
up_mdelay(1);
|
||||||
stm32_gpiowrite(STM32_LCD_RST, 1);
|
stm32_gpiowrite(STM32_LCD_RST, 1);
|
||||||
return 1;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* config/stm32f103-minimum/src/stm32_max7219.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -88,10 +88,10 @@ int board_lcd_initialize(void)
|
|||||||
if (!g_spidev)
|
if (!g_spidev)
|
||||||
{
|
{
|
||||||
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
|
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
|
||||||
return 0;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* config/stm32f103-minimum/src/stm32_pcd8544.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -95,13 +95,13 @@ int board_lcd_initialize(void)
|
|||||||
if (!g_spidev)
|
if (!g_spidev)
|
||||||
{
|
{
|
||||||
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
|
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
|
||||||
return 0;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
stm32_gpiowrite(STM32_LCD_RST, 0);
|
stm32_gpiowrite(STM32_LCD_RST, 0);
|
||||||
up_mdelay(10);
|
up_mdelay(10);
|
||||||
stm32_gpiowrite(STM32_LCD_RST, 1);
|
stm32_gpiowrite(STM32_LCD_RST, 1);
|
||||||
return 1;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -88,10 +88,10 @@ int board_lcd_initialize(void)
|
|||||||
if (!g_i2c)
|
if (!g_i2c)
|
||||||
{
|
{
|
||||||
lcderr("ERROR: Failed to initialize I2C port %d\n", OLED_I2C_PORT);
|
lcderr("ERROR: Failed to initialize I2C port %d\n", OLED_I2C_PORT);
|
||||||
return 0;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -103,13 +103,13 @@ int board_lcd_initialize(void)
|
|||||||
if (!g_spidev)
|
if (!g_spidev)
|
||||||
{
|
{
|
||||||
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
|
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
|
||||||
return 0;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
stm32_gpiowrite(STM32_LCD_RST, 0);
|
stm32_gpiowrite(STM32_LCD_RST, 0);
|
||||||
up_mdelay(1);
|
up_mdelay(1);
|
||||||
stm32_gpiowrite(STM32_LCD_RST, 1);
|
stm32_gpiowrite(STM32_LCD_RST, 1);
|
||||||
return 1;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* Based on configs/lm3s6965-ek/src/up_oled.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -91,13 +91,13 @@ int board_lcd_initialize(void)
|
|||||||
if (!g_spidev)
|
if (!g_spidev)
|
||||||
{
|
{
|
||||||
lcderr("ERROR: Failed to initialize SSP port 0\n");
|
lcderr("ERROR: Failed to initialize SSP port 0\n");
|
||||||
return 0;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
lpc17_gpiowrite(ZKITARM_OLED_RST, 0);
|
lpc17_gpiowrite(ZKITARM_OLED_RST, 0);
|
||||||
up_mdelay(1);
|
up_mdelay(1);
|
||||||
lpc17_gpiowrite(ZKITARM_OLED_RST, 1);
|
lpc17_gpiowrite(ZKITARM_OLED_RST, 1);
|
||||||
return 1;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user