Commit 7fc81e23 authored by Uwe Kleine-König's avatar Uwe Kleine-König

pwm: omap-dmtimer: Make use of pwmchip_parent() accessor

struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Link: https://lore.kernel.org/r/6681ebd024c2b8b2315ca3da5cac612e5f433d63.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 8c01031a
...@@ -155,7 +155,7 @@ static int pwm_omap_dmtimer_config(struct pwm_chip *chip, ...@@ -155,7 +155,7 @@ static int pwm_omap_dmtimer_config(struct pwm_chip *chip,
unsigned long clk_rate; unsigned long clk_rate;
struct clk *fclk; struct clk *fclk;
dev_dbg(chip->dev, "requested duty cycle: %d ns, period: %d ns\n", dev_dbg(pwmchip_parent(chip), "requested duty cycle: %d ns, period: %d ns\n",
duty_ns, period_ns); duty_ns, period_ns);
if (duty_ns == pwm_get_duty_cycle(pwm) && if (duty_ns == pwm_get_duty_cycle(pwm) &&
...@@ -164,17 +164,17 @@ static int pwm_omap_dmtimer_config(struct pwm_chip *chip, ...@@ -164,17 +164,17 @@ static int pwm_omap_dmtimer_config(struct pwm_chip *chip,
fclk = omap->pdata->get_fclk(omap->dm_timer); fclk = omap->pdata->get_fclk(omap->dm_timer);
if (!fclk) { if (!fclk) {
dev_err(chip->dev, "invalid pmtimer fclk\n"); dev_err(pwmchip_parent(chip), "invalid pmtimer fclk\n");
return -EINVAL; return -EINVAL;
} }
clk_rate = clk_get_rate(fclk); clk_rate = clk_get_rate(fclk);
if (!clk_rate) { if (!clk_rate) {
dev_err(chip->dev, "invalid pmtimer fclk rate\n"); dev_err(pwmchip_parent(chip), "invalid pmtimer fclk rate\n");
return -EINVAL; return -EINVAL;
} }
dev_dbg(chip->dev, "clk rate: %luHz\n", clk_rate); dev_dbg(pwmchip_parent(chip), "clk rate: %luHz\n", clk_rate);
/* /*
* Calculate the appropriate load and match values based on the * Calculate the appropriate load and match values based on the
...@@ -196,27 +196,27 @@ static int pwm_omap_dmtimer_config(struct pwm_chip *chip, ...@@ -196,27 +196,27 @@ static int pwm_omap_dmtimer_config(struct pwm_chip *chip,
duty_cycles = pwm_omap_dmtimer_get_clock_cycles(clk_rate, duty_ns); duty_cycles = pwm_omap_dmtimer_get_clock_cycles(clk_rate, duty_ns);
if (period_cycles < 2) { if (period_cycles < 2) {
dev_info(chip->dev, dev_info(pwmchip_parent(chip),
"period %d ns too short for clock rate %lu Hz\n", "period %d ns too short for clock rate %lu Hz\n",
period_ns, clk_rate); period_ns, clk_rate);
return -EINVAL; return -EINVAL;
} }
if (duty_cycles < 1) { if (duty_cycles < 1) {
dev_dbg(chip->dev, dev_dbg(pwmchip_parent(chip),
"duty cycle %d ns is too short for clock rate %lu Hz\n", "duty cycle %d ns is too short for clock rate %lu Hz\n",
duty_ns, clk_rate); duty_ns, clk_rate);
dev_dbg(chip->dev, "using minimum of 1 clock cycle\n"); dev_dbg(pwmchip_parent(chip), "using minimum of 1 clock cycle\n");
duty_cycles = 1; duty_cycles = 1;
} else if (duty_cycles >= period_cycles) { } else if (duty_cycles >= period_cycles) {
dev_dbg(chip->dev, dev_dbg(pwmchip_parent(chip),
"duty cycle %d ns is too long for period %d ns at clock rate %lu Hz\n", "duty cycle %d ns is too long for period %d ns at clock rate %lu Hz\n",
duty_ns, period_ns, clk_rate); duty_ns, period_ns, clk_rate);
dev_dbg(chip->dev, "using maximum of 1 clock cycle less than period\n"); dev_dbg(pwmchip_parent(chip), "using maximum of 1 clock cycle less than period\n");
duty_cycles = period_cycles - 1; duty_cycles = period_cycles - 1;
} }
dev_dbg(chip->dev, "effective duty cycle: %lld ns, period: %lld ns\n", dev_dbg(pwmchip_parent(chip), "effective duty cycle: %lld ns, period: %lld ns\n",
DIV_ROUND_CLOSEST_ULL((u64)NSEC_PER_SEC * duty_cycles, DIV_ROUND_CLOSEST_ULL((u64)NSEC_PER_SEC * duty_cycles,
clk_rate), clk_rate),
DIV_ROUND_CLOSEST_ULL((u64)NSEC_PER_SEC * period_cycles, DIV_ROUND_CLOSEST_ULL((u64)NSEC_PER_SEC * period_cycles,
...@@ -228,7 +228,7 @@ static int pwm_omap_dmtimer_config(struct pwm_chip *chip, ...@@ -228,7 +228,7 @@ static int pwm_omap_dmtimer_config(struct pwm_chip *chip,
omap->pdata->set_load(omap->dm_timer, load_value); omap->pdata->set_load(omap->dm_timer, load_value);
omap->pdata->set_match(omap->dm_timer, true, match_value); omap->pdata->set_match(omap->dm_timer, true, match_value);
dev_dbg(chip->dev, "load value: %#08x (%d), match value: %#08x (%d)\n", dev_dbg(pwmchip_parent(chip), "load value: %#08x (%d), match value: %#08x (%d)\n",
load_value, load_value, match_value, match_value); load_value, load_value, match_value, match_value);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment