public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] clk: x86: lpss-atom: A couple of cleanups
@ 2024-08-22 16:14 Andy Shevchenko
  2024-08-22 16:14 ` [PATCH v1 1/2] clk: x86: lpss-atom: Use predefined constants from units.h Andy Shevchenko
  2024-08-22 16:14 ` [PATCH v1 2/2] clk: x86: lpss-atom: Use temporary variable for struct device Andy Shevchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-08-22 16:14 UTC (permalink / raw)
  To: Andy Shevchenko, linux-clk, linux-kernel; +Cc: Michael Turquette, Stephen Boyd

A couple of cleanups for the clk-lpss-atom driver.
No functional changes intended.

Andy Shevchenko (2):
  clk: x86: lpss-atom: Use predefined constants from units.h
  clk: x86: lpss-atom: Use temporary variable for struct device

 drivers/clk/x86/clk-lpss-atom.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 1/2] clk: x86: lpss-atom: Use predefined constants from units.h
  2024-08-22 16:14 [PATCH v1 0/2] clk: x86: lpss-atom: A couple of cleanups Andy Shevchenko
@ 2024-08-22 16:14 ` Andy Shevchenko
  2024-08-28  0:21   ` Stephen Boyd
  2024-08-22 16:14 ` [PATCH v1 2/2] clk: x86: lpss-atom: Use temporary variable for struct device Andy Shevchenko
  1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2024-08-22 16:14 UTC (permalink / raw)
  To: Andy Shevchenko, linux-clk, linux-kernel; +Cc: Michael Turquette, Stephen Boyd

Use predefined constants from units.h to make code robust against typos
like how many zeros to put.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/clk/x86/clk-lpss-atom.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/x86/clk-lpss-atom.c b/drivers/clk/x86/clk-lpss-atom.c
index aa9d0bb98f8b..c70088be72d1 100644
--- a/drivers/clk/x86/clk-lpss-atom.c
+++ b/drivers/clk/x86/clk-lpss-atom.c
@@ -12,20 +12,24 @@
 #include <linux/module.h>
 #include <linux/platform_data/x86/clk-lpss.h>
 #include <linux/platform_device.h>
+#include <linux/units.h>
 
 static int lpss_atom_clk_probe(struct platform_device *pdev)
 {
 	struct lpss_clk_data *drvdata;
 	struct clk *clk;
+	u32 rate;
 
 	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
 	if (!drvdata)
 		return -ENOMEM;
 
+	/* Default frequency is 100MHz */
+	rate = 100 * HZ_PER_MHZ;
+
 	/* LPSS free running clock */
 	drvdata->name = "lpss_clk";
-	clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL,
-				      0, 100000000);
+	clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL, 0, rate);
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 2/2] clk: x86: lpss-atom: Use temporary variable for struct device
  2024-08-22 16:14 [PATCH v1 0/2] clk: x86: lpss-atom: A couple of cleanups Andy Shevchenko
  2024-08-22 16:14 ` [PATCH v1 1/2] clk: x86: lpss-atom: Use predefined constants from units.h Andy Shevchenko
@ 2024-08-22 16:14 ` Andy Shevchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-08-22 16:14 UTC (permalink / raw)
  To: Andy Shevchenko, linux-clk, linux-kernel; +Cc: Michael Turquette, Stephen Boyd

Use temporary variable for struct device to make code neater.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/clk/x86/clk-lpss-atom.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/x86/clk-lpss-atom.c b/drivers/clk/x86/clk-lpss-atom.c
index c70088be72d1..391a7d2e98e4 100644
--- a/drivers/clk/x86/clk-lpss-atom.c
+++ b/drivers/clk/x86/clk-lpss-atom.c
@@ -16,11 +16,12 @@
 
 static int lpss_atom_clk_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct lpss_clk_data *drvdata;
 	struct clk *clk;
 	u32 rate;
 
-	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
+	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
 	if (!drvdata)
 		return -ENOMEM;
 
@@ -29,7 +30,7 @@ static int lpss_atom_clk_probe(struct platform_device *pdev)
 
 	/* LPSS free running clock */
 	drvdata->name = "lpss_clk";
-	clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL, 0, rate);
+	clk = clk_register_fixed_rate(dev, drvdata->name, NULL, 0, rate);
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/2] clk: x86: lpss-atom: Use predefined constants from units.h
  2024-08-22 16:14 ` [PATCH v1 1/2] clk: x86: lpss-atom: Use predefined constants from units.h Andy Shevchenko
@ 2024-08-28  0:21   ` Stephen Boyd
  2024-08-28 13:11     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Stephen Boyd @ 2024-08-28  0:21 UTC (permalink / raw)
  To: Andy Shevchenko, linux-clk, linux-kernel; +Cc: Michael Turquette

Quoting Andy Shevchenko (2024-08-22 09:14:07)
> diff --git a/drivers/clk/x86/clk-lpss-atom.c b/drivers/clk/x86/clk-lpss-atom.c
> index aa9d0bb98f8b..c70088be72d1 100644
> --- a/drivers/clk/x86/clk-lpss-atom.c
> +++ b/drivers/clk/x86/clk-lpss-atom.c
> @@ -12,20 +12,24 @@
>  #include <linux/module.h>
>  #include <linux/platform_data/x86/clk-lpss.h>
>  #include <linux/platform_device.h>
> +#include <linux/units.h>
>  
>  static int lpss_atom_clk_probe(struct platform_device *pdev)
>  {
>         struct lpss_clk_data *drvdata;
>         struct clk *clk;
> +       u32 rate;

Do we need a local variable?

>  
>         drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
>         if (!drvdata)
>                 return -ENOMEM;
>  
> +       /* Default frequency is 100MHz */
> +       rate = 100 * HZ_PER_MHZ;
> +
>         /* LPSS free running clock */
>         drvdata->name = "lpss_clk";
> -       clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL,
> -                                     0, 100000000);
> +       clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL, 0, rate);

This should be a one line patch.

>         if (IS_ERR(clk))
>                 return PTR_ERR(clk);
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/2] clk: x86: lpss-atom: Use predefined constants from units.h
  2024-08-28  0:21   ` Stephen Boyd
@ 2024-08-28 13:11     ` Andy Shevchenko
  2024-08-28 18:38       ` Stephen Boyd
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2024-08-28 13:11 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: linux-clk, linux-kernel, Michael Turquette

On Tue, Aug 27, 2024 at 05:21:00PM -0700, Stephen Boyd wrote:
> Quoting Andy Shevchenko (2024-08-22 09:14:07)

...

> >  static int lpss_atom_clk_probe(struct platform_device *pdev)
> >  {
> >         struct lpss_clk_data *drvdata;
> >         struct clk *clk;
> > +       u32 rate;
> 
> Do we need a local variable?

Hmm... The idea was to allow retrieving this via device properties, that's why
a separate variable, but that patch wasn't included here.

Nevertheless, despite above the separate variable makes code a bit better to
read as we can see what is this value about.

> >         drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
> >         if (!drvdata)
> >                 return -ENOMEM;
> >  
> > +       /* Default frequency is 100MHz */
> > +       rate = 100 * HZ_PER_MHZ;
> > +
> >         /* LPSS free running clock */
> >         drvdata->name = "lpss_clk";
> > -       clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL,
> > -                                     0, 100000000);
> > +       clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL, 0, rate);
> 
> This should be a one line patch.

I don't get this. You mean the entire thingy?

It's possible, but as I mentioned above there is a rationale for making it with
a temporary variable.

> >         if (IS_ERR(clk))
> >                 return PTR_ERR(clk);

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/2] clk: x86: lpss-atom: Use predefined constants from units.h
  2024-08-28 13:11     ` Andy Shevchenko
@ 2024-08-28 18:38       ` Stephen Boyd
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Boyd @ 2024-08-28 18:38 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-clk, linux-kernel, Michael Turquette

Quoting Andy Shevchenko (2024-08-28 06:11:55)
> On Tue, Aug 27, 2024 at 05:21:00PM -0700, Stephen Boyd wrote:
> > Quoting Andy Shevchenko (2024-08-22 09:14:07)
> 
> ...
> 
> > >  static int lpss_atom_clk_probe(struct platform_device *pdev)
> > >  {
> > >         struct lpss_clk_data *drvdata;
> > >         struct clk *clk;
> > > +       u32 rate;
> > 
> > Do we need a local variable?
> 
> Hmm... The idea was to allow retrieving this via device properties, that's why
> a separate variable, but that patch wasn't included here.
> 
> Nevertheless, despite above the separate variable makes code a bit better to
> read as we can see what is this value about.
> 
> > >         drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
> > >         if (!drvdata)
> > >                 return -ENOMEM;
> > >  
> > > +       /* Default frequency is 100MHz */
> > > +       rate = 100 * HZ_PER_MHZ;
> > > +
> > >         /* LPSS free running clock */
> > >         drvdata->name = "lpss_clk";
> > > -       clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL,
> > > -                                     0, 100000000);
> > > +       clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL, 0, rate);
> > 
> > This should be a one line patch.
> 
> I don't get this. You mean the entire thingy?

Yes.

> 
> It's possible, but as I mentioned above there is a rationale for making it with
> a temporary variable.

The rationale looks like future code will want a local variable. When
that happens the local variable would make sense.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-28 18:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-22 16:14 [PATCH v1 0/2] clk: x86: lpss-atom: A couple of cleanups Andy Shevchenko
2024-08-22 16:14 ` [PATCH v1 1/2] clk: x86: lpss-atom: Use predefined constants from units.h Andy Shevchenko
2024-08-28  0:21   ` Stephen Boyd
2024-08-28 13:11     ` Andy Shevchenko
2024-08-28 18:38       ` Stephen Boyd
2024-08-22 16:14 ` [PATCH v1 2/2] clk: x86: lpss-atom: Use temporary variable for struct device Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox