Re: [PATCH v6]pwm: add BCM2835 PWM driver

From: Stephen Warren
Date: Tue Oct 07 2014 - 11:35:59 EST


On 10/07/2014 07:04 AM, Bart Tanghe wrote:
> Add pwm driver for Broadcom BCM2835 processor (Raspberry Pi)

Just a few nits below,

> diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c

> +#define PWM_CONTROL_MASK 0xff
> +#define PWM_MODE 0x80 /* set timer in pwm mode */
> +#define DEFAULT 0xff /* set timer in default mode */

BTW, it'd be nice to say default *what*. Perhaps DEFAULT_PWM_MODE?

> +static int bcm2835_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
> +{
> + struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
> + u32 value;
> +
> + value = readl(pc->base);
> + value &= ~(PWM_CONTROL_MASK << PWM_CONTROL_STRIDE * pwm->hwpwm);
> + value |= (PWM_MODE << (PWM_CONTROL_STRIDE * pwm->hwpwm));

Presence/absence of brackets around the STRIDE*pwm calculation is still
inconsistent here, and in other places.

> +static void bcm2835_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
> +{
> + struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
> + u32 value;
> +
> + value = readl(pc->base);
> + value &= (~DEFAULT << (PWM_CONTROL_STRIDE * pwm->hwpwm));

Why clear the "DEFAULT" bits here; why not use PWM_CONTROL_MASK?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/