All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] dell-laptop: Add debugfs support
       [not found] <AANLkTime84o+hJWVDegQWHxcvUiftKW-2psW5tv4a-yR@mail.gmail.com>
@ 2010-09-16  3:19 ` Keng-Yu Lin
  2010-09-16 16:46   ` Len Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Keng-Yu Lin @ 2010-09-16  3:19 UTC (permalink / raw)
  To: mjg59, len.brown, alan-jenkins, superm1, platform-driver-x86,
	linux-kernel
  Cc: Keng-Yu Lin

Export the status of RF killswitch through debugfs.

The killswitch status is obtained by the SMI to BIOS. Exporting this status
through debugfs can help identify the issue with the misbehaving firmware.

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 4413975..1536dd5 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
@@ -325,6 +327,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)
@@ -556,6 +629,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.
@@ -615,6 +695,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.1


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

* Re: [PATCH v2] dell-laptop: Add debugfs support
  2010-09-16  3:19 ` [PATCH v2] dell-laptop: Add debugfs support Keng-Yu Lin
@ 2010-09-16 16:46   ` Len Brown
  2010-09-17  5:47     ` Keng-Yü Lin
  2010-09-17  5:47     ` [PATCH v3] " Keng-Yu Lin
  0 siblings, 2 replies; 9+ messages in thread
From: Len Brown @ 2010-09-16 16:46 UTC (permalink / raw)
  To: Keng-Yu Lin
  Cc: mjg59, len.brown, alan-jenkins, superm1, platform-driver-x86,
	linux-kernel


> +#ifdef CONFIG_DEBUG_FS

Looks like you can delete these.

Of course you'd want to properly check the return value
from debugfs_create_dir(), which returns an ERR_PTR
when CONFIG_DEBUG_FS is not defined. (even though
few in the kernel seem to be bothering to use IS_ERR() here.)

cheers,
Len Brown, Intel Open Source Technology Center

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

* Re: [PATCH v2] dell-laptop: Add debugfs support
  2010-09-16 16:46   ` Len Brown
@ 2010-09-17  5:47     ` Keng-Yü Lin
  2010-09-17  5:47     ` [PATCH v3] " Keng-Yu Lin
  1 sibling, 0 replies; 9+ messages in thread
From: Keng-Yü Lin @ 2010-09-17  5:47 UTC (permalink / raw)
  To: Len Brown
  Cc: mjg59, len.brown, alan-jenkins, superm1, platform-driver-x86,
	linux-kernel

On Fri, Sep 17, 2010 at 12:46 AM, Len Brown <lenb@kernel.org> wrote:
>
>> +#ifdef CONFIG_DEBUG_FS
>
> Looks like you can delete these.
>
> Of course you'd want to properly check the return value
> from debugfs_create_dir(), which returns an ERR_PTR
> when CONFIG_DEBUG_FS is not defined. (even though
> few in the kernel seem to be bothering to use IS_ERR() here.)
>
> cheers,
> Len Brown, Intel Open Source Technology Center
>

Hi Len:
  If CONFIG_DEBUG_FS is not defined, all debugfs_create_dir(),
debugfs_create_file() and debugfs_remove_recursive() here will just
return -ENODEV. I think in this case, it causes little harm just to
skip checking the return value with IS_ERR() since no follow-up action
for that.

  Regards,
-kengyu

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

* [PATCH v3] dell-laptop: Add debugfs support
  2010-09-16 16:46   ` Len Brown
  2010-09-17  5:47     ` Keng-Yü Lin
@ 2010-09-17  5:47     ` Keng-Yu Lin
  2010-09-24 10:48       ` [PATCH v4] " Keng-Yu Lin
  1 sibling, 1 reply; 9+ messages in thread
From: Keng-Yu Lin @ 2010-09-17  5:47 UTC (permalink / raw)
  To: mjg59, len.brown, alan-jenkins, superm1, platform-driver-x86,
	linux-kernel
  Cc: Keng-Yu Lin

Export the status of RF killswitch through debugfs.

The killswitch status is obtained by the SMI to BIOS. Exporting this status
through debugfs can help identify the issue with the misbehaving firmware.

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

diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 4413975..bf5fbae 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
@@ -325,6 +327,75 @@ static const struct rfkill_ops dell_rfkill_ops = {
 	.query = dell_rfkill_query,
 };
 
+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,
+};
+
 static void dell_update_rfkill(struct work_struct *ignored)
 {
 	if (wifi_rfkill)
@@ -556,6 +627,11 @@ static int __init dell_init(void)
 		goto fail_filter;
 	}
 
+	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);
+
 #ifdef CONFIG_ACPI
 	/* In the event of an ACPI backlight being available, don't
 	 * register the platform controller.
@@ -615,6 +691,7 @@ fail_platform_driver:
 
 static void __exit dell_exit(void)
 {
+	debugfs_remove_recursive(dell_laptop_dir);
 	i8042_remove_filter(dell_laptop_i8042_filter);
 	cancel_delayed_work_sync(&dell_rfkill_work);
 	backlight_device_unregister(dell_backlight_device);
-- 
1.7.1


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

* [PATCH v4] dell-laptop: Add debugfs support
  2010-09-17  5:47     ` [PATCH v3] " Keng-Yu Lin
