drivers: serial: drop get_dev_data/get_dev_config usage
Replace all get_dev_data()/get_dev_config() accessor utilities with dev->data and dev->config. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
2c103a25cc
commit
a6614968a8
4 changed files with 181 additions and 163 deletions
|
@ -24,18 +24,6 @@ struct uart_rtt_data {
|
|||
#endif /* CONFIG_UART_ASYNC_API */
|
||||
};
|
||||
|
||||
static inline
|
||||
const struct uart_rtt_config *get_dev_config(const struct device *dev)
|
||||
{
|
||||
return dev->config;
|
||||
}
|
||||
|
||||
static inline
|
||||
struct uart_rtt_data *get_dev_data(const struct device *dev)
|
||||
{
|
||||
return dev->data;
|
||||
}
|
||||
|
||||
static int uart_rtt_init(const struct device *dev)
|
||||
{
|
||||
/*
|
||||
|
@ -43,8 +31,8 @@ static int uart_rtt_init(const struct device *dev)
|
|||
* it is configured in correct, non-blocking mode. Other channels
|
||||
* need to be configured at run-time.
|
||||
*/
|
||||
if (get_dev_config(dev)) {
|
||||
const struct uart_rtt_config *cfg = get_dev_config(dev);
|
||||
if (dev->config) {
|
||||
const struct uart_rtt_config *cfg = dev->config;
|
||||
|
||||
SEGGER_RTT_ConfigUpBuffer(cfg->channel, dev->name,
|
||||
cfg->up_buffer, cfg->up_size,
|
||||
|
@ -67,8 +55,8 @@ static int uart_rtt_init(const struct device *dev)
|
|||
|
||||
static int uart_rtt_poll_in(const struct device *dev, unsigned char *c)
|
||||
{
|
||||
unsigned int ch =
|
||||
get_dev_config(dev) ? get_dev_config(dev)->channel : 0;
|
||||
const struct uart_rtt_config *config = dev->config;
|
||||
unsigned int ch = config ? config->channel : 0;
|
||||
unsigned int ret = SEGGER_RTT_Read(ch, c, 1);
|
||||
|
||||
return ret ? 0 : -1;
|
||||
|
@ -82,8 +70,8 @@ static int uart_rtt_poll_in(const struct device *dev, unsigned char *c)
|
|||
*/
|
||||
static void uart_rtt_poll_out(const struct device *dev, unsigned char c)
|
||||
{
|
||||
unsigned int ch =
|
||||
get_dev_config(dev) ? get_dev_config(dev)->channel : 0;
|
||||
const struct uart_rtt_config *config = dev->config;
|
||||
unsigned int ch = config ? config->channel : 0;
|
||||
|
||||
SEGGER_RTT_Write(ch, &c, 1);
|
||||
}
|
||||
|
@ -93,16 +81,18 @@ static void uart_rtt_poll_out(const struct device *dev, unsigned char c)
|
|||
static int uart_rtt_callback_set(const struct device *dev,
|
||||
uart_callback_t callback, void *user_data)
|
||||
{
|
||||
get_dev_data(dev)->callback = callback;
|
||||
get_dev_data(dev)->user_data = user_data;
|
||||
struct uart_rtt_data *data = dev->data;
|
||||
|
||||
data->callback = callback;
|
||||
data->user_data = user_data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uart_rtt_tx(const struct device *dev,
|
||||
const uint8_t *buf, size_t len, int32_t timeout)
|
||||
{
|
||||
const struct uart_rtt_config *cfg = get_dev_config(dev);
|
||||
struct uart_rtt_data *data = get_dev_data(dev);
|
||||
const struct uart_rtt_config *cfg = dev->config;
|
||||
struct uart_rtt_data *data = dev->data;
|
||||
unsigned int ch = cfg ? cfg->channel : 0;
|
||||
|
||||
ARG_UNUSED(timeout);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue