[linux-yocto] [PATCH] drivers/mfd/pca9685-pwm.c: Update to reflect changes in patches from upstream

Bruce Ashfield bruce.ashfield at windriver.com
Thu Jul 21 19:58:17 PDT 2016


On 2016-07-21 3:21 PM, Saul Wold wrote:
> There are some patches brought into to 4.4 from upstream that change
> the pwm structure and move period and duty_cycle into a state structure
> so fix these up. Additional address the removal of PWMF_ENABLED in favor
> checking the state via pwm_is_enabled().
>

What branch is the target for this ? I could hunt around and
figure it out, but I wanted to check with you as well.

I had a quick look and the pca9685-pwm.c is quite a bit different
in the latest kernel (i.e. it is under drivers/pwm/pwm-pca9685.c)
.. so I assume that given your description, there isn't an upstream
fix for this and the file / routines in question are unique to
the BSP support in linux-yocto ?

If so, I guess I won't ask if this is already fixed upstream.

We could split the patch into the pwm struct fix, and the state
change .. but I won't insist, since it already looks this is
being stacked onto other pending patches for usptream.

Bruce

> Signed-off-by: Saul Wold <sgw at linux.intel.com>
> ---
>  drivers/mfd/pca9685-pwm.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/mfd/pca9685-pwm.c b/drivers/mfd/pca9685-pwm.c
> index 0c05263..3a79c33 100644
> --- a/drivers/mfd/pca9685-pwm.c
> +++ b/drivers/mfd/pca9685-pwm.c
> @@ -80,16 +80,16 @@ int pca9685_update_prescale(struct pca9685 *pca, unsigned period_ns,
>  	if (reconfigure_channels) {
>  		for (i = 0; i < pca->pwm_chip.npwm; i++) {
>  			pwm = &pca->pwm_chip.pwms[i];
> -			pwm->period = period_ns;
> -			if (pwm->duty_cycle > 0) {
> +			pwm->state.period = period_ns;
> +			if (pwm->state.duty_cycle > 0) {
>  				/* Scale the rise time to maintain duty cycle */
>  				duty_scale = period_ns;
>  				duty_scale *= 1000000;
>  				do_div(duty_scale, pca->pwm_period);
> -				new_duty_ns = duty_scale * pwm->duty_cycle;
> +				new_duty_ns = duty_scale * pwm->state.duty_cycle;
>  				do_div(new_duty_ns, 1000000);
>  				/* Update the duty_cycle */
> -				pwm_config(pwm, (int)new_duty_ns, pwm->period);
> +				pwm_config(pwm, (int)new_duty_ns, pwm->state.period);
>  			}
>  		}
>  	}
> @@ -159,7 +159,7 @@ static int pca9685_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>  	/* Changing PWM period for a single channel at run-time not allowed.
>  	 * The PCA9685 PWM clock is shared across all PWM channels
>  	 */
> -	if (unlikely(period_ns != pwm->period))
> +	if (unlikely(period_ns != pwm->state.period))
>  		return -EPERM;
>
>  	if (unlikely(pwm->hwpwm >= PCA9685_MAXCHAN)) {
> @@ -180,7 +180,7 @@ static int pca9685_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>  	else /* clear the LED_FULL bit */
>  		regmap_write(pca->regmap, reg_on_h, 0x00);
>
> -	full_off = !test_bit(PWMF_ENABLED, &pwm->flags) << 4;
> +	full_off = !pwm_is_enabled(pwm);
>
>  	regmap_write(pca->regmap, reg_off_l, (int)duty & 0xff);
>
> @@ -246,7 +246,7 @@ static int pca9685_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
>  		(gpiochip_is_requested(gpio_chip, channel)))
>  			return -EBUSY;
>
> -	pwm->period = pca->pwm_period;
> +	pwm->state.period = pca->pwm_period;
>
>  	return 0;
>  }
>



More information about the linux-yocto mailing list