drivers: serial: Fix device instance const qualifier loss
It is necessary to wrap the device pointer into data. Fixes #27399 Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
7af23757bc
commit
162c0bd7fe
3 changed files with 28 additions and 14 deletions
|
@ -139,6 +139,7 @@ struct uart_miv_device_config {
|
|||
|
||||
struct uart_miv_data {
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
const struct device *dev;
|
||||
uart_irq_callback_user_data_t callback;
|
||||
void *cb_data;
|
||||
#endif
|
||||
|
@ -312,7 +313,8 @@ static void uart_miv_irq_handler(void *arg)
|
|||
*/
|
||||
void uart_miv_rx_thread(void *arg1, void *arg2, void *arg3)
|
||||
{
|
||||
const struct device *dev = (const struct device *)arg1;
|
||||
struct uart_miv_data *data = (struct uart_miv_data *)arg1;
|
||||
const struct device *dev = data->dev;
|
||||
volatile struct uart_miv_regs_t *uart = DEV_UART(dev);
|
||||
const struct uart_miv_device_config *const cfg = DEV_CFG(dev);
|
||||
/* Make it go to sleep for a period no longer than
|
||||
|
@ -320,6 +322,9 @@ void uart_miv_rx_thread(void *arg1, void *arg2, void *arg3)
|
|||
*/
|
||||
uint32_t delay = 1000000 / cfg->baud_rate;
|
||||
|
||||
ARG_UNUSED(arg2);
|
||||
ARG_UNUSED(arg3);
|
||||
|
||||
while (1) {
|
||||
if (uart->status & STATUS_RXFULL_MASK) {
|
||||
uart_miv_irq_handler(dev);
|
||||
|
@ -411,9 +416,13 @@ DEVICE_AND_API_INIT(uart_miv_0, DT_INST_LABEL(0),
|
|||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void uart_miv_irq_cfg_func_0(const struct device *dev)
|
||||
{
|
||||
struct uart_miv_data *data = DEV_DATA(dev);
|
||||
|
||||
data->dev = dev;
|
||||
|
||||
/* Create a thread which will poll for data - replacement for IRQ */
|
||||
k_thread_create(&rx_thread, rx_stack, 500,
|
||||
uart_miv_rx_thread, dev, NULL, NULL, K_PRIO_COOP(2),
|
||||
uart_miv_rx_thread, data, NULL, NULL, K_PRIO_COOP(2),
|
||||
0, K_NO_WAIT);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -100,6 +100,7 @@ struct uarte_nrfx_int_driven {
|
|||
|
||||
/* Device data structure */
|
||||
struct uarte_nrfx_data {
|
||||
const struct device *dev;
|
||||
struct uart_config uart_config;
|
||||
#ifdef UARTE_INTERRUPT_DRIVEN
|
||||
struct uarte_nrfx_int_driven *int_driven;
|
||||
|
@ -485,9 +486,9 @@ static int uarte_nrfx_init(const struct device *dev)
|
|||
}
|
||||
|
||||
k_timer_init(&data->async->rx_timeout_timer, rx_timeout, NULL);
|
||||
k_timer_user_data_set(&data->async->rx_timeout_timer, dev);
|
||||
k_timer_user_data_set(&data->async->rx_timeout_timer, data);
|
||||
k_timer_init(&data->async->tx_timeout_timer, tx_timeout, NULL);
|
||||
k_timer_user_data_set(&data->async->tx_timeout_timer, dev);
|
||||
k_timer_user_data_set(&data->async->tx_timeout_timer, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -632,8 +633,8 @@ static int uarte_nrfx_rx_disable(const struct device *dev)
|
|||
|
||||
static void tx_timeout(struct k_timer *timer)
|
||||
{
|
||||
const struct device *dev = k_timer_user_data_get(timer);
|
||||
(void) uarte_nrfx_tx_abort(dev);
|
||||
struct uarte_nrfx_data *data = k_timer_user_data_get(timer);
|
||||
(void) uarte_nrfx_tx_abort(data->dev);
|
||||
}
|
||||
|
||||
static void user_callback(const struct device *dev, struct uart_event *evt)
|
||||
|
@ -655,8 +656,8 @@ static void user_callback(const struct device *dev, struct uart_event *evt)
|
|||
*/
|
||||
static void rx_timeout(struct k_timer *timer)
|
||||
{
|
||||
const struct device *dev = k_timer_user_data_get(timer);
|
||||
struct uarte_nrfx_data *data = get_dev_data(dev);
|
||||
struct uarte_nrfx_data *data = k_timer_user_data_get(timer);
|
||||
const struct device *dev = data->dev;
|
||||
const struct uarte_nrfx_config *cfg = get_dev_config(dev);
|
||||
uint32_t read;
|
||||
|
||||
|
@ -1302,6 +1303,8 @@ static int uarte_instance_init(const struct device *dev,
|
|||
|
||||
nrf_uarte_disable(uarte);
|
||||
|
||||
data->dev = dev;
|
||||
|
||||
nrf_gpio_pin_write(config->pseltxd, 1);
|
||||
nrf_gpio_cfg_output(config->pseltxd);
|
||||
|
||||
|
|
|
@ -127,8 +127,9 @@ static void uart_sam0_dma_tx_done(const struct device *dma_dev, void *arg,
|
|||
ARG_UNUSED(id);
|
||||
ARG_UNUSED(error_code);
|
||||
|
||||
const struct device *dev = arg;
|
||||
struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev);
|
||||
struct uart_sam0_dev_data *const dev_data =
|
||||
(struct uart_sam0_dev_data *const) arg;
|
||||
const struct device *dev = dev_data->dev;
|
||||
|
||||
k_delayed_work_cancel(&dev_data->tx_timeout_work);
|
||||
|
||||
|
@ -231,8 +232,9 @@ static void uart_sam0_dma_rx_done(const struct device *dma_dev, void *arg,
|
|||
ARG_UNUSED(id);
|
||||
ARG_UNUSED(error_code);
|
||||
|
||||
const struct device *dev = arg;
|
||||
struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev);
|
||||
struct uart_sam0_dev_data *const dev_data =
|
||||
(struct uart_sam0_dev_data *const)arg;
|
||||
const struct device *dev = dev_data->dev;
|
||||
const struct uart_sam0_dev_cfg *const cfg = dev_data->cfg;
|
||||
SercomUsart * const regs = cfg->regs;
|
||||
int key = irq_lock();
|
||||
|
@ -581,7 +583,7 @@ static int uart_sam0_init(const struct device *dev)
|
|||
dma_cfg.channel_direction = MEMORY_TO_PERIPHERAL;
|
||||
dma_cfg.source_data_size = 1;
|
||||
dma_cfg.dest_data_size = 1;
|
||||
dma_cfg.user_data = dev;
|
||||
dma_cfg.user_data = dev_data;
|
||||
dma_cfg.dma_callback = uart_sam0_dma_tx_done;
|
||||
dma_cfg.block_count = 1;
|
||||
dma_cfg.head_block = &dma_blk;
|
||||
|
@ -609,7 +611,7 @@ static int uart_sam0_init(const struct device *dev)
|
|||
dma_cfg.channel_direction = PERIPHERAL_TO_MEMORY;
|
||||
dma_cfg.source_data_size = 1;
|
||||
dma_cfg.dest_data_size = 1;
|
||||
dma_cfg.user_data = dev;
|
||||
dma_cfg.user_data = dev_data;
|
||||
dma_cfg.dma_callback = uart_sam0_dma_rx_done;
|
||||
dma_cfg.block_count = 1;
|
||||
dma_cfg.head_block = &dma_blk;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue