Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: serial: return int value from uart_poll_out #64081

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/auxdisplay/auxdisplay_itron.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ static int send_cmd(const struct device *dev, const uint8_t *command, uint8_t le
}
#endif

uart_poll_out(uart, command[i]);
(void)uart_poll_out(uart, command[i]);
++i;
}

Expand Down
14 changes: 7 additions & 7 deletions drivers/bluetooth/hci/h5.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,15 @@ static uint8_t h5_slip_byte(uint8_t byte)
{
switch (byte) {
case SLIP_DELIMITER:
uart_poll_out(h5_dev, SLIP_ESC);
uart_poll_out(h5_dev, SLIP_ESC_DELIM);
(void)uart_poll_out(h5_dev, SLIP_ESC);
(void)uart_poll_out(h5_dev, SLIP_ESC_DELIM);
return 2;
case SLIP_ESC:
uart_poll_out(h5_dev, SLIP_ESC);
uart_poll_out(h5_dev, SLIP_ESC_ESC);
(void)uart_poll_out(h5_dev, SLIP_ESC);
(void)uart_poll_out(h5_dev, SLIP_ESC_ESC);
return 2;
default:
uart_poll_out(h5_dev, byte);
(void)uart_poll_out(h5_dev, byte);
return 1;
}
}
Expand Down Expand Up @@ -306,7 +306,7 @@ static void h5_send(const uint8_t *payload, uint8_t type, int len)

h5_print_header(hdr, "TX: <");

uart_poll_out(h5_dev, SLIP_DELIMITER);
(void)uart_poll_out(h5_dev, SLIP_DELIMITER);

for (i = 0; i < 4; i++) {
h5_slip_byte(hdr[i]);
Expand All @@ -316,7 +316,7 @@ static void h5_send(const uint8_t *payload, uint8_t type, int len)
h5_slip_byte(payload[i]);
}

uart_poll_out(h5_dev, SLIP_DELIMITER);
(void)uart_poll_out(h5_dev, SLIP_DELIMITER);
}

/* Delayed work taking care about retransmitting packets */
Expand Down
22 changes: 11 additions & 11 deletions drivers/console/uart_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ static int console_out(int c)
}

if ('\n' == c) {
uart_poll_out(uart_console_dev, '\r');
(void)uart_poll_out(uart_console_dev, '\r');
}
uart_poll_out(uart_console_dev, c);
(void)uart_poll_out(uart_console_dev, c);

