diff mbox

[2/3] devfreq: exynos4_bus: Access memory mapped I/O region via dynamic allocation.

Message ID 1402449476-6782-3-git-send-email-jonghwa3.lee@samsung.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Jonghwa Lee June 11, 2014, 1:17 a.m. UTC
Instead of using statically allocated MMIO(Memory Mapped IO) region,
it makes driver to use ioremap() to allocate the SFR region dynamically.

This patch also includes minor code clean.

WARNING: line over 80 characters
 907: FILE: drivers/devfreq/exynos/exynos4_bus.c:907:

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
---
 drivers/devfreq/exynos/exynos4_bus.c |   23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/drivers/devfreq/exynos/exynos4_bus.c b/drivers/devfreq/exynos/exynos4_bus.c
index cadad03..7c5e940 100644
--- a/drivers/devfreq/exynos/exynos4_bus.c
+++ b/drivers/devfreq/exynos/exynos4_bus.c
@@ -25,8 +25,7 @@ 
 #include <linux/regulator/consumer.h>
 #include <linux/module.h>
 #include <linux/clk.h>
-
-#include <mach/map.h>
+#include <linux/io.h>
 
 #include "exynos_ppmu.h"
 #include "exynos4_bus.h"
@@ -902,9 +901,9 @@  static int exynos4_busfreq_probe(struct platform_device *pdev)
 	struct busfreq_ppmu_data *ppmu_data;
 	struct dev_pm_opp *opp;
 	struct device *dev = &pdev->dev;
-	int err = 0;
+	int i, err = 0;
 
-	data = devm_kzalloc(&pdev->dev, sizeof(struct busfreq_data), GFP_KERNEL);
+	data = devm_kzalloc(dev, sizeof(struct busfreq_data), GFP_KERNEL);
 	if (data == NULL) {
 		dev_err(dev, "Cannot allocate memory.\n");
 		return -ENOMEM;
@@ -921,8 +920,20 @@  static int exynos4_busfreq_probe(struct platform_device *pdev)
 	}
 
 	data->type = pdev->id_entry->driver_data;
-	ppmu_data->ppmu[PPMU_DMC0].hw_base = S5P_VA_DMC0;
-	ppmu_data->ppmu[PPMU_DMC1].hw_base = S5P_VA_DMC1;
+
+	/*  Allocate MMIO region for PPMU SFRs */
+	for (i = 0; i < PPMU_END; i++) {
+		struct resource *res;
+
+		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
+		if (!res) {
+			dev_err(dev, "No mem resource for ppmu[%d]\n", i);
+			return -ENOENT;
+		}
+
+		ppmu_data->ppmu[i].hw_base = devm_ioremap_resource(dev, res);
+	}
+
 	data->pm_notifier.notifier_call = exynos4_busfreq_pm_notifier_event;
 	data->dev = dev;
 	mutex_init(&data->lock);