clk: x86: lpss-atom: A couple of cleanups and a feature
v2 cover clk: x86: lpss-atom: A couple of cleanups and a feature
A couple of cleanups for the clk-lpss-atom driver. No functional changes intended.
On top of them, one feature is added.
Changelog v2:
- reshuffled code to add variables when it's needed (Stephen)
- added third patch
Andy Shevchenko (3):
clk: x86: lpss-atom: Use predefined constants from units.h
clk: x86: lpss-atom: Use temporary variable for struct device
clk: x86: lpss-atom: Read frequency from the property
drivers/clk/x86/clk-lpss-atom.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
Signature · 1 line
2.50.1
PATCH v2 1/3 clk: x86: lpss-atom: Use predefined constants from units.h
Use predefined constants from units.h to make code robust against typos like how many zeros to put.
--- drivers/clk/x86/clk-lpss-atom.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/x86/clk-lpss-atom.c +2 -1
@@ -12,6 +12,7 @@#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) {
@@ -25,7 +26,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 ,100000000 ); +0 ,100 *HZ_PER_MHZ );if (IS_ERR (clk))return PTR_ERR (clk);
Signature · 1 line
2.50.1
Re: [PATCH v2 1/3] clk: x86: lpss-atom: Use predefined constants from units.h
Quoted 4 lines · Andy Shevchenko
Use predefined constants from
units.hto make code robust against typos like how many zeros to put.Signed-off-by Andy Shevchenko <[email protected]>
PATCH v2 2/3 clk: x86: lpss-atom: Use temporary variable for struct device
In reply to Andy ShevchenkoUse temporary variable for struct device to make code neater.
--- drivers/clk/x86/clk-lpss-atom.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/x86/clk-lpss-atom.c +3 -3
@@ -16,17 +16,17 @@static int lpss_atom_clk_probe (struct platform_device *pdev) { +struct device *dev = &pdev->dev;struct lpss_clk_data *drvdata;struct clk *clk; - drvdata =devm_kzalloc (&pdev->dev,sizeof (*drvdata),GFP_KERNEL ); + drvdata =devm_kzalloc (dev,sizeof (*drvdata),GFP_KERNEL );if (!drvdata)return -ENOMEM ;/* LPSS free running clock */ drvdata->name ="lpss_clk" ; - clk =clk_register_fixed_rate (&pdev->dev, drvdata->name,NULL , -0 ,100 *HZ_PER_MHZ ); + clk =clk_register_fixed_rate (dev, drvdata->name,NULL ,0 ,100 *HZ_PER_MHZ );if (IS_ERR (clk))return PTR_ERR (clk);
Signature · 1 line
2.50.1
Re: [PATCH v2 2/3] clk: x86: lpss-atom: Use temporary variable for struct device
Quoted 3 lines · Andy Shevchenko
Use temporary variable for struct device to make code neater.
Signed-off-by Andy Shevchenko <[email protected]>
PATCH v2 3/3 clk: x86: lpss-atom: Read frequency from the property
In reply to Andy ShevchenkoOn the future platforms we might need to have different frequency of the free running clock. Allow that to be modified via supplied device property.
--- drivers/clk/x86/clk-lpss-atom.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/clk/x86/clk-lpss-atom.c +15 -2
@@ -10,23 +10,36 @@#include <linux/clk-provider.h> #include <linux/err.h> #include <linux/module.h> -#include <linux/platform_data/x86/clk-lpss.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/units.h> +#include <linux/platform_data/x86/clk-lpss.h> +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; +int ret; drvdata =devm_kzalloc (dev,sizeof (*drvdata),GFP_KERNEL );if (!drvdata)return -ENOMEM ; +if (device_property_present (dev,"clock-frequency" )) { + ret =device_property_read_u32 (dev,"clock-frequency" , &rate); +if (ret) +return ret; + }else { +/* Default frequency is 100MHz */ + rate =100 *HZ_PER_MHZ ; + } +/* LPSS free running clock */ drvdata->name ="lpss_clk" ; - clk =clk_register_fixed_rate (dev, drvdata->name,NULL ,0 ,100 *HZ_PER_MHZ ); + clk =clk_register_fixed_rate (dev, drvdata->name,NULL ,0 , rate);if (IS_ERR (clk))return PTR_ERR (clk);
Signature · 1 line
2.50.1
Re: [PATCH v2 3/3] clk: x86: lpss-atom: Read frequency from the property
Quoted 5 lines · Andy Shevchenko
On the future platforms we might need to have different frequency of the free running clock. Allow that to be modified via supplied device property.
Signed-off-by Andy Shevchenko <[email protected]>