Skip to contentSkip to conversation

clk: x86: lpss-atom: A couple of cleanups and a feature

PATCH In review Andy Shevchenko 2 participants 7 messages Feb 24 – Feb 25 Common clk

lore
Share & tools
lore
#0 lore raw

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

v1: [email protected]

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
#1 lore raw

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
index aa9d0bb98f8b..fb8637c472f2 100644
@@ -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
#3 lore raw

PATCH v2 2/3 clk: x86: lpss-atom: Use temporary variable for struct device

In reply to Andy Shevchenko

Use 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
index fb8637c472f2..57b0823d6ff2 100644
@@ -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
#5 lore raw

PATCH v2 3/3 clk: x86: lpss-atom: Read frequency from the property

In reply to 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.

---
 drivers/clk/x86/clk-lpss-atom.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/clk/x86/clk-lpss-atom.c +15 -2
index 57b0823d6ff2..597d20e492d2 100644
@@ -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