Skip to contentSkip to conversation

memory: omap-gpmc: Fix build error without CONFIG_OF

PATCH Superseded YueHaibing 3 participants 8 messages Aug 18, 2020 – Aug 27, 2020

Subsystems (2)
lore
Share & tools
lore

YueHaibing

author
#0 lore raw

PATCH 1/1 memory: omap-gpmc: Fix build error without CONFIG_OF

If CONFIG_OF is n, gcc fails:

drivers/memory/omap-gpmc.o: In function `gpmc_omap_onenand_set_timings':
omap-gpmc.c:(.text+0x2a88): undefined reference to `gpmc_read_settings_dt'

Add helper function to fix this.

Fixes a758f50f10cf ("mtd: onenand: omap2: Configure driver from DT")
---
 drivers/memory/omap-gpmc.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/memory/omap-gpmc.c +9 -0
index ce0e7e2d7cff..332bb4580817 100644
@@ -1176,6 +1176,7 @@ struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *reg, int cs)
 }
 EXPORT_SYMBOL_GPL(gpmc_omap_get_nand_ops);
 
+#ifdef CONFIG_OF
 static void gpmc_omap_onenand_calc_sync_timings(struct gpmc_timings *t,
 						struct gpmc_settings *s,
 						int freq, int latency)
@@ -1280,6 +1281,14 @@ int gpmc_omap_onenand_set_timings(struct device *dev, int cs, int freq,
 
 	return gpmc_cs_set_timings(cs, &gpmc_t, &gpmc_s);
 }
+#else
+int gpmc_omap_onenand_set_timings(struct device *dev, int cs, int freq,
+				  int latency,
+				  struct gpmc_onenand_info *info)
+{
+	return -EINVAL;
+}
+#endif
 EXPORT_SYMBOL_GPL(gpmc_omap_onenand_set_timings);
 
 int gpmc_get_client_irq(unsigned int irq_config)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 18 lines · YueHaibing

If CONFIG_OF is n, gcc fails:

drivers/memory/omap-gpmc.o: In function `gpmc_omap_onenand_set_timings':
omap-gpmc.c:(.text+0x2a88): undefined reference to `gpmc_read_settings_dt'

Add helper function to fix this.

Fixes a758f50f10cf ("mtd: onenand: omap2: Configure driver from DT")
---
 drivers/memory/omap-gpmc.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/memory/omap-gpmc.c +0 -0
index ce0e7e2d7cff..332bb4580817 100644

drivers/memory/omap-gpmc.c struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *reg, int cs) · line 1179

Quoted 4 lines
drivers/memory/omap-gpmc.c +1 -0
@@ -1176,6 +1176,7 @@ struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *reg, int cs)
 }
 EXPORT_SYMBOL_GPL(gpmc_omap_get_nand_ops);
 
+#ifdef CONFIG_OF

Hi,

Instead add empty stub for gpmc_read_settings_dt() in existing #ifdef section - around line 2314. Less ifdefs and actually seems to me appropriate place to group !OF stubs.

Best regards,
Krzysztof

author
#2 lore raw

PATCH v2 1/1 memory: omap-gpmc: Fix build error without CONFIG_OF

In reply to YueHaibing

If CONFIG_OF is n, gcc fails:

drivers/memory/omap-gpmc.o: In function `gpmc_omap_onenand_set_timings':
omap-gpmc.c:(.text+0x2a88): undefined reference to `gpmc_read_settings_dt'

Add gpmc_read_settings_dt() helper function to fix this.

Fixes a758f50f10cf ("mtd: onenand: omap2: Configure driver from DT")

---
v2: add gpmc_read_settings_dt() stub

---
 drivers/memory/omap-gpmc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/memory/omap-gpmc.c +3 -0
index cd9e80748591..02c0c694ecaf 100644
@@ -2310,6 +2310,9 @@ static void gpmc_probe_dt_children(struct platform_device *pdev)
 	}
 }
 #else
