From 7a9a3bea2f430706f07803a1cb783abff7d754b4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 2 Mar 2017 18:36:14 -0600 Subject: [PATCH] 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. --- configs/hymini-stm32v/src/stm32_appinit.c | 4 +-- configs/hymini-stm32v/src/stm32_ts.c | 12 ++++++--- configs/nucleo-144/src/stm32_sdio.c | 6 ++--- configs/nucleo-f4x1re/src/stm32_io.c | 27 +++++-------------- configs/nucleo-l476rg/src/stm32_io.c | 27 +++++-------------- configs/olimex-stm32-h407/src/stm32_sdio.c | 6 ++--- configs/spark/src/stm32_io.c | 14 +++++----- configs/stm32_tiny/src/stm32_wireless.c | 4 +-- configs/stm32butterfly2/src/stm32_mmcsd.c | 4 +-- .../stm32f103-minimum/src/stm32_wireless.c | 2 +- configs/stm32f429i-disco/src/stm32_l3gd20.c | 6 ++--- configs/stm32f4discovery/src/stm32_sdio.c | 6 ++--- configs/stm32f746-ws/src/stm32_sdmmc.c | 6 ++--- 13 files changed, 50 insertions(+), 74 deletions(-) diff --git a/configs/hymini-stm32v/src/stm32_appinit.c b/configs/hymini-stm32v/src/stm32_appinit.c index 2697adcb21..2e1d99f742 100644 --- a/configs/hymini-stm32v/src/stm32_appinit.c +++ b/configs/hymini-stm32v/src/stm32_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * 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 */ - 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 */ diff --git a/configs/hymini-stm32v/src/stm32_ts.c b/configs/hymini-stm32v/src/stm32_ts.c index e8889571d2..781eafc9f1 100644 --- a/configs/hymini-stm32v/src/stm32_ts.c +++ b/configs/hymini-stm32v/src/stm32_ts.c @@ -1,7 +1,7 @@ /************************************************************************************ * 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 * Laurent Latil * @@ -93,25 +93,29 @@ static xcpt_t tc_isr; ************************************************************************************/ /* Attach the ADS7843E interrupt handler to the GPIO interrupt */ + static int hymini_ts_irq_attach(FAR struct ads7843e_config_s *state, xcpt_t isr) { iinfo("hymini_ts_irq_attach\n"); 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; } /* Enable or disable the GPIO interrupt */ + static void hymini_ts_irq_enable(FAR struct ads7843e_config_s *state, - bool enable) + bool 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 */ + static void hymini_ts_irq_clear(FAR struct ads7843e_config_s *state) { // FIXME Nothing to do ? diff --git a/configs/nucleo-144/src/stm32_sdio.c b/configs/nucleo-144/src/stm32_sdio.c index 0a79f9258d..9b1de7415f 100644 --- a/configs/nucleo-144/src/stm32_sdio.c +++ b/configs/nucleo-144/src/stm32_sdio.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * 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 */ - stm32_gpiosetevent(GPIO_SDMMC1_NCD, true, true, true, - stm32_ncd_interrupt, NULL); + (void)stm32_gpiosetevent(GPIO_SDMMC1_NCD, true, true, true, + stm32_ncd_interrupt, NULL); #endif /* Mount the SDIO-based MMC/SD block driver */ diff --git a/configs/nucleo-f4x1re/src/stm32_io.c b/configs/nucleo-f4x1re/src/stm32_io.c index ba19049545..0fc399662a 100644 --- a/configs/nucleo-f4x1re/src/stm32_io.c +++ b/configs/nucleo-f4x1re/src/stm32_io.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -40,6 +40,7 @@ #include #include +#include #include #include "chip/stm32_tim.h" @@ -48,18 +49,6 @@ #ifndef CONFIG_CC3000_PROBES -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private 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 */ if (id == 0) { - oldhandler = stm32_gpiosetevent(GPIO_D14, true, true, true, - irqhandler, arg); + ret = stm32_gpiosetevent(GPIO_D14, true, true, true, irqhandler, arg); } else if (id == 1) { - oldhandler = stm32_gpiosetevent(GPIO_D15, true, true, true, - irqhandler, arg); + ret = stm32_gpiosetevent(GPIO_D15, true, true, true, irqhandler, arg); } - return oldhandler; + return ret; } #endif /* CONFIG_CC3000_PROBES */ diff --git a/configs/nucleo-l476rg/src/stm32_io.c b/configs/nucleo-l476rg/src/stm32_io.c index d6468c5d05..59e356d401 100644 --- a/configs/nucleo-l476rg/src/stm32_io.c +++ b/configs/nucleo-l476rg/src/stm32_io.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -40,6 +40,7 @@ #include #include +#include #include #include "chip/stm32l4_tim.h" @@ -48,18 +49,6 @@ #ifndef CONFIG_CC3000_PROBES -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private 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 */ if (id == 0) { - oldhandler = stm32_gpiosetevent(GPIO_D14, true, true, true, - irqhandler, NULL); + ret = stm32_gpiosetevent(GPIO_D14, true, true, true, irqhandler, arg); } else if (id == 1) { - oldhandler = stm32_gpiosetevent(GPIO_D15, true, true, true, - irqhandler, NULL); + ret = stm32_gpiosetevent(GPIO_D15, true, true, true, irqhandler, arg); } - return oldhandler; + return ret; } #endif /* CONFIG_CC3000_PROBES */ diff --git a/configs/olimex-stm32-h407/src/stm32_sdio.c b/configs/olimex-stm32-h407/src/stm32_sdio.c index f87e76c741..5745ba5bd8 100644 --- a/configs/olimex-stm32-h407/src/stm32_sdio.c +++ b/configs/olimex-stm32-h407/src/stm32_sdio.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * 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 */ - stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, - stm32_ncd_interrupt, NULL); + (void)stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, + stm32_ncd_interrupt, NULL); #endif /* Mount the SDIO-based MMC/SD block driver */ diff --git a/configs/spark/src/stm32_io.c b/configs/spark/src/stm32_io.c index 5730abe689..b6601c1ac6 100644 --- a/configs/spark/src/stm32_io.c +++ b/configs/spark/src/stm32_io.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * 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 */ if (id == 0) { - oldhandler = stm32_gpiosetevent(GPIO_D0, true, true, true, - irqhandler, NULL); + ret = stm32_gpiosetevent(GPIO_D0, true, true, true, irqhandler, arg); } else if (id == 1) { - oldhandler = stm32_gpiosetevent(GPIO_D1, true, true, true, - irqhandler, NULL); + ret = stm32_gpiosetevent(GPIO_D1, true, true, true, irqhandler, arg); } - return oldhandler; + return ret; } #endif /* CONFIG_CC3000_PROBES */ diff --git a/configs/stm32_tiny/src/stm32_wireless.c b/configs/stm32_tiny/src/stm32_wireless.c index ef3fc3f54c..a08e48a65a 100644 --- a/configs/stm32_tiny/src/stm32_wireless.c +++ b/configs/stm32_tiny/src/stm32_wireless.c @@ -1,7 +1,7 @@ /************************************************************************************ * 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 * * 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"); g_isr = isr; 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; } diff --git a/configs/stm32butterfly2/src/stm32_mmcsd.c b/configs/stm32butterfly2/src/stm32_mmcsd.c index d045d05c71..a244a5b5ff 100644 --- a/configs/stm32butterfly2/src/stm32_mmcsd.c +++ b/configs/stm32butterfly2/src/stm32_mmcsd.c @@ -1,7 +1,7 @@ /***************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -196,7 +196,7 @@ int stm32_mmcsd_initialize(int minor) 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); pthread_attr_init(&pattr); diff --git a/configs/stm32f103-minimum/src/stm32_wireless.c b/configs/stm32f103-minimum/src/stm32_wireless.c index e5d7c21073..c3ddcff784 100644 --- a/configs/stm32f103-minimum/src/stm32_wireless.c +++ b/configs/stm32f103-minimum/src/stm32_wireless.c @@ -85,7 +85,7 @@ static int stm32tiny_wl_irq_attach(xcpt_t isr, FAR void *arg) winfo("Attach IRQ\n"); g_isr = isr; 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; } diff --git a/configs/stm32f429i-disco/src/stm32_l3gd20.c b/configs/stm32f429i-disco/src/stm32_l3gd20.c index 1d6dd2cc2d..4cdc0a896e 100644 --- a/configs/stm32f429i-disco/src/stm32_l3gd20.c +++ b/configs/stm32f429i-disco/src/stm32_l3gd20.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * 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); } /**************************************************************************** diff --git a/configs/stm32f4discovery/src/stm32_sdio.c b/configs/stm32f4discovery/src/stm32_sdio.c index f4f5ba5024..75e87866d6 100644 --- a/configs/stm32f4discovery/src/stm32_sdio.c +++ b/configs/stm32f4discovery/src/stm32_sdio.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * 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 */ - stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, - stm32_ncd_interrupt, NULL); + (void)stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, + stm32_ncd_interrupt, NULL); #endif /* Mount the SDIO-based MMC/SD block driver */ diff --git a/configs/stm32f746-ws/src/stm32_sdmmc.c b/configs/stm32f746-ws/src/stm32_sdmmc.c index dce13b291d..daca5a160f 100644 --- a/configs/stm32f746-ws/src/stm32_sdmmc.c +++ b/configs/stm32f746-ws/src/stm32_sdmmc.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * 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 */ - stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, - stm32_ncd_interrupt, NULL); + (void)stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, + stm32_ncd_interrupt, NULL); #endif /* Mount the SDIO-based MMC/SD block driver */