pwm: Make use of pwm_get_xxx() helpers where appropriate
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Wed, 1 Jul 2015 08:21:50 +0000 (10:21 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Mon, 20 Jul 2015 07:53:22 +0000 (09:53 +0200)
Use the pwm_get_xxx() helpers instead of directly accessing the fields
in struct pwm_device. This will allow us to smoothly move to the atomic
update approach.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-atmel.c
drivers/pwm/pwm-bcm-kona.c
drivers/pwm/pwm-imx.c
drivers/pwm/pwm-rockchip.c
drivers/pwm/sysfs.c

index b3b294de88e0a1d0bbe61ba6b79f7b7ca03b5d15..0e4bd4e8e5823727c03b7701ad893b4cae1f7e7e 100644 (file)
@@ -114,7 +114,7 @@ static int atmel_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
        u32 val;
        int ret;
 
-       if (pwm_is_enabled(pwm) && (period_ns != pwm->period)) {
+       if (pwm_is_enabled(pwm) && (period_ns != pwm_get_period(pwm))) {
                dev_err(chip->dev, "cannot change PWM period while enabled\n");
                return -EBUSY;
        }
index dfdcf88279ae1c72a4b1e014b1773d80d6aebd67..920cd1b5aa9d64f00bc0699c74a24677c1dc0654 100644 (file)
@@ -194,7 +194,8 @@ static int kona_pwmc_enable(struct pwm_chip *chip, struct pwm_device *pwm)
                return ret;
        }
 
-       ret = kona_pwmc_config(chip, pwm, pwm->duty_cycle, pwm->period);
+       ret = kona_pwmc_config(chip, pwm, pwm_get_duty_cycle(pwm),
+                              pwm_get_period(pwm));
        if (ret < 0) {
                clk_disable_unprepare(kp->clk);
                return ret;
index 008dc646225e6a270178644b7e5a87578140d4ff..d600fd5cd4bac9a434a20798328d513d89b5452f 100644 (file)
@@ -129,7 +129,8 @@ static int imx_pwm_config_v2(struct pwm_chip *chip,
                sr = readl(imx->mmio_base + MX3_PWMSR);
                fifoav = sr & MX3_PWMSR_FIFOAV_MASK;
                if (fifoav == MX3_PWMSR_FIFOAV_4WORDS) {
-                       period_ms = DIV_ROUND_UP(pwm->period, NSEC_PER_MSEC);
+                       period_ms = DIV_ROUND_UP(pwm_get_period(pwm),
+                                                NSEC_PER_MSEC);
                        msleep(period_ms);
 
                        sr = readl(imx->mmio_base + MX3_PWMSR);
index 9442df244101772259a0ddb6824fe6035c4dd568..7d9cc9049522348dd15951f927ed4649b1cdf364 100644 (file)
@@ -83,7 +83,7 @@ static void rockchip_pwm_set_enable_v2(struct pwm_chip *chip,
                          PWM_CONTINUOUS;
        u32 val;
 
-       if (pwm->polarity == PWM_POLARITY_INVERSED)
+       if (pwm_get_polarity(pwm) == PWM_POLARITY_INVERSED)
                enable_conf |= PWM_DUTY_NEGATIVE | PWM_INACTIVE_POSITIVE;
        else
                enable_conf |= PWM_DUTY_POSITIVE | PWM_INACTIVE_NEGATIVE;
index eecf21d68108264a0e8e96d4ed22c5610794fb7c..ac0abecfbaa017c6ef0ad7369db98762c3b143bc 100644 (file)
@@ -46,7 +46,7 @@ static ssize_t pwm_period_show(struct device *child,
 {
        const struct pwm_device *pwm = child_to_pwm_device(child);
 
-       return sprintf(buf, "%u\n", pwm->period);
+       return sprintf(buf, "%u\n", pwm_get_period(pwm));
 }
 
 static ssize_t pwm_period_store(struct device *child,
@@ -61,7 +61,7 @@ static ssize_t pwm_period_store(struct device *child,
        if (ret)
                return ret;
 
-       ret = pwm_config(pwm, pwm->duty_cycle, val);
+       ret = pwm_config(pwm, pwm_get_duty_cycle(pwm), val);
 
        return ret ? : size;
 }
@@ -72,7 +72,7 @@ static ssize_t pwm_duty_cycle_show(struct device *child,
 {
        const struct pwm_device *pwm = child_to_pwm_device(child);
 
-       return sprintf(buf, "%u\n", pwm->duty_cycle);
+       return sprintf(buf, "%u\n", pwm_get_duty_cycle(pwm));
 }
 
 static ssize_t pwm_duty_cycle_store(struct device *child,
@@ -87,7 +87,7 @@ static ssize_t pwm_duty_cycle_store(struct device *child,
        if (ret)
                return ret;
 
-       ret = pwm_config(pwm, val, pwm->period);
+       ret = pwm_config(pwm, val, pwm_get_period(pwm));
 
        return ret ? : size;
 }
@@ -134,7 +134,8 @@ static ssize_t pwm_polarity_show(struct device *child,
 {
        const struct pwm_device *pwm = child_to_pwm_device(child);
 
-       return sprintf(buf, "%s\n", pwm->polarity ? "inversed" : "normal");
+       return sprintf(buf, "%s\n",
+                      pwm_get_polarity(pwm) ? "inversed" : "normal");
 }
 
 static ssize_t pwm_polarity_store(struct device *child,
This page took 0.029138 seconds and 5 git commands to generate.