drivers: watchdog: NXP: Convert clock control to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access to the clock controller device. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
8e75fff580
commit
99d1b292cc
2 changed files with 6 additions and 17 deletions
|
@ -19,7 +19,7 @@ LOG_MODULE_REGISTER(wdt_mcux_wdog);
|
|||
|
||||
struct mcux_wdog_config {
|
||||
WDOG_Type *base;
|
||||
char *clock_name;
|
||||
const struct device *clock_dev;
|
||||
clock_control_subsys_t clock_subsys;
|
||||
void (*irq_config_func)(const struct device *dev);
|
||||
};
|
||||
|
@ -71,7 +71,6 @@ static int mcux_wdog_install_timeout(const struct device *dev,
|
|||
{
|
||||
const struct mcux_wdog_config *config = dev->config;
|
||||
struct mcux_wdog_data *data = dev->data;
|
||||
const struct device *clock_dev;
|
||||
uint32_t clock_freq;
|
||||
|
||||
if (data->timeout_valid) {
|
||||
|
@ -79,12 +78,7 @@ static int mcux_wdog_install_timeout(const struct device *dev,
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
clock_dev = device_get_binding(config->clock_name);
|
||||
if (clock_dev == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (clock_control_get_rate(clock_dev, config->clock_subsys,
|
||||
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||
&clock_freq)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -167,7 +161,7 @@ static void mcux_wdog_config_func_0(const struct device *dev);
|
|||
|
||||
static const struct mcux_wdog_config mcux_wdog_config_0 = {
|
||||
.base = (WDOG_Type *) DT_INST_REG_ADDR(0),
|
||||
.clock_name = DT_INST_CLOCKS_LABEL(0),
|
||||
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(0)),
|
||||
.clock_subsys = (clock_control_subsys_t)
|
||||
DT_INST_CLOCKS_CELL(0, name),
|
||||
.irq_config_func = mcux_wdog_config_func_0,
|
||||
|
|
|
@ -24,7 +24,7 @@ struct mcux_wdog32_config {
|
|||
#if DT_NODE_HAS_PROP(DT_INST_PHANDLE(0, clocks), clock_frequency)
|
||||
uint32_t clock_frequency;
|
||||
#else /* !DT_NODE_HAS_PROP(DT_INST_PHANDLE(0, clocks), clock_frequency) */
|
||||
char *clock_name;
|
||||
const struct device *clock_dev;
|
||||
clock_control_subsys_t clock_subsys;
|
||||
#endif /* !DT_NODE_HAS_PROP(DT_INST_PHANDLE(0, clocks), clock_frequency) */
|
||||
wdog32_clock_source_t clk_source;
|
||||
|
@ -93,12 +93,7 @@ static int mcux_wdog32_install_timeout(const struct device *dev,
|
|||
#if DT_NODE_HAS_PROP(DT_INST_PHANDLE(0, clocks), clock_frequency)
|
||||
clock_freq = config->clock_frequency;
|
||||
#else /* !DT_NODE_HAS_PROP(DT_INST_PHANDLE(0, clocks), clock_frequency) */
|
||||
const struct device *clock_dev = device_get_binding(config->clock_name);
|
||||
if (clock_dev == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (clock_control_get_rate(clock_dev, config->clock_subsys,
|
||||
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||
&clock_freq)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -194,7 +189,7 @@ static const struct mcux_wdog32_config mcux_wdog32_config_0 = {
|
|||
#if DT_NODE_HAS_PROP(DT_INST_PHANDLE(0, clocks), clock_frequency)
|
||||
.clock_frequency = DT_INST_PROP_BY_PHANDLE(0, clocks, clock_frequency),
|
||||
#else /* !DT_NODE_HAS_PROP(DT_INST_PHANDLE(0, clocks), clock_frequency) */
|
||||
.clock_name = DT_INST_CLOCKS_LABEL(0),
|
||||
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(0)),
|
||||
.clock_subsys = (clock_control_subsys_t)
|
||||
DT_INST_CLOCKS_CELL(0, name),
|
||||
#endif /* DT_NODE_HAS_PROP(DT_INST_PHANDLE(0, clocks), clock_frequency) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue