Skip to contentSkip to conversation

drivers/fmc: The only way to dump the SDB is from debugfs

PATCH In review Alessandro Rubini 1 participant 1 message Jul 18, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v3 3/5 drivers/fmc: The only way to dump the SDB is from debugfs

From: Federico Vaga <[email protected]>

Driver should not call fmc_sdb_dump() anymore. (actually they can but the operation is not supported, so it will print an error message)

---

V3 (Alessandro): fixed From line in patch, added alessandro's acked-by

V2 (Pat): added Tested-by and incorrect From line

V1 (Pat): picked from ohwr.org repo, where most fmc users pick from.

 drivers/fmc/Makefile      |   1 +
 drivers/fmc/fmc-core.c    |   7 +-
 drivers/fmc/fmc-debug.c   | 173 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/fmc/fmc-dump.c    |  41 -----------
 drivers/fmc/fmc-private.h |   9 +++
 drivers/fmc/fmc-sdb.c     |  99 +-------------------------
 include/linux/fmc.h       |   4 +-
 7 files changed, 195 insertions(+), 139 deletions(-)
 create mode 100644 drivers/fmc/fmc-debug.c
 create mode 100644 drivers/fmc/fmc-private.h
drivers/fmc/Makefile +1 -0
index b945291..e809322 100644
@@ -6,6 +6,7 @@ fmc-y += fmc-match.o
 fmc-y += fmc-sdb.o
 fmc-y += fru-parse.o
 fmc-y += fmc-dump.o
+fmc-y += fmc-debug.o
 
 obj-$(CONFIG_FMC_FAKEDEV) += fmc-fakedev.o
 obj-$(CONFIG_FMC_TRIVIAL) += fmc-trivial.o
drivers/fmc/fmc-core.c +6 -1
index 5263d06..ef6d8ac 100644
@@ -13,6 +13,9 @@
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/fmc.h>
+#include <linux/fmc-sdb.h>
+
+#include "fmc-private.h"
 
 static int fmc_check_version(unsigned long version, const char *name)
 {
@@ -289,7 +292,7 @@ int fmc_device_register_n(struct fmc_device **devs, int n)
 		}
 		/* This device went well, give information to the user */
 		fmc_dump_eeprom(fmc);
-		fmc_dump_sdb(fmc);
+		fmc_debug_init(fmc);
 	}
 	return 0;
 
@@ -301,6 +304,7 @@ int fmc_device_register_n(struct fmc_device **devs, int n)
 
 	kfree(devarray);
 	for (i--; i >= 0; i--) {
+		fmc_debug_exit(devs[i]);
 		sysfs_remove_bin_file(&devs[i]->dev.kobj, &fmc_eeprom_attr);
 		device_del(&devs[i]->dev);
 		fmc_free_id_info(devs[i]);
@@ -328,6 +332,7 @@ void fmc_device_unregister_n(struct fmc_device **devs, int n)
 	kfree(devs[0]->devarray);
 
 	for (i = 0; i < n; i++) {
+		fmc_debug_exit(devs[i]);
 		sysfs_remove_bin_file(&devs[i]->dev.kobj, &fmc_eeprom_attr);
 		device_del(&devs[i]->dev);
 		fmc_free_id_info(devs[i]);
drivers/fmc/fmc-debug.c new file +173 -0

173 lines not on this page · raw message

drivers/fmc/fmc-dump.c +0 -41

50 lines not on this page · raw message

drivers/fmc/fmc-private.h new file +9 -0
new file mode 100644
index 0000000..1e51366
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2015 CERN (www.cern.ch)
+ * Author: Federico Vaga <[email protected]>
+ *
+ * Released according to the GNU GPL, version 2 or any later version.
+ */
+
+extern int fmc_debug_init(struct fmc_device *fmc);
+extern void fmc_debug_exit(struct fmc_device *fmc);
drivers/fmc/fmc-sdb.c +3 -96

111 lines not on this page · raw message

include/linux/fmc.h +3 -1
index 8bb4a154..5c8df0c 100644
@@ -180,6 +180,9 @@ struct fmc_device {
 	uint32_t device_id;		/* Filled by the device */
 	char *mezzanine_name;		/* Defaults to ``fmc'' */
 	void *mezzanine_data;
+
+	struct dentry *dbg_dir;
+	struct dentry *dbg_sdb_dump;
 };
 #define to_fmc_device(x) container_of((x), struct fmc_device, dev)
 
@@ -232,7 +235,6 @@ extern int fmc_match(struct device *dev, struct device_driver *drv);
 extern int fmc_fill_id_info(struct fmc_device *fmc);
 extern void fmc_free_id_info(struct fmc_device *fmc);
 extern void fmc_dump_eeprom(const struct fmc_device *fmc);
-extern void fmc_dump_sdb(const struct fmc_device *fmc);
 
 /* helpers for FMC operations */
 extern int fmc_irq_request(struct fmc_device *fmc, irq_handler_t h,
Signature · 1 line
2.1.4