Skip to content

Commit 28a1dad

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: atmel-tcb: Don't track polarity in driver data
struct atmel_tcb_pwm_device::polarity is only used in atmel_tcb_pwm_enable and atmel_tcb_pwm_disable(). These functions are only called by atmel_tcb_pwm_apply() after the member variable was assigned to state->polarity. So the value assigned in atmel_tcb_pwm_request() is never used and the member can be dropped from struct atmel_tcb_pwm_device. Signed-off-by: Uwe Kleine-König <[email protected]> Reviewed-by: Claudiu Beznea <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 9a6ac82 commit 28a1dad

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

drivers/pwm/pwm-atmel-tcb.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
ATMEL_TC_BEEVT | ATMEL_TC_BSWTRG)
3434

3535
struct atmel_tcb_pwm_device {
36-
enum pwm_polarity polarity; /* PWM polarity */
3736
unsigned div; /* PWM clock divider */
3837
unsigned duty; /* PWM duty expressed in clk cycles */
3938
unsigned period; /* PWM period expressed in clk cycles */
@@ -79,7 +78,6 @@ static int atmel_tcb_pwm_request(struct pwm_chip *chip,
7978
if (ret)
8079
return ret;
8180

82-
tcbpwm->polarity = PWM_POLARITY_NORMAL;
8381
tcbpwm->duty = 0;
8482
tcbpwm->period = 0;
8583
tcbpwm->div = 0;
@@ -122,12 +120,12 @@ static void atmel_tcb_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
122120
clk_disable_unprepare(tcbpwmc->clk);
123121
}
124122

125-
static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
123+
static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm,
124+
enum pwm_polarity polarity)
126125
{
127126
struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
128127
struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm];
129128
unsigned cmr;
130-
enum pwm_polarity polarity = tcbpwm->polarity;
131129

132130
/*
133131
* If duty is 0 the timer will be stopped and we have to
@@ -179,12 +177,12 @@ static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
179177
spin_unlock(&tcbpwmc->lock);
180178
}
181179

182-
static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
180+
static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm,
181+
enum pwm_polarity polarity)
183182
{
184183
struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
185184
struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm];
186185
u32 cmr;
187-
enum pwm_polarity polarity = tcbpwm->polarity;
188186

189187
/*
190188
* If duty is 0 the timer will be stopped and we have to
@@ -344,15 +342,11 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
344342
static int atmel_tcb_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
345343
const struct pwm_state *state)
346344
{
347-
struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
348-
struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm];
349345
int duty_cycle, period;
350346
int ret;
351347

352-
tcbpwm->polarity = state->polarity;
353-
354348
if (!state->enabled) {
355-
atmel_tcb_pwm_disable(chip, pwm);
349+
atmel_tcb_pwm_disable(chip, pwm, state->polarity);
356350
return 0;
357351
}
358352

@@ -363,7 +357,7 @@ static int atmel_tcb_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
363357
if (ret)
364358
return ret;
365359

366-
return atmel_tcb_pwm_enable(chip, pwm);
360+
return atmel_tcb_pwm_enable(chip, pwm, state->polarity);
367361
}
368362

369363
static const struct pwm_ops atmel_tcb_pwm_ops = {

0 commit comments

Comments
 (0)