exti: stm32: fix driver data handling
Since dd5e90ec
the device_get_binding call returns NULL unless the
driver_api is set by the driver. Since the exti driver only uses an
internal struct to store the callbacks, remove the need for the device
binding call from other drivers (e.g. gpio).
Change-Id: If0b733c27754108118d87ef02640311f0535ab57
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
This commit is contained in:
parent
4c2802d6b7
commit
17a62dd268
3 changed files with 35 additions and 40 deletions
|
@ -66,13 +66,11 @@ struct stm32_exti_data {
|
|||
#define AS_EXTI(__base_addr) \
|
||||
((struct stm32_exti *)(__base_addr))
|
||||
|
||||
void stm32_exti_enable(struct device *dev, int line)
|
||||
void stm32_exti_enable(int line)
|
||||
{
|
||||
volatile struct stm32_exti *exti = AS_EXTI(EXTI_BASE);
|
||||
int irqnum;
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
exti->imr |= 1 << line;
|
||||
|
||||
#ifdef CONFIG_SOC_SERIES_STM32F1X
|
||||
|
@ -89,12 +87,10 @@ void stm32_exti_enable(struct device *dev, int line)
|
|||
irq_enable(irqnum);
|
||||
}
|
||||
|
||||
void stm32_exti_disable(struct device *dev, int line)
|
||||
void stm32_exti_disable(int line)
|
||||
{
|
||||
volatile struct stm32_exti *exti = AS_EXTI(EXTI_BASE);
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
exti->imr &= ~(1 << line);
|
||||
}
|
||||
|
||||
|
@ -122,12 +118,10 @@ static inline void stm32_exti_clear_pending(int line)
|
|||
exti->pr |= 1 << line;
|
||||
}
|
||||
|
||||
void stm32_exti_trigger(struct device *dev, int line, int trigger)
|
||||
void stm32_exti_trigger(int line, int trigger)
|
||||
{
|
||||
volatile struct stm32_exti *exti = AS_EXTI(EXTI_BASE);
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
if (trigger & STM32_EXTI_TRIG_RISING) {
|
||||
exti->rtsr |= 1 << line;
|
||||
}
|
||||
|
@ -137,26 +131,6 @@ void stm32_exti_trigger(struct device *dev, int line, int trigger)
|
|||
}
|
||||
}
|
||||
|
||||
void stm32_exti_set_callback(struct device *dev, int line,
|
||||
stm32_exti_callback_t cb, void *arg)
|
||||
{
|
||||
struct stm32_exti_data *data = dev->driver_data;
|
||||
|
||||
__ASSERT(data->cb[line].cb == NULL,
|
||||
"EXTI %d callback already registered", line);
|
||||
|
||||
data->cb[line].cb = cb;
|
||||
data->cb[line].data = arg;
|
||||
}
|
||||
|
||||
void stm32_exti_unset_callback(struct device *dev, int line)
|
||||
{
|
||||
struct stm32_exti_data *data = dev->driver_data;
|
||||
|
||||
data->cb[line].cb = NULL;
|
||||
data->cb[line].data = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief EXTI ISR handler
|
||||
*
|
||||
|
@ -241,6 +215,30 @@ DEVICE_INIT(exti_stm32, STM32_EXTI_NAME, stm32_exti_init,
|
|||
&exti_data, NULL,
|
||||
PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
|
||||
|
||||
/**
|
||||
* @brief set & unset for the interrupt callbacks
|
||||
*/
|
||||
void stm32_exti_set_callback(int line, stm32_exti_callback_t cb, void *arg)
|
||||
{
|
||||
struct device *dev = DEVICE_GET(exti_stm32);
|
||||
struct stm32_exti_data *data = dev->driver_data;
|
||||
|
||||
__ASSERT(data->cb[line].cb == NULL,
|
||||
"EXTI %d callback already registered", line);
|
||||
|
||||
data->cb[line].cb = cb;
|
||||
data->cb[line].data = arg;
|
||||
}
|
||||
|
||||
void stm32_exti_unset_callback(int line)
|
||||
{
|
||||
struct device *dev = DEVICE_GET(exti_stm32);
|
||||
struct stm32_exti_data *data = dev->driver_data;
|
||||
|
||||
data->cb[line].cb = NULL;
|
||||
data->cb[line].data = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief connect all interrupts
|
||||
*/
|
||||
|
|
|
@ -38,14 +38,14 @@
|
|||
*
|
||||
* @param line EXTI# line
|
||||
*/
|
||||
void stm32_exti_enable(struct device *dev, int line);
|
||||
void stm32_exti_enable(int line);
|
||||
|
||||
/**
|
||||
* @brief disable EXTI interrupt for specific line
|
||||
*
|
||||
* @param line EXTI# line
|
||||
*/
|
||||
void stm32_exti_disable(struct device *dev, int line);
|
||||
void stm32_exti_disable(int line);
|
||||
|
||||
/**
|
||||
* @brief EXTI trigger flags
|
||||
|
@ -63,7 +63,7 @@ enum stm32_exti_trigger {
|
|||
* @param line EXTI# line
|
||||
* @param trg OR'ed stm32_exti_trigger flags
|
||||
*/
|
||||
void stm32_exti_trigger(struct device *dev, int line, int trg);
|
||||
void stm32_exti_trigger(int line, int trg);
|
||||
|
||||
/* callback for exti interrupt */
|
||||
typedef void (*stm32_exti_callback_t) (int line, void *user);
|
||||
|
@ -75,14 +75,13 @@ typedef void (*stm32_exti_callback_t) (int line, void *user);
|
|||
* @param cb user callback
|
||||
* @param arg user arg
|
||||
*/
|
||||
void stm32_exti_set_callback(struct device *dev, int line,
|
||||
stm32_exti_callback_t cb, void *data);
|
||||
void stm32_exti_set_callback(int line, stm32_exti_callback_t cb, void *data);
|
||||
|
||||
/**
|
||||
* @brief unset EXTI interrupt callback
|
||||
*
|
||||
* @param line EXI# line
|
||||
*/
|
||||
void stm32_exti_unset_callback(struct device *dev, int line);
|
||||
void stm32_exti_unset_callback(int line);
|
||||
|
||||
#endif /* _STM32_EXTI_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue