lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 26 Jun 2008 13:09:48 +0200
From:	Haavard Skinnemoen <haavard.skinnemoen@...el.com>
To:	Pierre Ossman <drzeus-mmc@...eus.cx>
Cc:	linux-kernel@...r.kernel.org,
	Haavard Skinnemoen <hskinnemoen@...el.com>
Subject: [PATCH 2/3] mmc: Export ios settings for a host through debugfs

From: Haavard Skinnemoen <hskinnemoen@...el.com>

Export all the fields in struct mmc_ios under /sys/kernel/debug/<host>/ios

Signed-off-by: Haavard Skinnemoen <hskinnemoen@...el.com>
---
 drivers/mmc/core/host.c  |   55 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mmc/host.h |   13 +++++++++++
 2 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 93da502..2977f26 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -25,6 +25,54 @@
 #ifdef CONFIG_MMC_DEBUG_FS
 #include <linux/debugfs.h>
 
+static void mmc_remove_ios_debugfs(struct mmc_ios *ios)
+{
+	if (ios->dbg_root) {
+		debugfs_remove(ios->dbg_clock);
+		debugfs_remove(ios->dbg_vdd);
+		debugfs_remove(ios->dbg_bus_mode);
+		debugfs_remove(ios->dbg_chip_select);
+		debugfs_remove(ios->dbg_power_mode);
+		debugfs_remove(ios->dbg_bus_width);
+		debugfs_remove(ios->dbg_timing);
+		debugfs_remove(ios->dbg_root);
+		ios->dbg_root = NULL;
+	}
+}
+
+static int mmc_add_ios_debugfs(struct mmc_ios *ios, struct dentry *parent)
+{
+	struct dentry *dir;
+
+	dir = debugfs_create_dir("ios", parent);
+	if (!dir)
+		return -EBUSY;	/* or whatever */
+	ios->dbg_root = dir;
+
+	ios->dbg_clock = debugfs_create_u32("clock", 0400, dir, &ios->clock);
+	ios->dbg_vdd = debugfs_create_u16("vdd", 0400, dir, &ios->vdd);
+	ios->dbg_bus_mode = debugfs_create_u8("bus_mode", 0400, dir,
+					      &ios->bus_mode);
+	ios->dbg_chip_select = debugfs_create_u8("chip_select", 0400, dir,
+						 &ios->chip_select);
+	ios->dbg_power_mode = debugfs_create_u8("power_mode", 0400, dir,
+						&ios->power_mode);
+	ios->dbg_bus_width = debugfs_create_u8("bus_width", 0400, dir,
+					       &ios->bus_width);
+	ios->dbg_timing = debugfs_create_u8("timing", 0400, dir, &ios->timing);
+
+	if (!ios->dbg_clock || !ios->dbg_vdd || !ios->dbg_bus_mode
+			|| !ios->dbg_chip_select || !ios->dbg_power_mode
+			|| !ios->dbg_bus_width || !ios->dbg_timing)
+		goto err;
+
+	return 0;
+
+err:
+	mmc_remove_ios_debugfs(ios);
+	return -EBUSY;
+}
+
 static void mmc_add_host_debugfs(struct mmc_host *host)
 {
 	struct dentry *root;
@@ -34,14 +82,21 @@ static void mmc_add_host_debugfs(struct mmc_host *host)
 		goto err_root;
 	host->debugfs_root = root;
 
+	if (mmc_add_ios_debugfs(&host->ios, root))
+		goto err_ios;
+
 	return;
 
+err_ios:
+	debugfs_remove(root);
+	host->debugfs_root = NULL;
 err_root:
 	dev_err(&host->class_dev, "failed to initialize debugfs\n");
 }
 
 static void mmc_remove_host_debugfs(struct mmc_host *host)
 {
+	mmc_remove_ios_debugfs(&host->ios);
 	debugfs_remove(host->debugfs_root);
 }
 
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 31002e7..1ba2723 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -47,6 +47,17 @@ struct mmc_ios {
 #define MMC_TIMING_LEGACY	0
 #define MMC_TIMING_MMC_HS	1
 #define MMC_TIMING_SD_HS	2
+
+#ifdef CONFIG_MMC_DEBUG_FS
+	struct dentry		*dbg_root;
+	struct dentry		*dbg_clock;
+	struct dentry		*dbg_vdd;
+	struct dentry		*dbg_bus_mode;
+	struct dentry		*dbg_chip_select;
+	struct dentry		*dbg_power_mode;
+	struct dentry		*dbg_bus_width;
+	struct dentry		*dbg_timing;
+#endif
 };
 
 struct mmc_host_ops {
@@ -136,6 +147,8 @@ struct mmc_host {
 #endif
 #ifdef CONFIG_MMC_DEBUG_FS
 	struct dentry		*debugfs_root;
+	struct dentry		*debugfs_ios;
+	struct dentry		*debugfs_ios_clock;
 #endif
 
 	unsigned long		private[0] ____cacheline_aligned;
-- 
1.5.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