Commit aecab554 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Thierry Reding

pwm: atmel-hlcdc: Use consistent variable naming

In PWM drivers the variable name "chip" is usually only used for struct
pwm_chip pointers. This driver however used "chip" for its driver data
and pwm_chip pointers are named "chip", too, when there is no driver
data around and "c" otherwise. Instead use "atmel" for driver data and
always "chip" for pwm_chips.
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: default avatarClaudiu Beznea <claudiu.beznea@tuxon.dev>
[thierry.reding@gmail.com: replace ddata by atmel]
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent b4f78ff7
...@@ -38,11 +38,11 @@ static inline struct atmel_hlcdc_pwm *to_atmel_hlcdc_pwm(struct pwm_chip *chip) ...@@ -38,11 +38,11 @@ static inline struct atmel_hlcdc_pwm *to_atmel_hlcdc_pwm(struct pwm_chip *chip)
return container_of(chip, struct atmel_hlcdc_pwm, chip); return container_of(chip, struct atmel_hlcdc_pwm, chip);
} }
static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm, static int atmel_hlcdc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
const struct pwm_state *state) const struct pwm_state *state)
{ {
struct atmel_hlcdc_pwm *chip = to_atmel_hlcdc_pwm(c); struct atmel_hlcdc_pwm *atmel = to_atmel_hlcdc_pwm(chip);
struct atmel_hlcdc *hlcdc = chip->hlcdc; struct atmel_hlcdc *hlcdc = atmel->hlcdc;
unsigned int status; unsigned int status;
int ret; int ret;
...@@ -54,7 +54,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm, ...@@ -54,7 +54,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
u32 pwmcfg; u32 pwmcfg;
int pres; int pres;
if (!chip->errata || !chip->errata->slow_clk_erratum) { if (!atmel->errata || !atmel->errata->slow_clk_erratum) {
clk_freq = clk_get_rate(new_clk); clk_freq = clk_get_rate(new_clk);
if (!clk_freq) if (!clk_freq)
return -EINVAL; return -EINVAL;
...@@ -64,7 +64,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm, ...@@ -64,7 +64,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
} }
/* Errata: cannot use slow clk on some IP revisions */ /* Errata: cannot use slow clk on some IP revisions */
if ((chip->errata && chip->errata->slow_clk_erratum) || if ((atmel->errata && atmel->errata->slow_clk_erratum) ||
clk_period_ns > state->period) { clk_period_ns > state->period) {
new_clk = hlcdc->sys_clk; new_clk = hlcdc->sys_clk;
clk_freq = clk_get_rate(new_clk); clk_freq = clk_get_rate(new_clk);
...@@ -77,8 +77,8 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm, ...@@ -77,8 +77,8 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
for (pres = 0; pres <= ATMEL_HLCDC_PWMPS_MAX; pres++) { for (pres = 0; pres <= ATMEL_HLCDC_PWMPS_MAX; pres++) {
/* Errata: cannot divide by 1 on some IP revisions */ /* Errata: cannot divide by 1 on some IP revisions */
if (!pres && chip->errata && if (!pres && atmel->errata &&
chip->errata->div1_clk_erratum) atmel->errata->div1_clk_erratum)
continue; continue;
if ((clk_period_ns << pres) >= state->period) if ((clk_period_ns << pres) >= state->period)
...@@ -90,7 +90,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm, ...@@ -90,7 +90,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
pwmcfg = ATMEL_HLCDC_PWMPS(pres); pwmcfg = ATMEL_HLCDC_PWMPS(pres);
if (new_clk != chip->cur_clk) { if (new_clk != atmel->cur_clk) {
u32 gencfg = 0; u32 gencfg = 0;
int ret; int ret;
...@@ -98,8 +98,8 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm, ...@@ -98,8 +98,8 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
if (ret) if (ret)
return ret; return ret;
clk_disable_unprepare(chip->cur_clk); clk_disable_unprepare(atmel->cur_clk);
chip->cur_clk = new_clk; atmel->cur_clk = new_clk;
if (new_clk == hlcdc->sys_clk) if (new_clk == hlcdc->sys_clk)
gencfg = ATMEL_HLCDC_CLKPWMSEL; gencfg = ATMEL_HLCDC_CLKPWMSEL;
...@@ -160,8 +160,8 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm, ...@@ -160,8 +160,8 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
if (ret) if (ret)
return ret; return ret;
clk_disable_unprepare(chip->cur_clk); clk_disable_unprepare(atmel->cur_clk);
chip->cur_clk = NULL; atmel->cur_clk = NULL;
} }
return 0; return 0;
...@@ -183,31 +183,32 @@ static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = { ...@@ -183,31 +183,32 @@ static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = {
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int atmel_hlcdc_pwm_suspend(struct device *dev) static int atmel_hlcdc_pwm_suspend(struct device *dev)
{ {
struct atmel_hlcdc_pwm *chip = dev_get_drvdata(dev); struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev);
/* Keep the periph clock enabled if the PWM is still running. */ /* Keep the periph clock enabled if the PWM is still running. */
if (pwm_is_enabled(&chip->chip.pwms[0])) if (pwm_is_enabled(&atmel->chip.pwms[0]))
clk_disable_unprepare(chip->hlcdc->periph_clk); clk_disable_unprepare(atmel->hlcdc->periph_clk);
return 0; return 0;
} }
static int atmel_hlcdc_pwm_resume(struct device *dev) static int atmel_hlcdc_pwm_resume(struct device *dev)
{ {
struct atmel_hlcdc_pwm *chip = dev_get_drvdata(dev); struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev);
struct pwm_state state; struct pwm_state state;
int ret; int ret;
pwm_get_state(&chip->chip.pwms[0], &state); pwm_get_state(&atmel->chip.pwms[0], &state);
/* Re-enable the periph clock it was stopped during suspend. */ /* Re-enable the periph clock it was stopped during suspend. */
if (!state.enabled) { if (!state.enabled) {
ret = clk_prepare_enable(chip->hlcdc->periph_clk); ret = clk_prepare_enable(atmel->hlcdc->periph_clk);
if (ret) if (ret)
return ret; return ret;
} }
return atmel_hlcdc_pwm_apply(&chip->chip, &chip->chip.pwms[0], &state); return atmel_hlcdc_pwm_apply(&atmel->chip, &atmel->chip.pwms[0],
&state);
} }
#endif #endif
...@@ -244,14 +245,14 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev) ...@@ -244,14 +245,14 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
{ {
const struct of_device_id *match; const struct of_device_id *match;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct atmel_hlcdc_pwm *chip; struct atmel_hlcdc_pwm *atmel;
struct atmel_hlcdc *hlcdc; struct atmel_hlcdc *hlcdc;
int ret; int ret;
hlcdc = dev_get_drvdata(dev->parent); hlcdc = dev_get_drvdata(dev->parent);
chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); atmel = devm_kzalloc(dev, sizeof(*atmel), GFP_KERNEL);
if (!chip) if (!atmel)
return -ENOMEM; return -ENOMEM;
ret = clk_prepare_enable(hlcdc->periph_clk); ret = clk_prepare_enable(hlcdc->periph_clk);
...@@ -260,31 +261,31 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev) ...@@ -260,31 +261,31 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
match = of_match_node(atmel_hlcdc_dt_ids, dev->parent->of_node); match = of_match_node(atmel_hlcdc_dt_ids, dev->parent->of_node);
if (match) if (match)
chip->errata = match->data; atmel->errata = match->data;
chip->hlcdc = hlcdc; atmel->hlcdc = hlcdc;
chip->chip.ops = &atmel_hlcdc_pwm_ops; atmel->chip.ops = &atmel_hlcdc_pwm_ops;
chip->chip.dev = dev; atmel->chip.dev = dev;
chip->chip.npwm = 1; atmel->chip.npwm = 1;
ret = pwmchip_add(&chip->chip); ret = pwmchip_add(&atmel->chip);
if (ret) { if (ret) {
clk_disable_unprepare(hlcdc->periph_clk); clk_disable_unprepare(hlcdc->periph_clk);
return ret; return ret;
} }
platform_set_drvdata(pdev, chip); platform_set_drvdata(pdev, atmel);
return 0; return 0;
} }
static void atmel_hlcdc_pwm_remove(struct platform_device *pdev) static void atmel_hlcdc_pwm_remove(struct platform_device *pdev)
{ {
struct atmel_hlcdc_pwm *chip = platform_get_drvdata(pdev); struct atmel_hlcdc_pwm *atmel = platform_get_drvdata(pdev);
pwmchip_remove(&chip->chip); pwmchip_remove(&atmel->chip);
clk_disable_unprepare(chip->hlcdc->periph_clk); clk_disable_unprepare(atmel->hlcdc->periph_clk);
} }
static const struct of_device_id atmel_hlcdc_pwm_dt_ids[] = { static const struct of_device_id atmel_hlcdc_pwm_dt_ids[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment