@@ -51,6 +51,7 @@ struct dwc_pwm_ctx {
};
struct dwc_pwm {
+ struct device *parent;
void __iomem *base;
struct dwc_pwm_ctx ctx[DWC_TIMERS_TOTAL];
};
@@ -153,12 +154,12 @@ static int dwc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
if (state->enabled) {
if (!pwm->state.enabled)
- pm_runtime_get_sync(chip->dev);
+ pm_runtime_get_sync(dwc->parent);
return __dwc_pwm_configure_timer(dwc, pwm, state);
} else {
if (pwm->state.enabled) {
__dwc_pwm_set_enable(dwc, pwm->hwpwm, false);
- pm_runtime_put_sync(chip->dev);
+ pm_runtime_put_sync(dwc->parent);
}
}
@@ -171,7 +172,7 @@ static int dwc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
struct dwc_pwm *dwc = to_dwc_pwm(chip);
u64 duty, period;
- pm_runtime_get_sync(chip->dev);
+ pm_runtime_get_sync(dwc->parent);
state->enabled = !!(dwc_pwm_readl(dwc,
DWC_TIM_CTRL(pwm->hwpwm)) & DWC_TIM_CTRL_EN);
@@ -189,7 +190,7 @@ static int dwc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
state->polarity = PWM_POLARITY_INVERSED;
- pm_runtime_put_sync(chip->dev);
+ pm_runtime_put_sync(dwc->parent);
return 0;
}
@@ -202,8 +203,9 @@ static const struct pwm_ops dwc_pwm_ops = {
static struct pwm_chip *dwc_pwm_alloc(struct device *dev)
{
struct pwm_chip *chip;
+ struct dwc_pwm *dwc;
- chip = devm_pwmchip_alloc(dev, DWC_TIMERS_TOTAL, sizeof(struct dwc_pwm));
+ chip = devm_pwmchip_alloc(dev, DWC_TIMERS_TOTAL, sizeof(*dwc));
if (!chip)
return NULL;
@@ -211,6 +213,9 @@ static struct pwm_chip *dwc_pwm_alloc(struct device *dev)
dev_set_drvdata(dev, chip);
+ dwc = to_dwc_pwm(chip);
+ dwc->parent = dev;
+
return chip;
}
struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, store a pointer to the parent device in driver data. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/pwm-dwc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)