mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-13 01:52:44 +00:00
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 <u.kleine-koenig@pengutronix.de> Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
parent
9a6ac822a2
commit
28a1dadc49
1 changed files with 6 additions and 12 deletions
|
@ -33,7 +33,6 @@
|
||||||
ATMEL_TC_BEEVT | ATMEL_TC_BSWTRG)
|
ATMEL_TC_BEEVT | ATMEL_TC_BSWTRG)
|
||||||
|
|
||||||
struct atmel_tcb_pwm_device {
|
struct atmel_tcb_pwm_device {
|
||||||
enum pwm_polarity polarity; /* PWM polarity */
|
|
||||||
unsigned div; /* PWM clock divider */
|
unsigned div; /* PWM clock divider */
|
||||||
unsigned duty; /* PWM duty expressed in clk cycles */
|
unsigned duty; /* PWM duty expressed in clk cycles */
|
||||||
unsigned period; /* PWM period expressed in clk cycles */
|
unsigned period; /* PWM period expressed in clk cycles */
|
||||||
|
@ -79,7 +78,6 @@ static int atmel_tcb_pwm_request(struct pwm_chip *chip,
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
tcbpwm->polarity = PWM_POLARITY_NORMAL;
|
|
||||||
tcbpwm->duty = 0;
|
tcbpwm->duty = 0;
|
||||||
tcbpwm->period = 0;
|
tcbpwm->period = 0;
|
||||||
tcbpwm->div = 0;
|
tcbpwm->div = 0;
|
||||||
|
@ -122,12 +120,12 @@ static void atmel_tcb_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||||
clk_disable_unprepare(tcbpwmc->clk);
|
clk_disable_unprepare(tcbpwmc->clk);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
|
static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||||
|
enum pwm_polarity polarity)
|
||||||
{
|
{
|
||||||
struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
|
struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
|
||||||
struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm];
|
struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm];
|
||||||
unsigned cmr;
|
unsigned cmr;
|
||||||
enum pwm_polarity polarity = tcbpwm->polarity;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If duty is 0 the timer will be stopped and we have to
|
* 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)
|
||||||
spin_unlock(&tcbpwmc->lock);
|
spin_unlock(&tcbpwmc->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
|
static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||||
|
enum pwm_polarity polarity)
|
||||||
{
|
{
|
||||||
struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
|
struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
|
||||||
struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm];
|
struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm];
|
||||||
u32 cmr;
|
u32 cmr;
|
||||||
enum pwm_polarity polarity = tcbpwm->polarity;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If duty is 0 the timer will be stopped and we have to
|
* 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,
|
||||||
static int atmel_tcb_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
static int atmel_tcb_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||||
const struct pwm_state *state)
|
const struct pwm_state *state)
|
||||||
{
|
{
|
||||||
struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
|
|
||||||
struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm];
|
|
||||||
int duty_cycle, period;
|
int duty_cycle, period;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
tcbpwm->polarity = state->polarity;
|
|
||||||
|
|
||||||
if (!state->enabled) {
|
if (!state->enabled) {
|
||||||
atmel_tcb_pwm_disable(chip, pwm);
|
atmel_tcb_pwm_disable(chip, pwm, state->polarity);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +357,7 @@ static int atmel_tcb_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return atmel_tcb_pwm_enable(chip, pwm);
|
return atmel_tcb_pwm_enable(chip, pwm, state->polarity);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pwm_ops atmel_tcb_pwm_ops = {
|
static const struct pwm_ops atmel_tcb_pwm_ops = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue