Skip to content

Commit 78b1d95

Browse files
galakcarlescufi
authored andcommitted
drivers: i2c: 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 93f2fed commit 78b1d95

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

drivers/i2c/i2c_lpc11u6x.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ static int lpc11u6x_i2c_configure(const struct device *dev,
3232
{
3333
const struct lpc11u6x_i2c_config *cfg = dev->config;
3434
struct lpc11u6x_i2c_data *data = dev->data;
35-
const struct device *clk_dev;
3635
uint32_t speed;
3736
int ret;
3837
uint8_t mux_selection = PINCTRL_STATE_DEFAULT;
@@ -59,13 +58,8 @@ static int lpc11u6x_i2c_configure(const struct device *dev,
5958
return -ENOTSUP;
6059
}
6160

62-
clk_dev = device_get_binding(cfg->clock_drv);
63-
if (!clk_dev) {
64-
return -EINVAL;
65-
}
66-
6761
k_mutex_lock(&data->mutex, K_FOREVER);
68-
lpc11u6x_i2c_set_bus_speed(cfg, clk_dev, speed);
62+
lpc11u6x_i2c_set_bus_speed(cfg, cfg->clock_dev, speed);
6963

7064
ret = pinctrl_apply_state(cfg->pincfg, mux_selection);
7165
if (ret) {
@@ -313,7 +307,6 @@ static int lpc11u6x_i2c_init(const struct device *dev)
313307
{
314308
const struct lpc11u6x_i2c_config *cfg = dev->config;
315309
struct lpc11u6x_i2c_data *data = dev->data;
316-
const struct device *clk_dev;
317310
int err;
318311

319312
err = pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_DEFAULT);
@@ -322,14 +315,10 @@ static int lpc11u6x_i2c_init(const struct device *dev)
322315
}
323316

324317
/* Configure clock and de-assert reset for I2Cx */
325-
clk_dev = device_get_binding(cfg->clock_drv);
326-
if (!clk_dev) {
327-
return -EINVAL;
328-
}
329-
clock_control_on(clk_dev, (clock_control_subsys_t) cfg->clkid);
318+
clock_control_on(cfg->clock_dev, (clock_control_subsys_t) cfg->clkid);
330319

331320
/* Configure bus speed. Default is 100KHz */
332-
lpc11u6x_i2c_set_bus_speed(cfg, clk_dev, 100000);
321+
lpc11u6x_i2c_set_bus_speed(cfg, cfg->clock_dev, 100000);
333322

334323
/* Clear all control bytes and enable I2C interface */
335324
cfg->base->con_clr = LPC11U6X_I2C_CONTROL_AA | LPC11U6X_I2C_CONTROL_SI |
@@ -362,7 +351,7 @@ PINCTRL_DT_INST_DEFINE(idx); \
362351
static const struct lpc11u6x_i2c_config i2c_cfg_##idx = { \
363352
.base = \
364353
(struct lpc11u6x_i2c_regs *) DT_INST_REG_ADDR(idx), \
365-
.clock_drv = DT_LABEL(DT_INST_PHANDLE(idx, clocks)), \
354+
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(idx)), \
366355
.irq_config_func = lpc11u6x_i2c_isr_config_##idx, \
367356
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(idx), \
368357
.clkid = DT_INST_PHA_BY_IDX(idx, clocks, 0, clkid), \

drivers/i2c/i2c_lpc11u6x.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct lpc11u6x_i2c_regs {
6969

7070
struct lpc11u6x_i2c_config {
7171
struct lpc11u6x_i2c_regs *base;
72-
char *clock_drv;
72+
const struct device *clock_dev;
7373
void (*irq_config_func)(const struct device *dev);
7474
uint32_t clkid;
7575
const struct pinctrl_dev_config *pincfg;

0 commit comments

Comments
 (0)