Skip to content

Commit e63643d

Browse files
galakcarlescufi
authored andcommitted
drivers: serial: lpc11u6x: Remove DT_LABEL usage
Remove DT_LABEL usage that is needed for device_get_binding, replace this with DEVICE_DT_GET. Signed-off-by: Kumar Gala <[email protected]>
1 parent 78b1d95 commit e63643d

File tree

2 files changed

+12
-38
lines changed

2 files changed

+12
-38
lines changed

drivers/serial/uart_lpc11u6x.c

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ static int lpc11u6x_uart0_configure(const struct device *dev,
102102
{
103103
const struct lpc11u6x_uart0_config *dev_cfg = dev->config;
104104
struct lpc11u6x_uart0_data *data = dev->data;
105-
const struct device *clk_dev;
106105
uint32_t flags = 0;
107106

108107
/* Check that the baudrate is a multiple of 9600 */
@@ -167,11 +166,7 @@ static int lpc11u6x_uart0_configure(const struct device *dev,
167166
return -ENOTSUP;
168167
}
169168

170-
clk_dev = device_get_binding(dev_cfg->clock_drv_name);
171-
if (!clk_dev) {
172-
return -EINVAL;
173-
}
174-
lpc11u6x_uart0_config_baudrate(clk_dev, dev_cfg, cfg->baudrate);
169+
lpc11u6x_uart0_config_baudrate(dev_cfg->clock_dev, dev_cfg, cfg->baudrate);
175170
dev_cfg->uart0->lcr = flags;
176171

177172
data->baudrate = cfg->baudrate;
@@ -344,7 +339,6 @@ static int lpc11u6x_uart0_init(const struct device *dev)
344339
{
345340
const struct lpc11u6x_uart0_config *cfg = dev->config;
346341
struct lpc11u6x_uart0_data *data = dev->data;
347-
const struct device *clk_drv;
348342
int err;
349343

350344
/* Apply default pin control state to select RX and TX pins */
@@ -353,16 +347,10 @@ static int lpc11u6x_uart0_init(const struct device *dev)
353347
return err;
354348
}
355349

356-
/* Call clock driver to initialize uart0 clock */
357-
clk_drv = device_get_binding(cfg->clock_drv_name);
358-
if (!clk_drv) {
359-
return -EINVAL;
360-
}
361-
362-
clock_control_on(clk_drv, (clock_control_subsys_t) cfg->clkid);
350+
clock_control_on(cfg->clock_dev, (clock_control_subsys_t) cfg->clkid);
363351

364352
/* Configure baudrate, parity and stop bits */
365-
lpc11u6x_uart0_config_baudrate(clk_drv, cfg, cfg->baudrate);
353+
lpc11u6x_uart0_config_baudrate(cfg->clock_dev, cfg, cfg->baudrate);
366354

367355
cfg->uart0->lcr |= LPC11U6X_UART0_LCR_WLS_8BITS; /* 8N1 */
368356

@@ -390,7 +378,7 @@ PINCTRL_DT_DEFINE(DT_NODELABEL(uart0));
390378
static const struct lpc11u6x_uart0_config uart0_config = {
391379
.uart0 = (struct lpc11u6x_uart0_regs *)
392380
DT_REG_ADDR(DT_NODELABEL(uart0)),
393-
.clock_drv_name = DT_LABEL(DT_PHANDLE(DT_NODELABEL(uart0), clocks)),
381+
.clock_dev = DEVICE_DT_GET(DT_CLOCKS_CTLR(DT_NODELABEL(uart0))),
394382
.pincfg = PINCTRL_DT_DEV_CONFIG_GET(DT_NODELABEL(uart0)),
395383
.clkid = DT_PHA_BY_IDX(DT_NODELABEL(uart0), clocks, 0, clkid),
396384
.baudrate = DT_PROP(DT_NODELABEL(uart0), current_speed),
@@ -491,11 +479,11 @@ static int lpc11u6x_uartx_err_check(const struct device *dev)
491479
}
492480

493481
static void lpc11u6x_uartx_config_baud(const struct lpc11u6x_uartx_config *cfg,
494-
const struct device *clk_drv,
495482
uint32_t baudrate)
496483
{
497484
uint32_t clk_rate;
498485
uint32_t div;
486+
const struct device *clk_drv = cfg->clock_dev;
499487

500488
clock_control_get_rate(clk_drv, (clock_control_subsys_t) cfg->clkid,
501489
&clk_rate);
@@ -511,9 +499,8 @@ static void lpc11u6x_uartx_config_baud(const struct lpc11u6x_uartx_config *cfg,
511499
static int lpc11u6x_uartx_configure(const struct device *dev,
512500
const struct uart_config *cfg)
513501
{
514-
const struct lpc11u6x_uartx_config *dev_cfg = dev->config;
502+
const struct lpc11u6x_uartx_config *dev_cfg = dev->config;
515503
struct lpc11u6x_uartx_data *data = dev->data;
516-
const struct device *clk_dev;
517504
uint32_t flags = 0;
518505

519506
/* We only support baudrates that are multiple of 9600 */
@@ -576,16 +563,11 @@ static int lpc11u6x_uartx_configure(const struct device *dev,
576563
return -ENOTSUP;
577564
}
578565

579-
clk_dev = device_get_binding(dev_cfg->clock_drv_name);
580-
if (!clk_dev) {
581-
return -EINVAL;
582-
}
583-
584566
/* Disable UART */
585567
dev_cfg->base->cfg = 0;
586568

587569
/* Update baudrate */
588-
lpc11u6x_uartx_config_baud(dev_cfg, clk_dev, cfg->baudrate);
570+
lpc11u6x_uartx_config_baud(dev_cfg, cfg->baudrate);
589571

590572
/* Set parity, data bits, stop bits and re-enable UART interface */
591573
dev_cfg->base->cfg = flags | LPC11U6X_UARTX_CFG_ENABLE;
@@ -779,7 +761,6 @@ static int lpc11u6x_uartx_init(const struct device *dev)
779761
{
780762
const struct lpc11u6x_uartx_config *cfg = dev->config;
781763
struct lpc11u6x_uartx_data *data = dev->data;
782-
const struct device *clk_drv;
783764
int err;
784765

785766
/* Apply default pin control state to select RX and TX pins */
@@ -788,16 +769,10 @@ static int lpc11u6x_uartx_init(const struct device *dev)
788769
return err;
789770
}
790771

791-
/* Call clock driver to initialize uart0 clock */
792-
clk_drv = device_get_binding(cfg->clock_drv_name);
793-
if (!clk_drv) {
794-
return -EINVAL;
795-
}
796-
797-
clock_control_on(clk_drv, (clock_control_subsys_t) cfg->clkid);
772+
clock_control_on(cfg->clock_dev, (clock_control_subsys_t) cfg->clkid);
798773

799774
/* Configure baudrate, parity and stop bits */
800-
lpc11u6x_uartx_config_baud(cfg, clk_drv, cfg->baudrate);
775+
lpc11u6x_uartx_config_baud(cfg, cfg->baudrate);
801776
cfg->base->cfg = LPC11U6X_UARTX_CFG_DATALEN_8BIT; /* 8N1 */
802777

803778
data->baudrate = cfg->baudrate;
@@ -861,8 +836,7 @@ PINCTRL_DT_DEFINE(DT_NODELABEL(uart##idx)); \
861836
static const struct lpc11u6x_uartx_config uart_cfg_##idx = { \
862837
.base = (struct lpc11u6x_uartx_regs *) \
863838
DT_REG_ADDR(DT_NODELABEL(uart##idx)), \
864-
.clock_drv_name = \
865-
DT_LABEL(DT_PHANDLE(DT_NODELABEL(uart##idx), clocks)), \
839+
.clock_dev = DEVICE_DT_GET(DT_CLOCKS_CTLR(DT_NODELABEL(uart##idx))), \
866840
.clkid = DT_PHA_BY_IDX(DT_NODELABEL(uart##idx), clocks, 0, clkid), \
867841
.pincfg = PINCTRL_DT_DEV_CONFIG_GET(DT_NODELABEL(uart##idx)), \
868842
.baudrate = DT_PROP(DT_NODELABEL(uart##idx), current_speed), \

drivers/serial/uart_lpc11u6x.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ struct lpc11u6x_uart0_regs {
128128

129129
struct lpc11u6x_uart0_config {
130130
struct lpc11u6x_uart0_regs *uart0;
131-
const char *clock_drv_name;
131+
const struct device *clock_dev;
132132
uint32_t baudrate;
133133
uint32_t clkid;
134134
const struct pinctrl_dev_config *pincfg;
@@ -167,7 +167,7 @@ struct lpc11u6x_uartx_regs {
167167

168168
struct lpc11u6x_uartx_config {
169169
struct lpc11u6x_uartx_regs *base;
170-
const char *clock_drv_name;
170+
const struct device *clock_dev;
171171
uint32_t baudrate;
172172
uint32_t clkid;
173173
const struct pinctrl_dev_config *pincfg;

0 commit comments

Comments
 (0)