@ 2010-09-24 10:48       ` Keng-Yu Lin
  2010-09-27 14:00         ` Matthew Garrett
  0 siblings, 1 reply; 9+ messages in thread
From: Keng-Yu Lin @ 2010-09-24 10:48 UTC (permalink / raw)
  To: mjg59, len.brown, alan-jenkins, superm1, platform-driver-x86,
	linux-kernel
  Cc: Keng-Yu Lin

Export the status of RF killswitch through debugfs.

The killswitch status is obtained by the SMI to BIOS. Exporting this status
through debugfs can help identify the issue with the misbehaving firmware.

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

diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 4413975..a943da5 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
@@ -325,6 +327,75 @@ static const struct rfkill_ops dell_rfkill_ops = {
 	.query = dell_rfkill_query,
 };
 
+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(1) >> 1);
+	seq_printf(s, "WWAN controlled by switch:      %lu\n",
+		   hwswitch_state & BIT(2) >> 2);
+	seq_printf(s, "Wireless switch config locked:  %lu\n",
+		   hwswitch_state & BIT(7) >> 7);
+	seq_printf(s, "Wifi locator enabled:           %lu\n",
+		   hwswitch_state & BIT(8) >> 8);
+	seq_printf(s, "Wifi locator setting locked:    %lu\n",
+		   hwswitch_state & BIT(15) >> 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,
+};
+
 static void dell_update_rfkill(struct work_struct *ignored)
 {
 	if (wifi_rfkill)
@@ -556,6 +627,11 @@ static int __init dell_init(void)
 		goto fail_filter;
 	}
 