+void gpmc_read_settings_dt(struct device_node *np, struct gpmc_settings *p)
+{
+}
 static int gpmc_probe_dt(struct platform_device *pdev)
 {
 	return 0;
Signature · 1 line
2.17.1
#3 lore raw

Hi,

Quoted 20 lines · YueHaibing

If CONFIG_OF is n, gcc fails:

drivers/memory/omap-gpmc.o: In function `gpmc_omap_onenand_set_timings':
omap-gpmc.c:(.text+0x2a88): undefined reference to `gpmc_read_settings_dt'

Add gpmc_read_settings_dt() helper function to fix this.

Fixes a758f50f10cf ("mtd: onenand: omap2: Configure driver from DT")

---
v2: add gpmc_read_settings_dt() stub

---
  drivers/memory/omap-gpmc.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/memory/omap-gpmc.c +0 -0
index cd9e80748591..02c0c694ecaf 100644

drivers/memory/omap-gpmc.c static void gpmc_probe_dt_children(struct platform_device *pdev) · line 2314

Quoted 5 lines
drivers/memory/omap-gpmc.c +2 -0
@@ -2310,6 +2310,9 @@ static void gpmc_probe_dt_children(struct platform_device *pdev)
  	}
  }
  #else
+void gpmc_read_settings_dt(struct device_node *np, struct gpmc_settings *p)
+{

I will suggest to set gpmc_settings data structure to zero here so that the caller doesn't proceed with random/invalid settings.

drivers/memory/omap-gpmc.c static void gpmc_probe_dt_children(struct platform_device *pdev) · line 2318

Quoted 5 lines
drivers/memory/omap-gpmc.c +1 -0
+}
  static int gpmc_probe_dt(struct platform_device *pdev)
  {
  	return 0;

cheers,
-roger

Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
author
#4 lore raw

PATCH v3 1/1 memory: omap-gpmc: Fix build error without CONFIG_OF

In reply to YueHaibing

If CONFIG_OF is n, gcc fails:

drivers/memory/omap-gpmc.o: In function `gpmc_omap_onenand_set_timings':
omap-gpmc.c:(.text+0x2a88): undefined reference to `gpmc_read_settings_dt'

Add gpmc_read_settings_dt() helper function, which zero the gpmc_settings so the caller doesn't proceed with random/invalid settings.

Fixes a758f50f10cf ("mtd: onenand: omap2: Configure driver from DT")

---
v3: zero gpmc_settings
v2: add gpmc_read_settings_dt() stub

---
 drivers/memory/omap-gpmc.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/memory/omap-gpmc.c +4 -0
index cd9e80748591..e026b4cd3612 100644
@@ -2310,6 +2310,10 @@ static void gpmc_probe_dt_children(struct platform_device *pdev)
 	}
 }
 #else
+void gpmc_read_settings_dt(struct device_node *np, struct gpmc_settings *p)
+{
+	memset(p, 0, sizeof(struct gpmc_settings));
+}
 static int gpmc_probe_dt(struct platform_device *pdev)
 {
 	return 0;
Signature · 1 line
2.17.1
#5 lore raw
Quoted 22 lines · YueHaibing

If CONFIG_OF is n, gcc fails:

drivers/memory/omap-gpmc.o: In function `gpmc_omap_onenand_set_timings':
omap-gpmc.c:(.text+0x2a88): undefined reference to `gpmc_read_settings_dt'

Add gpmc_read_settings_dt() helper function, which zero the gpmc_settings so the caller doesn't proceed with random/invalid settings.

Fixes a758f50f10cf ("mtd: onenand: omap2: Configure driver from DT")

---
v3: zero gpmc_settings
v2: add gpmc_read_settings_dt() stub

---
 drivers/memory/omap-gpmc.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/memory/omap-gpmc.c +0 -0
index cd9e80748591..e026b4cd3612 100644

drivers/memory/omap-gpmc.c static void gpmc_probe_dt_children(struct platform_device *pdev) · line 2315

Quoted 6 lines
drivers/memory/omap-gpmc.c +3 -0
@@ -2310,6 +2310,10 @@ static void gpmc_probe_dt_children(struct platform_device *pdev)
 	}
 }
 #else
