* [PATCH] pwm: vt8500: Rename variable pointing to driver private data
@ 2022-02-09 6:47 zhaoxiao
2022-02-10 7:40 ` Uwe Kleine-König
0 siblings, 1 reply; 3+ messages in thread
From: zhaoxiao @ 2022-02-09 6:47 UTC (permalink / raw)
To: thierry.reding, lee.jones
Cc: u.kleine-koenig, linux-arm-kernel, linux-pwm, linux-kernel, zhaoxiao
Status quo is that variables of type struct vt8500_chip * are named
"pwm", "chip" or "pc". The two formers are all not optimal because
usually only struct pwm_device * variables are named "pwm" and "chip" is
usually used for variabled of type struct pwm_chip *.
So consistently use the same and non-conflicting name "pc".
Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
---
drivers/pwm/pwm-vt8500.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c
index 7170a315535b..fc0a572f7d06 100644
--- a/drivers/pwm/pwm-vt8500.c
+++ b/drivers/pwm/pwm-vt8500.c
@@ -235,7 +235,7 @@ MODULE_DEVICE_TABLE(of, vt8500_pwm_dt_ids);
static int vt8500_pwm_probe(struct platform_device *pdev)
{
- struct vt8500_chip *chip;
+ struct vt8500_chip *pc;
struct device_node *np = pdev->dev.of_node;
int ret;
@@ -244,48 +244,48 @@ static int vt8500_pwm_probe(struct platform_device *pdev)
return -EINVAL;
}
- chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
- if (chip == NULL)
+ pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
+ if (pc == NULL)
return -ENOMEM;
- chip->chip.dev = &pdev->dev;
- chip->chip.ops = &vt8500_pwm_ops;
- chip->chip.npwm = VT8500_NR_PWMS;
+ pc->chip.dev = &pdev->dev;
+ pc->chip.ops = &vt8500_pwm_ops;
+ pc->chip.npwm = VT8500_NR_PWMS;
- chip->clk = devm_clk_get(&pdev->dev, NULL);
- if (IS_ERR(chip->clk)) {
+ pc->clk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(pc->clk)) {
dev_err(&pdev->dev, "clock source not specified\n");
- return PTR_ERR(chip->clk);
+ return PTR_ERR(pc->clk);
}
- chip->base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(chip->base))
- return PTR_ERR(chip->base);
+ pc->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(pc->base))
+ return PTR_ERR(pc->base);
- ret = clk_prepare(chip->clk);
+ ret = clk_prepare(pc->clk);
if (ret < 0) {
dev_err(&pdev->dev, "failed to prepare clock\n");
return ret;
}
- ret = pwmchip_add(&chip->chip);
+ ret = pwmchip_add(&pc->chip);
if (ret < 0) {
dev_err(&pdev->dev, "failed to add PWM chip\n");
- clk_unprepare(chip->clk);
+ clk_unprepare(pc->clk);
return ret;
}
- platform_set_drvdata(pdev, chip);
+ platform_set_drvdata(pdev, pc);
return ret;
}
static int vt8500_pwm_remove(struct platform_device *pdev)
{
- struct vt8500_chip *chip = platform_get_drvdata(pdev);
+ struct vt8500_chip *pc = platform_get_drvdata(pdev);
- pwmchip_remove(&chip->chip);
+ pwmchip_remove(&pc->chip);
- clk_unprepare(chip->clk);
+ clk_unprepare(pc->clk);
return 0;
}
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pwm: vt8500: Rename variable pointing to driver private data
2022-02-09 6:47 [PATCH] pwm: vt8500: Rename variable pointing to driver private data zhaoxiao
@ 2022-02-10 7:40 ` Uwe Kleine-König
[not found] ` <tencent_5115CB3B0563B582409DF902@qq.com>
0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2022-02-10 7:40 UTC (permalink / raw)
To: zhaoxiao
Cc: thierry.reding, lee.jones, linux-arm-kernel, linux-pwm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1085 bytes --]
On Wed, Feb 09, 2022 at 02:47:55PM +0800, zhaoxiao wrote:
> Status quo is that variables of type struct vt8500_chip * are named
> "pwm", "chip" or "pc". The two formers are all not optimal because
There are no variables named "pwm" or "pc".
> usually only struct pwm_device * variables are named "pwm" and "chip" is
> usually used for variabled of type struct pwm_chip *.
>
> So consistently use the same and non-conflicting name "pc".
The intention is fine, but you missed a few instances that are named
"vt8500". The statistic in mainline looks as follows:
$ git grep -o -h -E 'struct vt8500_chip \*[a-zA-Z0-9_]*' linus/master drivers/pwm/pwm-vt8500.c | sort | uniq -c
2 struct vt8500_chip *chip
5 struct vt8500_chip *vt8500
(So there 2 variabled named "chip" (that you renamed to "pc") and 5 that
are named "vt8500". I prefer to rename the "chip"s to "vt8500".
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 484 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pwm: vt8500: Rename variable pointing to driver private data
[not found] ` <tencent_5115CB3B0563B582409DF902@qq.com>
@ 2022-02-11 7:44 ` Lee Jones
0 siblings, 0 replies; 3+ messages in thread
From: Lee Jones @ 2022-02-11 7:44 UTC (permalink / raw)
To: 赵晓
Cc: Uwe Kleine-König, thierry.reding, linux-arm-kernel,
linux-pwm, linux-kernel
On Fri, 11 Feb 2022, 赵晓 wrote:
> Thanks for you suggestion. I modified the patch following your instructions and commit the v2 version.
>
Would you be kind enough to turn HTML off in your browser please.
Also, please refrain from top-posting.
Replies should be inline (like this).
> ------------------ Original ------------------
> From: "Uwe Kleine-König"<u.kleine-koenig@pengutronix.de>;
> Date: Thu, Feb 10, 2022 03:40 PM
> To: "zhaoxiao"<zhaoxiao@uniontech.com>;
> Cc: "thierry.reding"<thierry.reding@gmail.com>; "lee.jones"<lee.jones@linaro.org>; "linux-arm-kernel"<linux-arm-kernel@lists.infradead.org>; "linux-pwm"<linux-pwm@vger.kernel.org>; "linux-kernel"<linux-kernel@vger.kernel.org>;
> Subject: Re: [PATCH] pwm: vt8500: Rename variable pointing to driver private data
Please configure your mailer to strip mail headers from the body.
>
>
> On Wed, Feb 09, 2022 at 02:47:55PM +0800, zhaoxiao wrote:
> > Status quo is that variables of type struct vt8500_chip * are named
> > "pwm", "chip" or "pc". The two formers are all not optimal because
>
> There are no variables named "pwm" or "pc".
>
> > usually only struct pwm_device * variables are named "pwm" and "chip" is
> > usually used for variabled of type struct pwm_chip *.
> >
> > So consistently use the same and non-conflicting name "pc".
>
> The intention is fine, but you missed a few instances that are named
> "vt8500". The statistic in mainline looks as follows:
>
> $ git grep -o -h -E 'struct vt8500_chip \*[a-zA-Z0-9_]*' linus/master drivers/pwm/pwm-vt8500.c | sort | uniq -c
> 2 struct vt8500_chip *chip
> 5 struct vt8500_chip *vt8500
>
> (So there 2 variabled named "chip" (that you renamed to "pc") and 5 that
> are named "vt8500". I prefer to rename the "chip"s to "vt8500".
>
> Best regards
> Uwe
>
--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-11 7:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 6:47 [PATCH] pwm: vt8500: Rename variable pointing to driver private data zhaoxiao
2022-02-10 7:40 ` Uwe Kleine-König
[not found] ` <tencent_5115CB3B0563B582409DF902@qq.com>
2022-02-11 7:44 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®