+	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);
+
 #ifdef CONFIG_ACPI
 	/* In the event of an ACPI backlight being available, don't
 	 * register the platform controller.
@@ -615,6 +691,7 @@ fail_platform_driver:
 
 static void __exit dell_exit(void)
 {
+	debugfs_remove_recursive(dell_laptop_dir);
 	i8042_remove_filter(dell_laptop_i8042_filter);
 	cancel_delayed_work_sync(&dell_rfkill_work);
 	backlight_device_unregister(dell_backlight_device);
-- 
1.7.1


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

* Re: [PATCH v4] dell-laptop: Add debugfs support
  2010-09-24 10:48       ` [PATCH v4] " Keng-Yu Lin
@ 2010-09-27 14:00         ` Matthew Garrett
  2010-09-28  2:43           ` Keng-Yü Lin
  0 siblings, 1 reply; 9+ messages in thread
From: Matthew Garrett @ 2010-09-27 14:00 UTC (permalink / raw)
  To: Keng-Yu Lin
  Cc: len.brown, alan-jenkins, superm1, platform-driver-x86, linux-kernel

What's the difference between this version and v3?

-- 
Matthew Garrett | mjg59@srcf.ucam.org

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

* Re: [PATCH v4] dell-laptop: Add debugfs support
  2010-09-27 14:00         ` Matthew Garrett
@ 2010-09-28  2:43           ` Keng-Yü Lin
  2010-09-28  2:52             ` Matthew Garrett
  0 siblings, 1 reply; 9+ messages in thread
From: Keng-Yü Lin @ 2010-09-28  2:43 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: len.brown, alan-jenkins, superm1, platform-driver-x86, linux-kernel

On Mon, Sep 27, 2010 at 10:00 PM, Matthew Garrett <mjg59@srcf.ucam.org> wrote:
> What's the difference between this version and v3?
>
> --
> Matthew Garrett | mjg59@srcf.ucam.org
>

Hi Mathew:
  V3 does not print the correct bit of hwswitch_state. I just found
that V4 messed up by the operator precedence; will send a new fix.

  Regards,
-kengyu

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

* Re: [PATCH v4] dell-laptop: Add debugfs support
  2010-09-28  2:43           ` Keng-Yü Lin
@ 2010-09-28  2:52             ` Matthew Garrett
  2010-09-28  3:43               ` [PATCH v5] " Keng-Yu Lin
  0 siblings, 1 reply; 9+ messages in thread
From: Matthew Garrett @ 2010-09-28  2:52 UTC (permalink / raw)
  To: Keng-Yü Lin
  Cc: len.brown, alan-jenkins, superm1, platform-driver-x86, linux-kernel

On Tue, Sep 28, 2010 at 10:43:44AM +0800, Keng-Yü Lin wrote:
> On Mon, Sep 27, 2010 at 10:00 PM, Matthew Garrett <mjg59@srcf.ucam.org> wrote:
> > What's the difference between this version and v3?
> >
> > --
> > Matthew Garrett | mjg59@srcf.ucam.org
> >
> 
> Hi Mathew:
>   V3 does not print the correct bit of hwswitch_state. I just found
> that V4 messed up by the operator precedence; will send a new fix.

Ok, no problem. In future it's helpful to include a changelog with the 
difference - see Documentation/SubmittingPatches section 15 for some 
information on that. I'll wait for v5 and then merge it.

-- 
Matthew Garrett | mjg59@srcf.ucam.org

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

* [PATCH v5] dell-laptop: Add debugfs support
  2010-09-28  2:52             ` Matthew Garrett
@ 2010-09-28  3:43               ` Keng-Yu Lin
  0 siblings, 0 replies; 9+ messages in thread
From: Keng-Yu Lin @ 2010-09-28  3:43 UTC (permalink / raw)
  To: mjg59, len.brown, alan-jenkins, superm1, platform-driver-x86,
	linux-kernel
  Cc: Keng-Yu Lin

Export the status of RF killswitch through debugfs.

The killswitch status is obtained by the SMI to BIOS. Exporting this status
through debugfs can help identify the issue with the misbehaving firmware.

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

V5 fixed operator precedence mess-up of hwswitch_state, and prints the
bit number so that this debug info is complete for hardare manufacturers. 

diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 4413975..cf8a89a 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
@@ -325,6 +327,75 @@ static const struct rfkill_ops dell_rfkill_ops = {
 	.query = dell_rfkill_query,
 };
 
+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, "Bit 0 : Hardware switch supported:   %lu\n",
+		   status & BIT(0));
+	seq_printf(s, "Bit 1 : Wifi locator supported:      %lu\n",
+		  (status & BIT(1)) >> 1);
+	seq_printf(s, "Bit 2 : Wifi is supported:           %lu\n",
+		  (status & BIT(2)) >> 2);
+	seq_printf(s, "Bit 3 : Bluetooth is supported:      %lu\n",
+		  (status & BIT(3)) >> 3);
+	seq_printf(s, "Bit 4 : WWAN is supported:           %lu\n",
+		  (status & BIT(4)) >> 4);
+	seq_printf(s, "Bit 5 : Wireless keyboard supported: %lu\n",
+		  (status & BIT(5)) >> 5);
+	seq_printf(s, "Bit 8 : Wifi is installed:           %lu\n",
+		  (status & BIT(8)) >> 8);
+	seq_printf(s, "Bit 9 : Bluetooth is installed:      %lu\n",
+		  (status & BIT(9)) >> 9);
+	seq_printf(s, "Bit 10: WWAN is installed:           %lu\n",
+		  (status & BIT(10)) >> 10);
+	seq_printf(s, "Bit 16: Hardware switch is on:       %lu\n",
+		  (status & BIT(16)) >> 16);
+	seq_printf(s, "Bit 17: Wifi is blocked:             %lu\n",
+		  (status & BIT(17)) >> 17);
+	seq_printf(s, "Bit 18: Bluetooth is blocked:        %lu\n",
+		  (status & BIT(18)) >> 18);
+	seq_printf(s, "Bit 19: WWAN is blocked:             %lu\n",
+		  (status & BIT(19)) >> 19);
+
+	seq_printf(s, "\nhwswitch_state:\t0x%X\n", hwswitch_state);
+	seq_printf(s, "Bit 0 : Wifi controlled by switch:      %lu\n",
+		   hwswitch_state & BIT(0));
+	seq_printf(s, "Bit 1 : Bluetooth controlled by switch: %lu\n",
+		   (hwswitch_state & BIT(1)) >> 1);
+	seq_printf(s, "Bit 2 : WWAN controlled by switch:      %lu\n",
+		   (hwswitch_state & BIT(2)) >> 2);
+	seq_printf(s, "Bit 7 : Wireless switch config locked:  %lu\n",
+		   (hwswitch_state & BIT(7)) >> 7);
+	seq_printf(s, "Bit 8 : Wifi locator enabled:           %lu\n",
+		   (hwswitch_state & BIT(8)) >> 8);
+	seq_printf(s, "Bit 15: Wifi locator setting locked:    %lu\n",
+		   (hwswitch_state & BIT(15)) >> 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,
+};
+
 static void dell_update_rfkill(struct work_struct *ignored)
 {
 	if (wifi_rfkill)
@@ -556,6 +627,11 @@ static int __init dell_init(void)
 		goto fail_filter;
 	}
 
+	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);
+
 #ifdef CONFIG_ACPI
 	/* In the event of an ACPI backlight being available, don't
 	 * register the platform controller.
@@ -615,6 +691,7 @@ fail_platform_driver:
 
 static void __exit dell_exit(void)
 {
+	debugfs_remove_recursive(dell_laptop_dir);
 	i8042_remove_filter(dell_laptop_i8042_filter);
 	cancel_delayed_work_sync(&dell_rfkill_work);
 	backlight_device_unregister(dell_backlight_device);
-- 
1.7.1


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

end of thread, other threads:[~2010-09-28  3:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <AANLkTime84o+hJWVDegQWHxcvUiftKW-2psW5tv4a-yR@mail.gmail.com>
2010-09-16  3:19 ` [PATCH v2] dell-laptop: Add debugfs support Keng-Yu Lin
2010-09-16 16:46   ` Len Brown
2010-09-17  5:47     ` Keng-Yü Lin
2010-09-17  5:47     ` [PATCH v3] " Keng-Yu Lin
2010-09-24 10:48       ` [PATCH v4] " Keng-Yu Lin
2010-09-27 14:00         ` Matthew Garrett
2010-09-28  2:43           ` Keng-Yü Lin
2010-09-28  2:52             ` Matthew Garrett
2010-09-28  3:43               ` [PATCH v5] " Keng-Yu Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.