if (pm_device_runtime_is_enabled(uart_console_dev)) {
/* As errors cannot be returned, ignore the return value */
Expand Down Expand Up @@ -180,7 +180,7 @@ static void insert_char(char *pos, char c, uint8_t end)
char tmp;

/* Echo back to console */
uart_poll_out(uart_console_dev, c);
(void)uart_poll_out(uart_console_dev, c);

if (end == 0U) {
*pos = c;
Expand All @@ -193,7 +193,7 @@ static void insert_char(char *pos, char c, uint8_t end)
cursor_save();

while (end-- > 0) {
uart_poll_out(uart_console_dev, tmp);
(void)uart_poll_out(uart_console_dev, tmp);
c = *pos;
*(pos++) = tmp;
tmp = c;
Expand All @@ -205,22 +205,22 @@ static void insert_char(char *pos, char c, uint8_t end)

static void del_char(char *pos, uint8_t end)
{
uart_poll_out(uart_console_dev, '\b');
(void)uart_poll_out(uart_console_dev, '\b');

if (end == 0U) {
uart_poll_out(uart_console_dev, ' ');
uart_poll_out(uart_console_dev, '\b');
(void)uart_poll_out(uart_console_dev, ' ');
(void)uart_poll_out(uart_console_dev, '\b');
return;
}

cursor_save();

while (end-- > 0) {
*pos = *(pos + 1);
uart_poll_out(uart_console_dev, *(pos++));
(void)uart_poll_out(uart_console_dev, *(pos++));
}

uart_poll_out(uart_console_dev, ' ');
(void)uart_poll_out(uart_console_dev, ' ');

/* Move cursor back to right place */
cursor_restore();
Expand Down Expand Up @@ -529,8 +529,8 @@ static void uart_console_isr(const struct device *unused, void *user_data)
}
case '\r':
cmd->line[cur + end] = '\0';
uart_poll_out(uart_console_dev, '\r');
uart_poll_out(uart_console_dev, '\n');
(void)uart_poll_out(uart_console_dev, '\r');
(void)uart_poll_out(uart_console_dev, '\n');
cur = 0U;
end = 0U;
k_fifo_put(lines_queue, cmd);
Expand Down
2 changes: 1 addition & 1 deletion drivers/console/uart_mcumgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static int uart_mcumgr_send_raw(const void *data, int len)

u8p = data;
while (len--) {
uart_poll_out(uart_mcumgr_dev, *u8p++);
(void)uart_poll_out(uart_mcumgr_dev, *u8p++);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@de-nordic will need to add code to bail at this point for 3.6

}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/console/uart_mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ int uart_mux_send(const struct device *uart, const uint8_t *buf, size_t size)
k_mutex_lock(&dev_data->real_uart->lock, K_FOREVER);

do {
uart_poll_out(dev_data->real_uart->uart, *buf++);
(void)uart_poll_out(dev_data->real_uart->uart, *buf++);
} while (--remaining);

k_mutex_unlock(&dev_data->real_uart->lock);
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/i2c_sc18im704.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int sc18im704_transfer(const struct device *dev,

if (tx_data != NULL) {
for (uint8_t i = 0; i < tx_len; ++i) {
uart_poll_out(cfg->bus, tx_data[i]);
(void)uart_poll_out(cfg->bus, tx_data[i]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/modem/modem_iface_uart_interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static int modem_iface_uart_write(struct modem_iface *iface,
uart_fifo_fill(iface->dev, buf, size);
} else {
do {
uart_poll_out(iface->dev, *buf++);
(void)uart_poll_out(iface->dev, *buf++);
} while (--size);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/modem/modem_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ int mdm_receiver_send(struct mdm_receiver_context *ctx,
}

do {
uart_poll_out(ctx->uart_dev, *buf++);
(void)uart_poll_out(ctx->uart_dev, *buf++);
} while (--size);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ static int ppp_send_flush(struct ppp_driver_context *ppp, int off)
#endif
} else {
while (off--) {
uart_poll_out(ppp->dev, *buf++);
(void)uart_poll_out(ppp->dev, *buf++);
}
}

Expand Down
4 changes: 3 additions & 1 deletion drivers/serial/leuart_gecko.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ static int leuart_gecko_poll_in(const struct device *dev, unsigned char *c)
return -1;
}

static void leuart_gecko_poll_out(const struct device *dev, unsigned char c)
static int leuart_gecko_poll_out(const struct device *dev, unsigned char c)
{
LEUART_TypeDef *base = DEV_BASE(dev);

/* LEUART_Tx function already waits for the transmit buffer being empty
* and and waits for the bus to be free to transmit.
*/
LEUART_Tx(base, c);

return 0;
}

static int leuart_gecko_err_check(const struct device *dev)
Expand Down
6 changes: 4 additions & 2 deletions drivers/serial/serial_esp32_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static int serial_esp32_usb_poll_in(const struct device *dev, unsigned char *p_c
return 0;
}

static void serial_esp32_usb_poll_out(const struct device *dev, unsigned char c)
static int serial_esp32_usb_poll_out(const struct device *dev, unsigned char c)
{
struct serial_esp32_usb_data *data = dev->data;

Expand All @@ -84,9 +84,11 @@ static void serial_esp32_usb_poll_out(const struct device *dev, unsigned char c)
usb_serial_jtag_ll_write_txfifo(&c, 1);
usb_serial_jtag_ll_txfifo_flush();
data->last_tx_time = k_uptime_get();
return;
return 0;
}
} while ((k_uptime_get() - data->last_tx_time) < USBSERIAL_POLL_OUT_TIMEOUT_MS);

return -EIO;
}

static int serial_esp32_usb_err_check(const struct device *dev)
Expand Down
6 changes: 4 additions & 2 deletions drivers/serial/serial_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,21 @@ static int serial_vnd_poll_in(const struct device *dev, unsigned char *c)
#endif
}

static void serial_vnd_poll_out(const struct device *dev, unsigned char c)
static int serial_vnd_poll_out(const struct device *dev, unsigned char c)
{
struct serial_vnd_data *data = dev->data;

#ifdef CONFIG_RING_BUFFER
if (data == NULL || data->written == NULL) {
return;
return -EIO;
}
ring_buf_put(data->written, &c, 1);
#endif
if (data->callback) {
data->callback(dev, data->callback_data);
}

return 0;
}

#ifdef CONFIG_UART_ASYNC_API
Expand Down
4 changes: 3 additions & 1 deletion drivers/serial/uart_altera.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int uart_altera_poll_in(const struct device *dev, unsigned char *p_char)
* @param dev UART device instance
* @param c Character to send
*/
static void uart_altera_poll_out(const struct device *dev, unsigned char c)
static int uart_altera_poll_out(const struct device *dev, unsigned char c)
{
const struct uart_altera_device_config *config = dev->config;
struct uart_altera_device_data *data = dev->data;
Expand All @@ -194,6 +194,8 @@ static void uart_altera_poll_out(const struct device *dev, unsigned char c)
sys_write32(c, config->base + ALTERA_AVALON_UART_TXDATA_REG_OFFSET);

k_spin_unlock(&data->lock, key);

return 0;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion drivers/serial/uart_altera_jtag.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static int uart_altera_jtag_poll_in(const struct device *dev,
* @param dev UART device instance
* @param c Character to send
*/
static void uart_altera_jtag_poll_out(const struct device *dev,
static int uart_altera_jtag_poll_out(const struct device *dev,
unsigned char c)
{
#ifdef CONFIG_UART_ALTERA_JTAG_HAL
Expand All @@ -137,6 +137,8 @@ static void uart_altera_jtag_poll_out(const struct device *dev,

k_spin_unlock(&data->lock, key);
#endif /* CONFIG_UART_ALTERA_JTAG_HAL */

return 0;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion drivers/serial/uart_apbuart.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct apbuart_dev_data {
* This routine waits for the TX holding register or TX FIFO to be ready and
* then it writes a character to the data register.
*/
static void apbuart_poll_out(const struct device *dev, unsigned char x)
static int apbuart_poll_out(const struct device *dev, unsigned char x)
{
const struct apbuart_dev_cfg *config = dev->config;
struct apbuart_dev_data *data = dev->data;
Expand All @@ -162,6 +162,8 @@ static void apbuart_poll_out(const struct device *dev, unsigned char x)
}

regs->data = x & 0xff;

return 0;
}

static int apbuart_poll_in(const struct device *dev, unsigned char *c)
Expand Down
4 changes: 3 additions & 1 deletion drivers/serial/uart_b91.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static int uart_b91_driver_init(const struct device *dev)
}

/* API implementation: poll_out */
static void uart_b91_poll_out(const struct device *dev, uint8_t c)
static int uart_b91_poll_out(const struct device *dev, uint8_t c)
{
volatile struct uart_b91_t *uart = GET_UART(dev);
struct uart_b91_data *data = dev->data;
Expand All @@ -344,6 +344,8 @@ static void uart_b91_poll_out(const struct device *dev, uint8_t c)

uart->data_buf[data->tx_byte_index] = c;
data->tx_byte_index = (data->tx_byte_index + 1) % ARRAY_SIZE(uart->data_buf);

return 0;
}

/* API implementation: poll_in */
Expand Down
4 changes: 3 additions & 1 deletion drivers/serial/uart_bcm2711.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ static int uart_bcm2711_init(const struct device *dev)
return 0;
}

static void uart_bcm2711_poll_out(const struct device *dev, unsigned char c)
static int uart_bcm2711_poll_out(const struct device *dev, unsigned char c)
{
struct bcm2711_uart_data *uart_data = dev->data;

bcm2711_mu_lowlevel_putc(uart_data->uart_addr, c);

return 0;
}

static int uart_bcm2711_poll_in(const struct device *dev, unsigned char *c)
Expand Down
4 changes: 3 additions & 1 deletion drivers/serial/uart_cc13xx_cc26xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static int uart_cc13xx_cc26xx_poll_in(const struct device *dev,
return 0;
}

static void uart_cc13xx_cc26xx_poll_out(const struct device *dev,
static int uart_cc13xx_cc26xx_poll_out(const struct device *dev,
unsigned char c)
{
const struct uart_cc13xx_cc26xx_config *config = dev->config;
Expand All @@ -72,6 +72,8 @@ static void uart_cc13xx_cc26xx_poll_out(const struct device *dev,
*/
while (UARTBusy(config->reg) == true) {
}

return 0;
}

static int uart_cc13xx_cc26xx_err_check(const struct device *dev)
Expand Down
4 changes: 3 additions & 1 deletion drivers/serial/uart_cc32xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,13 @@ static int uart_cc32xx_poll_in(const struct device *dev, unsigned char *c)
return 0;
}

static void uart_cc32xx_poll_out(const struct device *dev, unsigned char c)
static int uart_cc32xx_poll_out(const struct device *dev, unsigned char c)
{
const struct uart_cc32xx_dev_config *config = dev->config;

MAP_UARTCharPut(config->base, c);

return 0;
}

static int uart_cc32xx_err_check(const struct device *dev)
Expand Down
4 changes: 3 additions & 1 deletion drivers/serial/uart_cdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ void uart_cdns_set_baudrate(struct uart_cdns_regs *uart_regs,
((dev_cfg->bdiv + 1) * baud_rate);
}

static void uart_cdns_poll_out(const struct device *dev, unsigned char out_char)
static int uart_cdns_poll_out(const struct device *dev, unsigned char out_char)
{
struct uart_cdns_regs *uart_regs = DEV_UART(dev);
/* Wait while TX FIFO is full */
while (uart_cdns_is_tx_fifo_full(uart_regs)) {
}
uart_regs->rx_tx_fifo = (uint32_t)out_char;

return 0;
}

/** @brief Poll the device for input. */
Expand Down
4 changes: 3 additions & 1 deletion drivers/serial/uart_cmsdk_apb.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static int uart_cmsdk_apb_poll_in(const struct device *dev, unsigned char *c)
* @param dev UART device struct
* @param c Character to send
*/
static void uart_cmsdk_apb_poll_out(const struct device *dev,
static int uart_cmsdk_apb_poll_out(const struct device *dev,
unsigned char c)
{
const struct uart_cmsdk_apb_config *dev_cfg = dev->config;
Expand All @@ -199,6 +199,8 @@ static void uart_cmsdk_apb_poll_out(const struct device *dev,

/* Send a character */
dev_cfg->uart->data = (uint32_t)c;

return 0;
}

#ifdef CONFIG_UART_INTERRUPT_DRIVEN
Expand Down
Loading