mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dell-laptop: Add debugfs support
@ 2010-09-14  9:48 Keng-Yu Lin
  2010-09-15 16:57 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Keng-Yu Lin @ 2010-09-14  9:48 UTC (permalink / raw)
  To: len.brown, alan-jenkins, superm1, platform-driver-x86, linux-kernel
  Cc: Keng-Yu Lin

Export the status of RF killswitch through debugfs.

Signed-off-by: Keng-Yu Lin <keng-yu.lin@canonical.com>
---
 drivers/platform/x86/dell-laptop.c |   83 ++++++++++++++++++++++++++++++++++++
 1 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 6110601..0d390b3 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -25,6 +25,8 @@
 #include <linux/mm.h>
 #include <linux/i8042.h>
 #include <linux/slab.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
 #include "../../firmware/dcdbas.h"
 
 #define BRIGHTNESS_TOKEN 0x7d
@@ -319,6 +321,77 @@ static const struct rfkill_ops dell_rfkill_ops = {
 	.query = dell_rfkill_query,
 };
 
+#ifdef CONFIG_DEBUG_FS
+static struct dentry *dell_laptop_dir;
+
+static int dell_debugfs_show(struct seq_file *s, void *data)
+{
+	int status;
+
+	get_buffer();
+	dell_send_request(buffer, 17, 11);
+	status = buffer->output[1];
+	release_buffer();
+
+	seq_printf(s, "status:\t0x%X\n", status);
+	seq_printf(s, "Hardware switch supported:   %lu\n",
+		   status & BIT(0));
+	seq_printf(s, "Wifi locator supported:      %lu\n",
+		  (status & BIT(1)) >> 1);
+	seq_printf(s, "Wifi is supported:           %lu\n",
+		  (status & BIT(2)) >> 2);
+	seq_printf(s, "Bluetooth is supported:      %lu\n",
+		  (status & BIT(3)) >> 3);
+	seq_printf(s, "WWAN is supported:           %lu\n",
+		  (status & BIT(4)) >> 4);
+	seq_printf(s, "Wireless keyboard supported: %lu\n",
+		  (status & BIT(5)) >> 5);
+	seq_printf(s, "Wifi is installed:           %lu\n",
+		  (status & BIT(8)) >> 8);
+	seq_printf(s, "Bluetooth is installed:      %lu\n",
+		  (status & BIT(9)) >> 9);
+	seq_printf(s, "WWAN is installed:           %lu\n",
+		  (status & BIT(10)) >> 10);
+	seq_printf(s, "Hardware switch is on:       %lu\n",
+		  (status & BIT(16)) >> 16);
+	seq_printf(s, "Wifi is blocked:             %lu\n",
+		  (status & BIT(17)) >> 17);
+	seq_printf(s, "Bluetooth is blocked:        %lu\n",
+		  (status & BIT(18)) >> 18);
+	seq_printf(s, "WWAN is blocked:             %lu\n",
+		  (status & BIT(19)) >> 19);
+
+	seq_printf(s, "\nhwswitch_state:\t0x%X\n", hwswitch_state);
+	seq_printf(s, "Wifi controlled by switch:      %lu\n",
+		   hwswitch_state & BIT(0));
+	seq_printf(s, "Bluetooth controlled by switch: %lu\n",
+		   hwswitch_state & BIT(0) >> 1);
+	seq_printf(s, "WWAN controlled by switch:      %lu\n",
+		   hwswitch_state & BIT(0) >> 2);
+	seq_printf(s, "Wireless switch config locked:  %lu\n",
+		   hwswitch_state & BIT(0) >> 7);
+	seq_printf(s, "Wifi locator enabled:           %lu\n",
+		   hwswitch_state & BIT(0) >> 8);
+	seq_printf(s, "Wifi locator setting locked:    %lu\n",
+		   hwswitch_state & BIT(0) >> 15);
+
+	return 0;
+}
+
+static int dell_debugfs_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, dell_debugfs_show, inode->i_private);
+}
+
+static const struct file_operations dell_debugfs_fops = {
+	.owner = THIS_MODULE,
+	.open = dell_debugfs_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+#endif
+
 static void dell_update_rfkill(struct work_struct *ignored)
 {
 	if (wifi_rfkill)
@@ -550,6 +623,13 @@ static int __init dell_init(void)
 		goto fail_filter;
 	}
 
+#ifdef CONFIG_DEBUG_FS
+	dell_laptop_dir = debugfs_create_dir("dell_laptop", NULL);
+	if (dell_laptop_dir != NULL)
+		debugfs_create_file("rfkill", 0444, dell_laptop_dir, NULL,
+				    &dell_debugfs_fops);
+#endif
+
 #ifdef CONFIG_ACPI
 	/* In the event of an ACPI backlight being available, don't
 	 * register the platform controller.
@@ -609,6 +689,9 @@ fail_platform_driver:
 
 static void __exit dell_exit(void)
 {
+#ifdef CONFIG_DEBUG_FS
+	debugfs_remove_recursive(dell_laptop_dir);
+#endif
 	i8042_remove_filter(dell_laptop_i8042_filter);
 	cancel_delayed_work_sync(&dell_rfkill_work);
 	backlight_device_unregister(dell_backlight_device);
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] dell-laptop: Add debugfs support
  2010-09-14  9:48 [PATCH] dell-laptop: Add debugfs support Keng-Yu Lin
@ 2010-09-15 16:57 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2010-09-15 16:57 UTC (permalink / raw)
  To: Keng-Yu Lin
  Cc: len.brown, alan-jenkins, superm1, platform-driver-x86, linux-kernel

Hi Keng-Yu,

On Tue, Sep 14, 2010 at 05:48:10PM +0800, Keng-Yu Lin wrote:
> Export the status of RF killswitch through debugfs.
> 

The patch description could be improved. What is the driving point in
exporting this data?

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-09-15 16:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-14  9:48 [PATCH] dell-laptop: Add debugfs support Keng-Yu Lin
2010-09-15 16:57 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®