+void gpmc_read_settings_dt(struct device_node *np, struct gpmc_settings *p)
+{
+	memset(p, 0, sizeof(struct gpmc_settings));

sizeof(*p) but if patch is otherwise ok (got review/ack) then I can fix it while applying.

If there is resend, please fix it as well.

Best regards,
Krzysztof

Acked-by
#6 lore raw
Quoted 33 lines · Krzysztof Kozlowski
Quoted 22 lines · YueHaibing

If CONFIG_OF is n, gcc fails:

drivers/memory/omap-gpmc.o: In function `gpmc_omap_onenand_set_timings':
omap-gpmc.c:(.text+0x2a88): undefined reference to `gpmc_read_settings_dt'

Add gpmc_read_settings_dt() helper function, which zero the gpmc_settings so the caller doesn't proceed with random/invalid settings.

Fixes a758f50f10cf ("mtd: onenand: omap2: Configure driver from DT")

---
v3: zero gpmc_settings
v2: add gpmc_read_settings_dt() stub

---
  drivers/memory/omap-gpmc.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/memory/omap-gpmc.c +0 -0
index cd9e80748591..e026b4cd3612 100644

drivers/memory/omap-gpmc.c static void gpmc_probe_dt_children(struct platform_device *pdev) · line 2315

Quoted 6 lines
drivers/memory/omap-gpmc.c +3 -0
@@ -2310,6 +2310,10 @@ static void gpmc_probe_dt_children(struct platform_device *pdev)
  	}
  }
  #else
+void gpmc_read_settings_dt(struct device_node *np, struct gpmc_settings *p)
+{
+	memset(p, 0, sizeof(struct gpmc_settings));

sizeof(*p) but if patch is otherwise ok (got review/ack) then I can fix it while applying.

Quoted 1 line

If there is resend, please fix it as well.

With the sizeof(*p) change.

cheers,
-roger

Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
maintainer Applied
#7 lore raw
Quoted 36 lines · Roger Quadros
Quoted 33 lines · Krzysztof Kozlowski
Quoted 22 lines · YueHaibing

If CONFIG_OF is n, gcc fails:

drivers/memory/omap-gpmc.o: In function `gpmc_omap_onenand_set_timings':
omap-gpmc.c:(.text+0x2a88): undefined reference to `gpmc_read_settings_dt'

Add gpmc_read_settings_dt() helper function, which zero the gpmc_settings so the caller doesn't proceed with random/invalid settings.

Fixes a758f50f10cf ("mtd: onenand: omap2: Configure driver from DT")

---
v3: zero gpmc_settings
v2: add gpmc_read_settings_dt() stub

---
  drivers/memory/omap-gpmc.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/memory/omap-gpmc.c +0 -0
index cd9e80748591..e026b4cd3612 100644

drivers/memory/omap-gpmc.c static void gpmc_probe_dt_children(struct platform_device *pdev) · line 2315

Quoted 6 lines
drivers/memory/omap-gpmc.c +3 -0
@@ -2310,6 +2310,10 @@ static void gpmc_probe_dt_children(struct platform_device *pdev)
  	}
  }
  #else
+void gpmc_read_settings_dt(struct device_node *np, struct gpmc_settings *p)
+{
+	memset(p, 0, sizeof(struct gpmc_settings));

sizeof(*p) but if patch is otherwise ok (got review/ack) then I can fix it while applying.

Quoted 5 lines
Quoted 1 line

If there is resend, please fix it as well.

With the sizeof(*p) change.

Thanks, applied.

Best regards,
Krzysztof