stm32_gpiosetevent: GPIO IRQ function should not return the xcpt_t oldhandler. This value is useful and potentially dangerous by itself after the change to assocaite a argument with the interrupt handler.

This commit is contained in:
Gregory Nutt
2017-03-02 18:36:14 -06:00
parent 454164a88c
commit 7a9a3bea2f
13 changed files with 50 additions and 74 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* config/hymini-stm32v/src/stm32_appinit.c * config/hymini-stm32v/src/stm32_appinit.c
* *
* Copyright (C) 2009, 2011, 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2009, 2011, 2016-2017 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
@@ -182,7 +182,7 @@ int board_app_initialize(uintptr_t arg)
/* Register an interrupt handler for the card detect pin */ /* Register an interrupt handler for the card detect pin */
stm32_gpiosetevent(GPIO_SD_CD, true, true, true, nsh_cdinterrupt, NULL); (void)stm32_gpiosetevent(GPIO_SD_CD, true, true, true, nsh_cdinterrupt, NULL);
/* Mount the SDIO-based MMC/SD block driver */ /* Mount the SDIO-based MMC/SD block driver */
+8 -4
View File
@@ -1,7 +1,7 @@
/************************************************************************************ /************************************************************************************
* configs/hymini-stm32v/src/stm32_ts.c * configs/hymini-stm32v/src/stm32_ts.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* Laurent Latil <laurent@latil.nom.fr> * Laurent Latil <laurent@latil.nom.fr>
* *
@@ -93,25 +93,29 @@ static xcpt_t tc_isr;
************************************************************************************/ ************************************************************************************/
/* Attach the ADS7843E interrupt handler to the GPIO interrupt */ /* Attach the ADS7843E interrupt handler to the GPIO interrupt */
static int hymini_ts_irq_attach(FAR struct ads7843e_config_s *state, xcpt_t isr) static int hymini_ts_irq_attach(FAR struct ads7843e_config_s *state, xcpt_t isr)
{ {
iinfo("hymini_ts_irq_attach\n"); iinfo("hymini_ts_irq_attach\n");
tc_isr = isr; tc_isr = isr;
stm32_gpiosetevent(GPIO_TS_IRQ, true, true, true, isr, NULL); (void)stm32_gpiosetevent(GPIO_TS_IRQ, true, true, true, isr, NULL);
return OK; return OK;
} }
/* Enable or disable the GPIO interrupt */ /* Enable or disable the GPIO interrupt */
static void hymini_ts_irq_enable(FAR struct ads7843e_config_s *state, static void hymini_ts_irq_enable(FAR struct ads7843e_config_s *state,
bool enable) bool enable)
{ {
iinfo("%d\n", enable); iinfo("%d\n", enable);
stm32_gpiosetevent(GPIO_TS_IRQ, true, true, true, enable ? tc_isr : NULL, NULL); (void)stm32_gpiosetevent(GPIO_TS_IRQ, true, true, true,
enable ? tc_isr : NULL, NULL);
} }
/* Acknowledge/clear any pending GPIO interrupt */ /* Acknowledge/clear any pending GPIO interrupt */
static void hymini_ts_irq_clear(FAR struct ads7843e_config_s *state) static void hymini_ts_irq_clear(FAR struct ads7843e_config_s *state)
{ {
// FIXME Nothing to do ? // FIXME Nothing to do ?
+3 -3
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* config/nucleo-144/src/stm32_sdio.c * config/nucleo-144/src/stm32_sdio.c
* *
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2014, 2016-2017 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
@@ -132,8 +132,8 @@ int stm32_sdio_initialize(void)
/* Register an interrupt handler for the card detect pin */ /* Register an interrupt handler for the card detect pin */
stm32_gpiosetevent(GPIO_SDMMC1_NCD, true, true, true, (void)stm32_gpiosetevent(GPIO_SDMMC1_NCD, true, true, true,
stm32_ncd_interrupt, NULL); stm32_ncd_interrupt, NULL);
#endif #endif
/* Mount the SDIO-based MMC/SD block driver */ /* Mount the SDIO-based MMC/SD block driver */
+7 -20
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* configs/nucleo-f4x1re/src/stm32_io.c * configs/nucleo-f4x1re/src/stm32_io.c
* *
* Copyright (C) 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2014, 2017 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
@@ -40,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <stdint.h> #include <stdint.h>
#include <errno.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#include "chip/stm32_tim.h" #include "chip/stm32_tim.h"
@@ -48,18 +49,6 @@
#ifndef CONFIG_CC3000_PROBES #ifndef CONFIG_CC3000_PROBES
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -176,23 +165,21 @@ void up_write_outputs(int id, bool bits)
* *
****************************************************************************/ ****************************************************************************/
xcpt_t up_irqio(int id, xcpt_t irqhandler) int up_irqio(int id, xcpt_t irqhandler, void *arg)
{ {
xcpt_t oldhandler = NULL; int ret = -EINVAL;
/* The following should be atomic */ /* The following should be atomic */
if (id == 0) if (id == 0)
{ {
oldhandler = stm32_gpiosetevent(GPIO_D14, true, true, true, ret = stm32_gpiosetevent(GPIO_D14, true, true, true, irqhandler, arg);
irqhandler, arg);
} }
else if (id == 1) else if (id == 1)
{ {
oldhandler = stm32_gpiosetevent(GPIO_D15, true, true, true, ret = stm32_gpiosetevent(GPIO_D15, true, true, true, irqhandler, arg);
irqhandler, arg);
} }
return oldhandler; return ret;
} }
#endif /* CONFIG_CC3000_PROBES */ #endif /* CONFIG_CC3000_PROBES */
+7 -20
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* configs/nucleo-l476rg/src/stm32_io.c * configs/nucleo-l476rg/src/stm32_io.c
* *
* Copyright (C) 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2014, 2017 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
@@ -40,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <stdint.h> #include <stdint.h>
#include <errno.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#include "chip/stm32l4_tim.h" #include "chip/stm32l4_tim.h"
@@ -48,18 +49,6 @@
#ifndef CONFIG_CC3000_PROBES #ifndef CONFIG_CC3000_PROBES
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -176,23 +165,21 @@ void up_write_outputs(int id, bool bits)
* *
****************************************************************************/ ****************************************************************************/
xcpt_t up_irqio(int id, xcpt_t irqhandler) int up_irqio(int id, xcpt_t irqhandler, void *arg)
{ {
xcpt_t oldhandler = NULL; int ret = -EINVAL;
/* The following should be atomic */ /* The following should be atomic */
if (id == 0) if (id == 0)
{ {
oldhandler = stm32_gpiosetevent(GPIO_D14, true, true, true, ret = stm32_gpiosetevent(GPIO_D14, true, true, true, irqhandler, arg);
irqhandler, NULL);
} }
else if (id == 1) else if (id == 1)
{ {
oldhandler = stm32_gpiosetevent(GPIO_D15, true, true, true, ret = stm32_gpiosetevent(GPIO_D15, true, true, true, irqhandler, arg);
irqhandler, NULL);
} }
return oldhandler; return ret;
} }
#endif /* CONFIG_CC3000_PROBES */ #endif /* CONFIG_CC3000_PROBES */
+3 -3
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* config/olimex-stm32_h407/src/stm32_sdio.c * config/olimex-stm32_h407/src/stm32_sdio.c
* *
* Copyright (C) 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2016-2017 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
@@ -128,8 +128,8 @@ int stm32_sdio_initialize(void)
/* Register an interrupt handler for the card detect pin */ /* Register an interrupt handler for the card detect pin */
stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, (void)stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true,
stm32_ncd_interrupt, NULL); stm32_ncd_interrupt, NULL);
#endif #endif
/* Mount the SDIO-based MMC/SD block driver */ /* Mount the SDIO-based MMC/SD block driver */
+6 -8
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* configs/spark/src/stm32_io.c * configs/spark/src/stm32_io.c
* *
* Copyright (C) 2011-2014 Gregory Nutt. All rights reserved. * Copyright (C) 2011-2014, 2017 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
@@ -175,23 +175,21 @@ void up_write_outputs(int id, bool bits)
* *
****************************************************************************/ ****************************************************************************/
xcpt_t up_irqio(int id, xcpt_t irqhandler) int up_irqio(int id, xcpt_t irqhandler, void *arg)
{ {
xcpt_t oldhandler = NULL; int ret = -EINVAL;
/* The following should be atomic */ /* The following should be atomic */
if (id == 0) if (id == 0)
{ {
oldhandler = stm32_gpiosetevent(GPIO_D0, true, true, true, ret = stm32_gpiosetevent(GPIO_D0, true, true, true, irqhandler, arg);
irqhandler, NULL);
} }
else if (id == 1) else if (id == 1)
{ {
oldhandler = stm32_gpiosetevent(GPIO_D1, true, true, true, ret = stm32_gpiosetevent(GPIO_D1, true, true, true, irqhandler, arg);
irqhandler, NULL);
} }
return oldhandler; return ret;
} }
#endif /* CONFIG_CC3000_PROBES */ #endif /* CONFIG_CC3000_PROBES */
+2 -2
View File
@@ -1,7 +1,7 @@
/************************************************************************************ /************************************************************************************
* configs/stm32_tiny/src/stm32_wireless.c * configs/stm32_tiny/src/stm32_wireless.c
* *
* Copyright (C) 2009, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2009, 2013, 2017 Gregory Nutt. All rights reserved.
* Author: Laurent Latil <laurent@latil.nom.fr> * Author: Laurent Latil <laurent@latil.nom.fr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -83,7 +83,7 @@ static int stm32tiny_wl_irq_attach(xcpt_t isr, FAR void *arg)
_info("Attach IRQ\n"); _info("Attach IRQ\n");
g_isr = isr; g_isr = isr;
g_arg = arg; g_arg = arg;
stm32_gpiosetevent(GPIO_NRF24L01_IRQ, false, true, false, g_isr, g_arg); (void)stm32_gpiosetevent(GPIO_NRF24L01_IRQ, false, true, false, g_isr, g_arg);
return OK; return OK;
} }
+2 -2
View File
@@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
* configs/stm32butterfly2/src/stm32_mmcsd.c * configs/stm32butterfly2/src/stm32_mmcsd.c
* *
* Copyright (C) 2016 Michał Łyszczek. All rights reserved. * Copyright (C) 2016-2017 Michał Łyszczek. All rights reserved.
* Author: Michał Łyszczek <michal.lyszczek@gmail.com> * Author: Michał Łyszczek <michal.lyszczek@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -196,7 +196,7 @@ int stm32_mmcsd_initialize(int minor)
return rv; return rv;
} }
stm32_gpiosetevent(GPIO_SD_CD, true, true, true, stm32_cd, NULL); (void)stm32_gpiosetevent(GPIO_SD_CD, true, true, true, stm32_cd, NULL);
sem_init(&g_cdsem, 0, 0); sem_init(&g_cdsem, 0, 0);
pthread_attr_init(&pattr); pthread_attr_init(&pattr);
@@ -85,7 +85,7 @@ static int stm32tiny_wl_irq_attach(xcpt_t isr, FAR void *arg)
winfo("Attach IRQ\n"); winfo("Attach IRQ\n");
g_isr = isr; g_isr = isr;
g_arg = arg; g_arg = arg;
stm32_gpiosetevent(GPIO_NRF24L01_IRQ, false, true, false, g_isr, g_arg); (void)stm32_gpiosetevent(GPIO_NRF24L01_IRQ, false, true, false, g_isr, g_arg);
return OK; return OK;
} }
+3 -3
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* configs/stm32f429i-disco/src/stm32_l3gd20.c * configs/stm32f429i-disco/src/stm32_l3gd20.c
* *
* Copyright (C) Gregory Nutt. All rights reserved. * Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me> * Author: Mateusz Szafoni <raiden00@railab.me>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -85,9 +85,9 @@ static struct l3gd20_config_s g_l3gd20_config =
* *
****************************************************************************/ ****************************************************************************/
static int l3gd20_attach(FAR struct l3gd20_config_s * cfg, xcpt_t irq) static int l3gd20_attach(FAR struct l3gd20_config_s *cfg, xcpt_t irq)
{ {
stm32_gpiosetevent(GPIO_L3GD20_DREADY, true, false, true, irq, NULL); return stm32_gpiosetevent(GPIO_L3GD20_DREADY, true, false, true, irq, NULL);
} }
/**************************************************************************** /****************************************************************************
+3 -3
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* config/stm32f4discovery/src/stm32_sdio.c * config/stm32f4discovery/src/stm32_sdio.c
* *
* Copyright (C) 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2014, 2017 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
@@ -128,8 +128,8 @@ int stm32_sdio_initialize(void)
/* Register an interrupt handler for the card detect pin */ /* Register an interrupt handler for the card detect pin */
stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, (void)stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true,
stm32_ncd_interrupt, NULL); stm32_ncd_interrupt, NULL);
#endif #endif
/* Mount the SDIO-based MMC/SD block driver */ /* Mount the SDIO-based MMC/SD block driver */
+3 -3
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* config/stm32f746-ws/src/stm32_sdmmc.c * config/stm32f746-ws/src/stm32_sdmmc.c
* *
* Copyright (C) 2016 Gregory Nutt. All rights reserved. * Copyright (C) 2016-2017 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
@@ -126,8 +126,8 @@ int stm32_sdio_initialize(void)
/* Register an interrupt handler for the card detect pin */ /* Register an interrupt handler for the card detect pin */
stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, (void)stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true,
stm32_ncd_interrupt, NULL); stm32_ncd_interrupt, NULL);
#endif #endif
/* Mount the SDIO-based MMC/SD block driver */ /* Mount the SDIO-based MMC/SD block driver */