Skip to contentSkip to conversation

staging: media: imx7-mipi-csis: fix debugfs compilation

PATCH In review Arnd Bergmann 2 participants 2 messages Mar 13, 2019 – Mar 14, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: media: imx7-mipi-csis: fix debugfs compilation

When CONFIG_DEBUGFS is enabled, we get a warning about an incorrect section annotation that can lead to undefined behavior:

WARNING: vmlinux.o(.text+0xd3c7c4): Section mismatch in reference from the function mipi_csis_probe() to the function .init.text:mipi_csis_debugfs_init() The function mipi_csis_probe() references
the function __init mipi_csis_debugfs_init().
This is often because mipi_csis_probe lacks a __init
annotation or the annotation of mipi_csis_debugfs_init is wrong.

The same function for an unknown reason has a different version for !CONFIG_DEBUGFS, which does not have this problem, but behaves the same way otherwise (it does nothing when debugfs is disabled).
Consolidate the two versions, using the correct section from one version, and the implementation from the other.

---
 drivers/staging/media/imx/imx7-mipi-csis.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/staging/media/imx/imx7-mipi-csis.c +2 -14
index 2ddcc42ab8ff..001ce369ec45 100644
@@ -9,6 +9,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/interrupt.h>
@@ -889,8 +890,6 @@ static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd,
 	return ret;
 }
 
-#ifdef CONFIG_DEBUG_FS
-#include <linux/debugfs.h>
 
 static int mipi_csis_dump_regs_show(struct seq_file *m, void *private)
 {
@@ -900,7 +899,7 @@ static int mipi_csis_dump_regs_show(struct seq_file *m, void *private)
 }
 DEFINE_SHOW_ATTRIBUTE(mipi_csis_dump_regs);
 
-static int __init_or_module mipi_csis_debugfs_init(struct csi_state *state)
+static int mipi_csis_debugfs_init(struct csi_state *state)
 {
 	struct dentry *d;
 
@@ -934,17 +933,6 @@ static void mipi_csis_debugfs_exit(struct csi_state *state)
 	debugfs_remove_recursive(state->debugfs_root);
 }
 
-#else
-static int mipi_csis_debugfs_init(struct csi_state *state __maybe_unused)
-{
-	return 0;
-}
-
-static void mipi_csis_debugfs_exit(struct csi_state *state __maybe_unused)
-{
-}
-#endif
-
 static int mipi_csis_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
Signature · 1 line
2.20.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Arnd,
Thanks for the patch.

Quoted 10 lines · Arnd Bergmann

When CONFIG_DEBUGFS is enabled, we get a warning about an incorrect section annotation that can lead to undefined behavior:

WARNING: vmlinux.o(.text+0xd3c7c4): Section mismatch in reference from the function mipi_csis_probe() to the function .init.text:mipi_csis_debugfs_init() The function mipi_csis_probe() references
the function __init mipi_csis_debugfs_init().
This is often because mipi_csis_probe lacks a __init
annotation or the annotation of mipi_csis_debugfs_init is wrong.

Quoted 8 lines

The same function for an unknown reason has a different version for !CONFIG_DEBUGFS, which does not have this problem, but behaves the same way otherwise (it does nothing when debugfs is disabled).
Consolidate the two versions, using the correct section from one version, and the implementation from the other.

---
Cheers,
Rui

Quoted 60 lines
---
 drivers/staging/media/imx/imx7-mipi-csis.c | 16 
 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/staging/media/imx/imx7-mipi-csis.c +1 -2
index 2ddcc42ab8ff..001ce369ec45 100644
@@ -9,6 +9,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/interrupt.h>
@@ -889,8 +890,6 @@ static int mipi_csis_subdev_init(struct 
 v4l2_subdev *mipi_sd,
 	return ret;
 }
 
-#ifdef CONFIG_DEBUG_FS
-#include <linux/debugfs.h>
 
 static int mipi_csis_dump_regs_show(struct seq_file *m, void 

*private)
{

drivers/staging/media/imx/imx7-mipi-csis.c +1 -1
@@ -900,7 +899,7 @@ static int mipi_csis_dump_regs_show(struct 
 seq_file *m, void *private)
 }
 DEFINE_SHOW_ATTRIBUTE(mipi_csis_dump_regs);
 
-static int __init_or_module mipi_csis_debugfs_init(struct 
 csi_state *state)
+static int mipi_csis_debugfs_init(struct csi_state *state)
 {
drivers/staging/media/imx/imx7-mipi-csis.c +0 -11
 	struct dentry *d;
@@ -934,17 +933,6 @@ static void mipi_csis_debugfs_exit(struct 
 csi_state *state)
 	debugfs_remove_recursive(state->debugfs_root);
 }
 
-#else
-static int mipi_csis_debugfs_init(struct csi_state *state 
 __maybe_unused)
-{
-	return 0;
-}
-
-static void mipi_csis_debugfs_exit(struct csi_state *state 
 __maybe_unused)
-{
-}
-#endif
-

static int mipi_csis_probe(struct platform_device *pdev) {
struct device *dev = &pdev->dev;