From: claudiu beznea <claudiu.beznea@tuxon.dev>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Claudiu Beznea" <claudiu.beznea@microchip.com>
Cc: linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
kernel@pengutronix.de
Subject: Re: [PATCH 02/10] pwm: atmel-hlcdc: Use consistent variable naming
Date: Sun, 16 Jul 2023 16:04:03 +0300 [thread overview]
Message-ID: <9a0cb190-9344-dc26-b3dd-9895690e886f@tuxon.dev> (raw)
In-Reply-To: <20230714205623.2496590-3-u.kleine-koenig@pengutronix.de>
On 14.07.2023 23:56, Uwe Kleine-König wrote:
> 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 "ddata" for driver data and
> always "chip" for pwm_chips.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> ---
> drivers/pwm/pwm-atmel-hlcdc.c | 64 +++++++++++++++++------------------
> 1 file changed, 32 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
> index 96a709a9d49a..9b0165d61c49 100644
> --- a/drivers/pwm/pwm-atmel-hlcdc.c
> +++ b/drivers/pwm/pwm-atmel-hlcdc.c
> @@ -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);
> }
>
> -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)
> {
> - struct atmel_hlcdc_pwm *chip = to_atmel_hlcdc_pwm(c);
> - struct atmel_hlcdc *hlcdc = chip->hlcdc;
> + struct atmel_hlcdc_pwm *ddata = to_atmel_hlcdc_pwm(chip);
> + struct atmel_hlcdc *hlcdc = ddata->hlcdc;
> unsigned int status;
> int ret;
>
> @@ -54,7 +54,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
> u32 pwmcfg;
> int pres;
>
> - if (!chip->errata || !chip->errata->slow_clk_erratum) {
> + if (!ddata->errata || !ddata->errata->slow_clk_erratum) {
> clk_freq = clk_get_rate(new_clk);
> if (!clk_freq)
> return -EINVAL;
> @@ -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 */
> - if ((chip->errata && chip->errata->slow_clk_erratum) ||
> + if ((ddata->errata && ddata->errata->slow_clk_erratum) ||
> clk_period_ns > state->period) {
> new_clk = hlcdc->sys_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,
>
> for (pres = 0; pres <= ATMEL_HLCDC_PWMPS_MAX; pres++) {
> /* Errata: cannot divide by 1 on some IP revisions */
> - if (!pres && chip->errata &&
> - chip->errata->div1_clk_erratum)
> + if (!pres && ddata->errata &&
> + ddata->errata->div1_clk_erratum)
> continue;
>
> 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,
>
> pwmcfg = ATMEL_HLCDC_PWMPS(pres);
>
> - if (new_clk != chip->cur_clk) {
> + if (new_clk != ddata->cur_clk) {
> u32 gencfg = 0;
> int ret;
>
> @@ -98,8 +98,8 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
> if (ret)
> return ret;
>
> - clk_disable_unprepare(chip->cur_clk);
> - chip->cur_clk = new_clk;
> + clk_disable_unprepare(ddata->cur_clk);
> + ddata->cur_clk = new_clk;
>
> if (new_clk == hlcdc->sys_clk)
> gencfg = ATMEL_HLCDC_CLKPWMSEL;
> @@ -160,8 +160,8 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
> if (ret)
> return ret;
>
> - clk_disable_unprepare(chip->cur_clk);
> - chip->cur_clk = NULL;
> + clk_disable_unprepare(ddata->cur_clk);
> + ddata->cur_clk = NULL;
> }
>
> return 0;
> @@ -183,31 +183,31 @@ static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = {
> #ifdef CONFIG_PM_SLEEP
> static int atmel_hlcdc_pwm_suspend(struct device *dev)
> {
> - struct atmel_hlcdc_pwm *chip = dev_get_drvdata(dev);
> + struct atmel_hlcdc_pwm *ddata = dev_get_drvdata(dev);
>
> /* Keep the periph clock enabled if the PWM is still running. */
> - if (pwm_is_enabled(&chip->chip.pwms[0]))
> - clk_disable_unprepare(chip->hlcdc->periph_clk);
> + if (pwm_is_enabled(&ddata->chip.pwms[0]))
> + clk_disable_unprepare(ddata->hlcdc->periph_clk);
>
> return 0;
> }
>
> static int atmel_hlcdc_pwm_resume(struct device *dev)
> {
> - struct atmel_hlcdc_pwm *chip = dev_get_drvdata(dev);
> + struct atmel_hlcdc_pwm *ddata = dev_get_drvdata(dev);
> struct pwm_state state;
> int ret;
>
> - pwm_get_state(&chip->chip.pwms[0], &state);
> + pwm_get_state(&ddata->chip.pwms[0], &state);
>
> /* Re-enable the periph clock it was stopped during suspend. */
> if (!state.enabled) {
> - ret = clk_prepare_enable(chip->hlcdc->periph_clk);
> + ret = clk_prepare_enable(ddata->hlcdc->periph_clk);
> if (ret)
> return ret;
> }
>
> - return atmel_hlcdc_pwm_apply(&chip->chip, &chip->chip.pwms[0], &state);
> + return atmel_hlcdc_pwm_apply(&ddata->chip, &ddata->chip.pwms[0], &state);
> }
> #endif
>
> @@ -244,14 +244,14 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
> {
> const struct of_device_id *match;
> struct device *dev = &pdev->dev;
> - struct atmel_hlcdc_pwm *chip;
> + struct atmel_hlcdc_pwm *ddata;
> struct atmel_hlcdc *hlcdc;
> int ret;
>
> hlcdc = dev_get_drvdata(dev->parent);
>
> - chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
> - if (!chip)
> + ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
> + if (!ddata)
> return -ENOMEM;
>
> ret = clk_prepare_enable(hlcdc->periph_clk);
> @@ -260,31 +260,31 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
>
> match = of_match_node(atmel_hlcdc_dt_ids, dev->parent->of_node);
> if (match)
> - chip->errata = match->data;
> + ddata->errata = match->data;
>
> - chip->hlcdc = hlcdc;
> - chip->chip.ops = &atmel_hlcdc_pwm_ops;
> - chip->chip.dev = dev;
> - chip->chip.npwm = 1;
> + ddata->hlcdc = hlcdc;
> + ddata->chip.ops = &atmel_hlcdc_pwm_ops;
> + ddata->chip.dev = dev;
> + ddata->chip.npwm = 1;
>
> - ret = pwmchip_add(&chip->chip);
> + ret = pwmchip_add(&ddata->chip);
> if (ret) {
> clk_disable_unprepare(hlcdc->periph_clk);
> return ret;
> }
>
> - platform_set_drvdata(pdev, chip);
> + platform_set_drvdata(pdev, ddata);
>
> return 0;
> }
>
> static void atmel_hlcdc_pwm_remove(struct platform_device *pdev)
> {
> - struct atmel_hlcdc_pwm *chip = platform_get_drvdata(pdev);
> + struct atmel_hlcdc_pwm *ddata = platform_get_drvdata(pdev);
>
> - pwmchip_remove(&chip->chip);
> + pwmchip_remove(&ddata->chip);
>
> - clk_disable_unprepare(chip->hlcdc->periph_clk);
> + clk_disable_unprepare(ddata->hlcdc->periph_clk);
> }
>
> static const struct of_device_id atmel_hlcdc_pwm_dt_ids[] = {
next prev parent reply other threads:[~2023-07-16 13:04 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 20:56 [PATCH 00/10] pwm: Constistenly name pwm_chip variables "chip" Uwe Kleine-König
2023-07-14 20:56 ` [PATCH 01/10] pwm: Use a consistent name for pwm_chip pointers in the core Uwe Kleine-König
2023-07-14 20:56 ` [PATCH 02/10] pwm: atmel-hlcdc: Use consistent variable naming Uwe Kleine-König
2023-07-16 13:04 ` claudiu beznea [this message]
2023-07-20 6:53 ` Thierry Reding
2023-07-20 7:29 ` Uwe Kleine-König
2023-07-21 17:58 ` Uwe Kleine-König
2023-07-21 18:26 ` Thierry Reding
2023-07-14 20:56 ` [PATCH 03/10] pwm: bcm-kona: Consistenly name pwm_chip variables "chip" Uwe Kleine-König
2023-07-14 20:56 ` [PATCH 04/10] pwm: crc: " Uwe Kleine-König
2023-07-14 20:56 ` [PATCH 05/10] pwm: cros-ec: " Uwe Kleine-König
2023-07-17 3:34 ` Tzung-Bi Shih
2023-07-14 20:56 ` [PATCH 06/10] pwm: lp3943: " Uwe Kleine-König
2023-07-14 20:56 ` [PATCH 07/10] pwm: rockchip: " Uwe Kleine-König
2023-07-14 20:56 ` [PATCH 08/10] pwm: sifive: " Uwe Kleine-König
2023-07-14 20:56 ` [PATCH 09/10] pwm: sl28cpld: " Uwe Kleine-König
2023-07-19 14:17 ` Michael Walle
2023-07-19 14:39 ` Uwe Kleine-König
2023-07-19 14:55 ` Michael Walle
2023-07-14 20:56 ` [PATCH 10/10] staging: greybus: pwm: " Uwe Kleine-König
2023-07-15 15:04 ` Alex Elder
2023-07-20 6:48 ` [PATCH 00/10] pwm: Constistenly " Thierry Reding
2023-07-20 7:10 ` Uwe Kleine-König
2023-07-20 15:03 ` Thierry Reding
2023-07-20 14:41 ` Thierry Reding
2023-09-11 4:31 ` patchwork-bot+chrome-platform
2023-09-11 4:49 ` patchwork-bot+chrome-platform
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9a0cb190-9344-dc26-b3dd-9895690e886f@tuxon.dev \
--to=claudiu.beznea@tuxon.dev \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@microchip.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pwm@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox