Skip to contentSkip to conversation

memory: jz4780_nemc: Only request IO memory the driver will use

PATCH Superseded Paul Cercueil 2 participants 3 messages Jul 27, 2020 – Jul 28, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Paul Cercueil

author maintainer
#0 lore raw

PATCH 1/1 memory: jz4780_nemc: Only request IO memory the driver will use

The driver only uses the registers up to offset 0x54. Since the EFUSE registers are in the middle of the NEMC registers, we only request the registers we will use for now - that way the EFUSE driver can probe too.

---
 drivers/memory/jz4780-nemc.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/memory/jz4780-nemc.c +14 -1
index b232ed279fc3..647267ea8c63 100644
@@ -8,6 +8,7 @@
 
 #include <linux/clk.h>
 #include <linux/init.h>
+#include <linux/io.h>
 #include <linux/math64.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
@@ -288,7 +289,19 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
 	nemc->dev = dev;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	nemc->base = devm_ioremap_resource(dev, res);
+
+	/*
+	 * The driver only uses the registers up to offset 0x54. Since the EFUSE
+	 * registers are in the middle of the NEMC registers, we only request
+	 * the registers we will use for now - that way the EFUSE driver can
+	 * probe too.
+	 */
+	if (!devm_request_mem_region(dev, res->start, 0x54, dev_name(dev))) {
+		dev_err(dev, "unable to request I/O memory region\n");
+		return -EBUSY;
+	}
+
+	nemc->base = devm_ioremap(dev, res->start, resource_size(res));
 	if (IS_ERR(nemc->base)) {
 		dev_err(dev, "failed to get I/O memory\n");
 		return PTR_ERR(nemc->base);
Signature · 1 line
2.27.0
#1 lore raw
Quoted 31 lines · Paul Cercueil

The driver only uses the registers up to offset 0x54. Since the EFUSE registers are in the middle of the NEMC registers, we only request the registers we will use for now - that way the EFUSE driver can probe too.

---
 drivers/memory/jz4780-nemc.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/memory/jz4780-nemc.c +4 -1
index b232ed279fc3..647267ea8c63 100644
@@ -8,6 +8,7 @@
 
 #include <linux/clk.h>
 #include <linux/init.h>
+#include <linux/io.h>
 #include <linux/math64.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
@@ -288,7 +289,19 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
 	nemc->dev = dev;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	nemc->base = devm_ioremap_resource(dev, res);
+
+	/*
+	 * The driver only uses the registers up to offset 0x54. Since the EFUSE

drivers/memory/jz4780-nemc.c static int jz4780_nemc_probe(struct platform_device *pdev) · line 304

Quoted 10 lines
drivers/memory/jz4780-nemc.c +10 -0
+	 * registers are in the middle of the NEMC registers, we only request
+	 * the registers we will use for now - that way the EFUSE driver can
+	 * probe too.
+	 */
+	if (!devm_request_mem_region(dev, res->start, 0x54, dev_name(dev))) {
+		dev_err(dev, "unable to request I/O memory region\n");
+		return -EBUSY;
+	}
+
+	nemc->base = devm_ioremap(dev, res->start, resource_size(res));

Shouldn't you map only 0x54 size as well?

Best regards,
Krzysztof

author maintainer
#2 lore raw
Quoted 50 lines · Krzysztof Kozlowski
Quoted 40 lines · Paul Cercueil

The driver only uses the registers up to offset 0x54. Since the
EFUSE
registers are in the middle of the NEMC registers, we only request the registers we will use for now - that way the EFUSE driver can probe too.

---

  drivers/memory/jz4780-nemc.c | 15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/jz4780-nemc.c
b/drivers/memory/jz4780-nemc.c
index b232ed279fc3..647267ea8c63 100644
--- a/drivers/memory/jz4780-nemc.c
+++ b/drivers/memory/jz4780-nemc.c
@@ -8,6 +8,7 @@

#include <linux/clk.h>
#include <linux/init.h>
+#include <linux/io.h>
#include <linux/math64.h>
#include <linux/of.h>
#include <linux/of_address.h>
@@ -288,7 +289,19 @@ static int jz4780_nemc_probe(struct
platform_device *pdev)
nemc->dev = dev;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- nemc->base = devm_ioremap_resource(dev, res);
+
+ /*
+ * The driver only uses the registers up to offset 0x54. Since
the EFUSE
+ * registers are in the middle of the NEMC registers, we only
request
+ * the registers we will use for now - that way the EFUSE driver
can
+ * probe too.

Quoted 8 lines

+ */
+ if (!devm_request_mem_region(dev, res->start, 0x54,
dev_name(dev))) {
+ dev_err(dev, "unable to request I/O memory region\n");
+ return -EBUSY;
+ }
+
+ nemc->base = devm_ioremap(dev, res->start, resource_size(res));

Quoted 1 line

Shouldn't you map only 0x54 size as well?

I can do that.

Cheers,
-Paul