Skip to content

Commit c3f9e6d

Browse files
robhancocksedkartben
authored andcommitted
drivers: serial: serial_test: support IRQ callback user data
This driver previously caused an assertion error if non-NULL user_data was passed to uart_irq_callback_set. Add support for this by storing the user data and passing it back to the IRQ callback function. Signed-off-by: Robert Hancock <[email protected]>
1 parent c2b408d commit c3f9e6d

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

drivers/serial/serial_test.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct serial_vnd_data {
3131
void *callback_data;
3232
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
3333
uart_irq_callback_user_data_t irq_isr;
34+
void *irq_isr_user_data;
3435
bool irq_rx_enabled;
3536
bool irq_tx_enabled;
3637
#endif
@@ -80,7 +81,7 @@ static void irq_process(const struct device *dev)
8081
LOG_ERR("no isr registered");
8182
break;
8283
}
83-
data->irq_isr(dev, NULL);
84+
data->irq_isr(dev, data->irq_isr_user_data);
8485
};
8586
}
8687

@@ -141,11 +142,6 @@ static void irq_callback_set(const struct device *dev, uart_irq_callback_user_da
141142
{
142143
struct serial_vnd_data *data = dev->data;
143144

144-
/* Not implemented. Ok because `user_data` is always NULL in the current
145-
* implementation of core UART API.
146-
*/
147-
__ASSERT_NO_MSG(user_data == NULL);
148-
149145
#if defined(CONFIG_UART_EXCLUSIVE_API_CALLBACKS) && defined(CONFIG_UART_ASYNC_API)
150146
if (data->read_buf) {
151147
LOG_ERR("Setting callback to NULL while asynchronous API is in use.");
@@ -155,6 +151,7 @@ static void irq_callback_set(const struct device *dev, uart_irq_callback_user_da
155151
#endif
156152

157153
data->irq_isr = cb;
154+
data->irq_isr_user_data = user_data;
158155
LOG_DBG("callback set");
159156
}
160157

0 commit comments

Comments
 (0)