All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails
@ 2010-08-26  7:14 Dmitry Torokhov
  2010-08-26  7:14 ` [PATCH 02/10] WMI: free wmi blocks when parse_wdg() fails Dmitry Torokhov
                   ` (10 more replies)
  0 siblings, 11 replies; 21+ messages in thread
From: Dmitry Torokhov @ 2010-08-26  7:14 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: Carlos Corbacho, platform-driver-x86

Driver initialization was forgetting to remove EC address space handler
in cases when parse_wdg() method failed.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/platform/x86/wmi.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index b2978a0..7a77f03 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -968,12 +968,17 @@ static int acpi_wmi_add(struct acpi_device *device)
 						    ACPI_ADR_SPACE_EC,
 						    &acpi_wmi_ec_space_handler,
 						    NULL, NULL);
-	if (ACPI_FAILURE(status))
+	if (ACPI_FAILURE(status)) {
+		printk(KERN_ERR PREFIX "Error installing EC region handler\n");
 		return -ENODEV;
+	}
 
 	status = parse_wdg(device->handle);
 	if (ACPI_FAILURE(status)) {
-		printk(KERN_ERR PREFIX "Error installing EC region handler\n");
+		acpi_remove_address_space_handler(device->handle,
+						  ACPI_ADR_SPACE_EC,
+						  &acpi_wmi_ec_space_handler);
+		printk(KERN_ERR PREFIX "Failed to parse WDG method\n");
 		return -ENODEV;
 	}
 

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

* [PATCH 02/10] WMI: free wmi blocks when parse_wdg() fails
  2010-08-26  7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
@ 2010-08-26  7:14 ` Dmitry Torokhov
  2010-09-12 17:19   ` Carlos Corbacho
  2010-08-26  7:14 ` [PATCH 03/10] WMI: fix wmi_gtoa() to actully terminate the string Dmitry Torokhov
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Dmitry Torokhov @ 2010-08-26  7:14 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: Carlos Corbacho, platform-driver-x86

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/platform/x86/wmi.c |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 7a77f03..030d5f2 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -807,6 +807,16 @@ static bool guid_already_parsed(const char *guid_string)
 	return false;
 }
 
+static void free_wmi_blocks(void)
+{
+	struct wmi_block *wblock, *next;
+
+	list_for_each_entry_safe(wblock, next, &wmi_blocks.list, list) {
+		list_del(&wblock->list);
+		kfree(wblock);
+	}
+}
+
 /*
  * Parse the _WDG method for the GUID data blocks
  */
@@ -865,7 +875,7 @@ static acpi_status parse_wdg(acpi_handle handle)
 		wblock->handle = handle;
 		if (debug_event) {
 			wblock->handler = wmi_notify_debug;
-			status = wmi_method_enable(wblock, 1);
+			wmi_method_enable(wblock, 1);
 		}
 		list_add_tail(&wblock->list, &wmi_blocks.list);
 	}
@@ -875,6 +885,9 @@ out_free_gblock:
 out_free_pointer:
 	kfree(out.pointer);
 
+	if (ACPI_FAILURE(status))
+		free_wmi_blocks();
+
 	return status;
 }
 
@@ -1014,19 +1027,11 @@ static int __init acpi_wmi_init(void)
 
 static void __exit acpi_wmi_exit(void)
 {
-	struct list_head *p, *tmp;
-	struct wmi_block *wblock;
-
 	wmi_class_exit();
 
 	acpi_bus_unregister_driver(&acpi_wmi_driver);
 
-	list_for_each_safe(p, tmp, &wmi_blocks.list) {
-		wblock = list_entry(p, struct wmi_block, list);
-
-		list_del(p);
-		kfree(wblock);
-	}
+	free_wmi_blocks();
 
 	printk(KERN_INFO PREFIX "Mapper unloaded\n");
 }

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

* [PATCH 03/10] WMI: fix wmi_gtoa() to actully terminate the string
  2010-08-26  7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
  2010-08-26  7:14 ` [PATCH 02/10] WMI: free wmi blocks when parse_wdg() fails Dmitry Torokhov
@ 2010-08-26  7:14 ` Dmitry Torokhov
  2010-09-12 17:28   ` Carlos Corbacho
  2010-08-26  7:14 ` [PATCH 04/10] WMI: do not leak memory in parse_wdg() Dmitry Torokhov
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Dmitry Torokhov @ 2010-08-26  7:14 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: Carlos Corbacho, platform-driver-x86

Courtesy of sparse...

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/platform/x86/wmi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 030d5f2..63ad45e 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -232,7 +232,7 @@ static int wmi_gtoa(const char *in, char *out)
 	for (i = 10; i <= 15; i++)
 		out += sprintf(out, "%02X", in[i] & 0xFF);
 
-	out = '\0';
+	*out = '\0';
 	return 0;
 }
 

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

* [PATCH 04/10] WMI: do not leak memory in parse_wdg()
  2010-08-26  7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
  2010-08-26  7:14 ` [PATCH 02/10] WMI: free wmi blocks when parse_wdg() fails Dmitry Torokhov
  2010-08-26  7:14 ` [PATCH 03/10] WMI: fix wmi_gtoa() to actully terminate the string Dmitry Torokhov
@ 2010-08-26  7:14 ` Dmitry Torokhov
  2010-09-12 17:29   ` Carlos Corbacho
  2010-08-26  7:15 ` [PATCH 05/10] WMI: fix potential NULL pointer dereference Dmitry Torokhov
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Dmitry Torokhov @ 2010-08-26  7:14 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: Carlos Corbacho, platform-driver-x86

If we _WDG returned object that is not buffer we were forgetting
to free memory allocated for that object.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/platform/x86/wmi.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 63ad45e..5abb2ad 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -837,8 +837,10 @@ static acpi_status parse_wdg(acpi_handle handle)
 
 	obj = (union acpi_object *) out.pointer;
 
-	if (obj->type != ACPI_TYPE_BUFFER)
-		return AE_ERROR;
+	if (obj->type != ACPI_TYPE_BUFFER) {
+		status = AE_ERROR;
+		goto out_free_pointer;
+	}
 
 	total = obj->buffer.length / sizeof(struct guid_block);
 

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

* [PATCH 05/10] WMI: fix potential NULL pointer dereference
  2010-08-26  7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
                   ` (2 preceding siblings ...)
  2010-08-26  7:14 ` [PATCH 04/10] WMI: do not leak memory in parse_wdg() Dmitry Torokhov
@ 2010-08-26  7:15 ` Dmitry Torokhov
  2010-09-12 17:30   ` Carlos Corbacho
  2010-08-26  7:15 ` [PATCH 06/10] WMI: simplify handling of returned WMI blocks in parse_wdg() Dmitry Torokhov
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Dmitry Torokhov @ 2010-08-26  7:15 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: Carlos Corbacho, platform-driver-x86

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/platform/x86/wmi.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 5abb2ad..4032fa4 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -836,6 +836,8 @@ static acpi_status parse_wdg(acpi_handle handle)
 		return status;
 
 	obj = (union acpi_object *) out.pointer;
+	if (!obj)
+		return AE_ERROR;
 
 	if (obj->type != ACPI_TYPE_BUFFER) {
 		status = AE_ERROR;

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

* [PATCH 06/10] WMI: simplify handling of returned WMI blocks in parse_wdg()
  2010-08-26  7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
                   ` (3 preceding siblings ...)
  2010-08-26  7:15 ` [PATCH 05/10] WMI: fix potential NULL pointer dereference Dmitry Torokhov
@ 2010-08-26  7:15 ` Dmitry Torokhov
  2010-09-12 17:39   ` Carlos Corbacho
  2010-08-26  7:15 ` [PATCH 07/10] WMI: use separate list head for storing wmi blocks Dmitry Torokhov
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Dmitry Torokhov @ 2010-08-26  7:15 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: Carlos Corbacho, platform-driver-x86

There is no reason why we allocate memory and copy data into an
intermediate buffer, it is not like we are working with data coming
from userspace.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/platform/x86/wmi.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 4032fa4..e9064fb 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -487,7 +487,7 @@ const struct acpi_buffer *in)
 }
 EXPORT_SYMBOL_GPL(wmi_set_block);
 
-static void wmi_dump_wdg(struct guid_block *g)
+static void wmi_dump_wdg(const struct guid_block *g)
 {
 	char guid_string[37];
 
@@ -824,7 +824,7 @@ static acpi_status parse_wdg(acpi_handle handle)
 {
 	struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
 	union acpi_object *obj;
-	struct guid_block *gblock;
+	const struct guid_block *gblock;
 	struct wmi_block *wblock;
 	char guid_string[37];
 	acpi_status status;
@@ -844,14 +844,9 @@ static acpi_status parse_wdg(acpi_handle handle)
 		goto out_free_pointer;
 	}
 
+	gblock = (const struct guid_block *)obj->buffer.pointer;
 	total = obj->buffer.length / sizeof(struct guid_block);
 
-	gblock = kmemdup(obj->buffer.pointer, obj->buffer.length, GFP_KERNEL);
-	if (!gblock) {
-		status = AE_NO_MEMORY;
-		goto out_free_pointer;
-	}
-
 	for (i = 0; i < total; i++) {
 		/*
 		  Some WMI devices, like those for nVidia hooks, have a
@@ -872,7 +867,7 @@ static acpi_status parse_wdg(acpi_handle handle)
 		wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
 		if (!wblock) {
 			status = AE_NO_MEMORY;
-			goto out_free_gblock;
+			goto out_free_pointer;
 		}
 
 		wblock->gblock = gblock[i];
@@ -884,8 +879,6 @@ static acpi_status parse_wdg(acpi_handle handle)
 		list_add_tail(&wblock->list, &wmi_blocks.list);
 	}
 
-out_free_gblock:
-	kfree(gblock);
 out_free_pointer:
 	kfree(out.pointer);
 

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

* [PATCH 07/10] WMI: use separate list head for storing wmi blocks
  2010-08-26  7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
                   ` (4 preceding siblings ...)
  2010-08-26  7:15 ` [PATCH 06/10] WMI: simplify handling of returned WMI blocks in parse_wdg() Dmitry Torokhov
@ 2010-08-26  7:15 ` Dmitry Torokhov
  2010-09-12 17:40   ` Carlos Corbacho
  2010-08-26  7:15 ` [PATCH 08/10] WMI: use pr_err() and friends Dmitry Torokhov
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Dmitry Torokhov @ 2010-08-26  7:15 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: Carlos Corbacho, platform-driver-x86

Do not abuse wmi_block structure to hold the head of list
of blocks, use separate list_head for that.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/platform/x86/wmi.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index e9064fb..7b68dce 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -47,6 +47,7 @@ MODULE_LICENSE("GPL");
 #define PREFIX "ACPI: WMI: "
 
 static DEFINE_MUTEX(wmi_data_lock);
+static LIST_HEAD(wmi_block_list);
 
 struct guid_block {
 	char guid[16];
@@ -70,7 +71,6 @@ struct wmi_block {
 	struct device *dev;
 };
 
-static struct wmi_block wmi_blocks;
 
 /*
  * If the GUID data block is marked as expensive, we must enable and
@@ -246,7 +246,7 @@ static bool find_guid(const char *guid_string, struct wmi_block **out)
 	wmi_parse_guid(guid_string, tmp);
 	wmi_swap_bytes(tmp, guid_input);
 
-	list_for_each(p, &wmi_blocks.list) {
+	list_for_each(p, &wmi_block_list) {
 		wblock = list_entry(p, struct wmi_block, list);
 		block = &wblock->gblock;
 
@@ -633,7 +633,7 @@ acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out)
 	params[0].type = ACPI_TYPE_INTEGER;
 	params[0].integer.value = event;
 
-	list_for_each(p, &wmi_blocks.list) {
+	list_for_each(p, &wmi_block_list) {
 		wblock = list_entry(p, struct wmi_block, list);
 		gblock = &wblock->gblock;
 
@@ -721,7 +721,7 @@ static int wmi_create_devs(void)
 	struct device *guid_dev;
 
 	/* Create devices for all the GUIDs */
-	list_for_each(p, &wmi_blocks.list) {
+	list_for_each(p, &wmi_block_list) {
 		wblock = list_entry(p, struct wmi_block, list);
 
 		guid_dev = kzalloc(sizeof(struct device), GFP_KERNEL);
@@ -758,7 +758,7 @@ static void wmi_remove_devs(void)
 	struct device *guid_dev;
 
 	/* Delete devices for all the GUIDs */
-	list_for_each(p, &wmi_blocks.list) {
+	list_for_each(p, &wmi_block_list) {
 		wblock = list_entry(p, struct wmi_block, list);
 
 		guid_dev = wblock->dev;
@@ -797,7 +797,7 @@ static bool guid_already_parsed(const char *guid_string)
 	struct wmi_block *wblock;
 	struct list_head *p;
 
-	list_for_each(p, &wmi_blocks.list) {
+	list_for_each(p, &wmi_block_list) {
 		wblock = list_entry(p, struct wmi_block, list);
 		gblock = &wblock->gblock;
 
@@ -811,7 +811,7 @@ static void free_wmi_blocks(void)
 {
 	struct wmi_block *wblock, *next;
 
-	list_for_each_entry_safe(wblock, next, &wmi_blocks.list, list) {
+	list_for_each_entry_safe(wblock, next, &wmi_block_list, list) {
 		list_del(&wblock->list);
 		kfree(wblock);
 	}
@@ -876,7 +876,7 @@ static acpi_status parse_wdg(acpi_handle handle)
 			wblock->handler = wmi_notify_debug;
 			wmi_method_enable(wblock, 1);
 		}
-		list_add_tail(&wblock->list, &wmi_blocks.list);
+		list_add_tail(&wblock->list, &wmi_block_list);
 	}
 
 out_free_pointer:
@@ -939,7 +939,7 @@ static void acpi_wmi_notify(struct acpi_device *device, u32 event)
 	struct list_head *p;
 	char guid_string[37];
 
-	list_for_each(p, &wmi_blocks.list) {
+	list_for_each(p, &wmi_block_list) {
 		wblock = list_entry(p, struct wmi_block, list);
 		block = &wblock->gblock;
 
@@ -999,8 +999,6 @@ static int __init acpi_wmi_init(void)
 {
 	int result;
 
-	INIT_LIST_HEAD(&wmi_blocks.list);
-
 	if (acpi_disabled)
 		return -ENODEV;
 

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

* [PATCH 08/10] WMI: use pr_err() and friends
  2010-08-26  7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
                   ` (5 preceding siblings ...)
  2010-08-26  7:15 ` [PATCH 07/10] WMI: use separate list head for storing wmi blocks Dmitry Torokhov
@ 2010-08-26  7:15 ` Dmitry Torokhov
  2010-09-12 17:42   ` Carlos Corbacho
  2010-08-26  7:15 ` [PATCH 09/10] WMI: make use of class device's attributres Dmitry Torokhov
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Dmitry Torokhov @ 2010-08-26  7:15 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: Carlos Corbacho, platform-driver-x86

This makes source more concise and easier to read.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/platform/x86/wmi.c |   64 ++++++++++++++++++++------------------------
 1 files changed, 29 insertions(+), 35 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 7b68dce..b4e5bea 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -27,6 +27,8 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#define pr_fmt(fmt)	KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -44,8 +46,6 @@ MODULE_LICENSE("GPL");
 
 #define ACPI_WMI_CLASS "wmi"
 
-#define PREFIX "ACPI: WMI: "
-
 static DEFINE_MUTEX(wmi_data_lock);
 static LIST_HEAD(wmi_block_list);
 
@@ -492,25 +492,24 @@ static void wmi_dump_wdg(const struct guid_block *g)
 	char guid_string[37];
 
 	wmi_gtoa(g->guid, guid_string);
-	printk(KERN_INFO PREFIX "%s:\n", guid_string);
-	printk(KERN_INFO PREFIX "\tobject_id: %c%c\n",
-	       g->object_id[0], g->object_id[1]);
-	printk(KERN_INFO PREFIX "\tnotify_id: %02X\n", g->notify_id);
-	printk(KERN_INFO PREFIX "\treserved: %02X\n", g->reserved);
-	printk(KERN_INFO PREFIX "\tinstance_count: %d\n", g->instance_count);
-	printk(KERN_INFO PREFIX "\tflags: %#x", g->flags);
+
+	pr_info("%s:\n", guid_string);
+	pr_info("\tobject_id: %c%c\n", g->object_id[0], g->object_id[1]);
+	pr_info("\tnotify_id: %02X\n", g->notify_id);
+	pr_info("\treserved: %02X\n", g->reserved);
+	pr_info("\tinstance_count: %d\n", g->instance_count);
+	pr_info("\tflags: %#x ", g->flags);
 	if (g->flags) {
-		printk(" ");
 		if (g->flags & ACPI_WMI_EXPENSIVE)
-			printk("ACPI_WMI_EXPENSIVE ");
+			pr_cont("ACPI_WMI_EXPENSIVE ");
 		if (g->flags & ACPI_WMI_METHOD)
-			printk("ACPI_WMI_METHOD ");
+			pr_cont("ACPI_WMI_METHOD ");
 		if (g->flags & ACPI_WMI_STRING)
-			printk("ACPI_WMI_STRING ");
+			pr_cont("ACPI_WMI_STRING ");
 		if (g->flags & ACPI_WMI_EVENT)
-			printk("ACPI_WMI_EVENT ");
+			pr_cont("ACPI_WMI_EVENT ");
 	}
-	printk("\n");
+	pr_cont("\n");
 
 }
 
@@ -522,7 +521,7 @@ static void wmi_notify_debug(u32 value, void *context)
 
 	status = wmi_get_event_data(value, &response);
 	if (status != AE_OK) {
-		printk(KERN_INFO "wmi: bad event status 0x%x\n", status);
+		pr_info("bad event status 0x%x\n", status);
 		return;
 	}
 
@@ -531,22 +530,22 @@ static void wmi_notify_debug(u32 value, void *context)
 	if (!obj)
 		return;
 
-	printk(KERN_INFO PREFIX "DEBUG Event ");
+	pr_info("DEBUG Event ");
 	switch(obj->type) {
 	case ACPI_TYPE_BUFFER:
-		printk("BUFFER_TYPE - length %d\n", obj->buffer.length);
+		pr_cont("BUFFER_TYPE - length %d\n", obj->buffer.length);
 		break;
 	case ACPI_TYPE_STRING:
-		printk("STRING_TYPE - %s\n", obj->string.pointer);
+		pr_cont("STRING_TYPE - %s\n", obj->string.pointer);
 		break;
 	case ACPI_TYPE_INTEGER:
-		printk("INTEGER_TYPE - %llu\n", obj->integer.value);
+		pr_cont("INTEGER_TYPE - %llu\n", obj->integer.value);
 		break;
 	case ACPI_TYPE_PACKAGE:
-		printk("PACKAGE_TYPE - %d elements\n", obj->package.count);
+		pr_cont("PACKAGE_TYPE - %d elements\n", obj->package.count);
 		break;
 	default:
-		printk("object type 0x%X\n", obj->type);
+		pr_cont("object type 0x%X\n", obj->type);
 	}
 	kfree(obj);
 }
@@ -857,8 +856,7 @@ static acpi_status parse_wdg(acpi_handle handle)
 		*/
 		if (guid_already_parsed(gblock[i].guid) == true) {
 			wmi_gtoa(gblock[i].guid, guid_string);
-			printk(KERN_INFO PREFIX "Skipping duplicate GUID %s\n",
-				guid_string);
+			pr_info("Skipping duplicate GUID %s\n", guid_string);
 			continue;
 		}
 		if (debug_dump_wdg)
@@ -949,8 +947,7 @@ static void acpi_wmi_notify(struct acpi_device *device, u32 event)
 				wblock->handler(event, wblock->handler_data);
 			if (debug_event) {
 				wmi_gtoa(wblock->gblock.guid, guid_string);
-				printk(KERN_INFO PREFIX "DEBUG Event GUID:"
-				       " %s\n", guid_string);
+				pr_info("DEBUG Event GUID: %s\n", guid_string);
 			}
 
 			acpi_bus_generate_netlink_event(
@@ -979,7 +976,7 @@ static int acpi_wmi_add(struct acpi_device *device)
 						    &acpi_wmi_ec_space_handler,
 						    NULL, NULL);
 	if (ACPI_FAILURE(status)) {
-		printk(KERN_ERR PREFIX "Error installing EC region handler\n");
+		pr_err("Error installing EC region handler\n");
 		return -ENODEV;
 	}
 
@@ -988,7 +985,7 @@ static int acpi_wmi_add(struct acpi_device *device)
 		acpi_remove_address_space_handler(device->handle,
 						  ACPI_ADR_SPACE_EC,
 						  &acpi_wmi_ec_space_handler);
-		printk(KERN_ERR PREFIX "Failed to parse WDG method\n");
+		pr_err("Failed to parse WDG method\n");
 		return -ENODEV;
 	}
 
@@ -1003,9 +1000,8 @@ static int __init acpi_wmi_init(void)
 		return -ENODEV;
 
 	result = acpi_bus_register_driver(&acpi_wmi_driver);
-
 	if (result < 0) {
-		printk(KERN_INFO PREFIX "Error loading mapper\n");
+		pr_err("Error loading mapper\n");
 		return -ENODEV;
 	}
 
@@ -1015,20 +1011,18 @@ static int __init acpi_wmi_init(void)
 		return result;
 	}
 
-	printk(KERN_INFO PREFIX "Mapper loaded\n");
+	pr_info("Mapper loaded\n");
 
-	return result;
+	return 0;
 }
 
 static void __exit acpi_wmi_exit(void)
 {
 	wmi_class_exit();
-
 	acpi_bus_unregister_driver(&acpi_wmi_driver);
-
 	free_wmi_blocks();
 
-	printk(KERN_INFO PREFIX "Mapper unloaded\n");
+	pr_info("Mapper unloaded\n");
 }
 
 subsys_initcall(acpi_wmi_init);

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

* [PATCH 09/10] WMI: make use of class device's attributres
  2010-08-26  7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
                   ` (6 preceding siblings ...)
  2010-08-26  7:15 ` [PATCH 08/10] WMI: use pr_err() and friends Dmitry Torokhov
@ 2010-08-26  7:15 ` Dmitry Torokhov
  2010-09-12 17:50   ` Carlos Corbacho
  2010-08-26  7:15 ` [PATCH 10/10] WMI: embed struct device directly into wmi_block Dmitry Torokhov
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Dmitry Torokhov @ 2010-08-26  7:15 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: Carlos Corbacho, platform-driver-x86

Instead of adding modalias attribute manually set it up as class's
device attribute so driver core will create and remove it for us.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/platform/x86/wmi.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index b4e5bea..781321b 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -661,7 +661,7 @@ EXPORT_SYMBOL_GPL(wmi_has_guid);
 /*
  * sysfs interface
  */
-static ssize_t show_modalias(struct device *dev, struct device_attribute *attr,
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 			     char *buf)
 {
 	char guid_string[37];
@@ -675,7 +675,11 @@ static ssize_t show_modalias(struct device *dev, struct device_attribute *attr,
 
 	return sprintf(buf, "wmi:%s\n", guid_string);
 }
-static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
+
+static struct device_attribute wmi_dev_attrs[] = {
+	__ATTR_RO(modalias),
+	__ATTR_NULL
+};
 
 static int wmi_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
@@ -708,6 +712,7 @@ static struct class wmi_class = {
 	.name = "wmi",
 	.dev_release = wmi_dev_free,
 	.dev_uevent = wmi_dev_uevent,
+	.dev_attrs = wmi_dev_attrs,
 };
 
 static int wmi_create_devs(void)
@@ -740,10 +745,6 @@ static int wmi_create_devs(void)
 		result = device_register(guid_dev);
 		if (result)
 			return result;
-
-		result = device_create_file(guid_dev, &dev_attr_modalias);
-		if (result)
-			return result;
 	}
 
 	return 0;
@@ -763,8 +764,6 @@ static void wmi_remove_devs(void)
 		guid_dev = wblock->dev;
 		gblock = &wblock->gblock;
 
-		device_remove_file(guid_dev, &dev_attr_modalias);
-
 		device_unregister(guid_dev);
 	}
 }

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

* [PATCH 10/10] WMI: embed struct device directly into wmi_block
  2010-08-26  7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
                   ` (7 preceding siblings ...)
  2010-08-26  7:15 ` [PATCH 09/10] WMI: make use of class device's attributres Dmitry Torokhov
@ 2010-08-26  7:15 ` Dmitry Torokhov
  2010-09-12  7:29 ` [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
  2010-09-12 17:14 ` Carlos Corbacho
  10 siblings, 0 replies; 21+ messages in thread
From: Dmitry Torokhov @ 2010-08-26  7:15 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: Carlos Corbacho, platform-driver-x86

Instead of creating wmi_blocks and then register corresponding devices
on a separate pass do it all in one shot, since lifetime rules for both
objects are the same. This also takes care of leaking devices when
device_create fails for one of them.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/platform/x86/wmi.c |  176 ++++++++++++++++----------------------------
 1 files changed, 65 insertions(+), 111 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 781321b..f822ff0 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -68,7 +68,7 @@ struct wmi_block {
 	acpi_handle handle;
 	wmi_notify_handler handler;
 	void *handler_data;
-	struct device *dev;
+	struct device dev;
 };
 
 
@@ -110,7 +110,7 @@ static struct acpi_driver acpi_wmi_driver = {
 		.add = acpi_wmi_add,
 		.remove = acpi_wmi_remove,
 		.notify = acpi_wmi_notify,
-		},
+	},
 };
 
 /*
@@ -705,7 +705,9 @@ static int wmi_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
 
 static void wmi_dev_free(struct device *dev)
 {
-	kfree(dev);
+	struct wmi_block *wmi_block = container_of(dev, struct wmi_block, dev);
+
+	kfree(wmi_block);
 }
 
 static struct class wmi_class = {
@@ -715,104 +717,60 @@ static struct class wmi_class = {
 	.dev_attrs = wmi_dev_attrs,
 };
 
-static int wmi_create_devs(void)
+static struct wmi_block *wmi_create_device(const struct guid_block *gblock,
+					   acpi_handle handle)
 {
-	int result;
-	char guid_string[37];
-	struct guid_block *gblock;
 	struct wmi_block *wblock;
-	struct list_head *p;
-	struct device *guid_dev;
+	int error;
+	char guid_string[37];
 
-	/* Create devices for all the GUIDs */
-	list_for_each(p, &wmi_block_list) {
-		wblock = list_entry(p, struct wmi_block, list);
+	wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
+	if (!wblock) {
+		error = -ENOMEM;
+		goto err_out;
+	}
 
-		guid_dev = kzalloc(sizeof(struct device), GFP_KERNEL);
-		if (!guid_dev)
-			return -ENOMEM;
+	wblock->handle = handle;
+	wblock->gblock = *gblock;
 
-		wblock->dev = guid_dev;
+	wblock->dev.class = &wmi_class;
 
-		guid_dev->class = &wmi_class;
-		dev_set_drvdata(guid_dev, wblock);
+	wmi_gtoa(gblock->guid, guid_string);
+	dev_set_name(&wblock->dev, guid_string);
 
-		gblock = &wblock->gblock;
+	dev_set_drvdata(&wblock->dev, wblock);
 
-		wmi_gtoa(gblock->guid, guid_string);
-		dev_set_name(guid_dev, guid_string);
+	error = device_register(&wblock->dev);
+	if (error)
+		goto err_free;
 
-		result = device_register(guid_dev);
-		if (result)
-			return result;
-	}
+	list_add_tail(&wblock->list, &wmi_block_list);
+	return wblock;
 
-	return 0;
+err_free:
+	kfree(wblock);
+err_out:
+	return ERR_PTR(error);
 }
 
-static void wmi_remove_devs(void)
+static void wmi_free_devices(void)
 {
-	struct guid_block *gblock;
-	struct wmi_block *wblock;
-	struct list_head *p;
-	struct device *guid_dev;
+	struct wmi_block *wblock, *next;
 
 	/* Delete devices for all the GUIDs */
-	list_for_each(p, &wmi_block_list) {
-		wblock = list_entry(p, struct wmi_block, list);
-
-		guid_dev = wblock->dev;
-		gblock = &wblock->gblock;
-
-		device_unregister(guid_dev);
-	}
-}
-
-static void wmi_class_exit(void)
-{
-	wmi_remove_devs();
-	class_unregister(&wmi_class);
-}
-
-static int wmi_class_init(void)
-{
-	int ret;
-
-	ret = class_register(&wmi_class);
-	if (ret)
-		return ret;
-
-	ret = wmi_create_devs();
-	if (ret)
-		wmi_class_exit();
-
-	return ret;
+	list_for_each_entry_safe(wblock, next, &wmi_block_list, list)
+		device_unregister(&wblock->dev);
 }
 
 static bool guid_already_parsed(const char *guid_string)
 {
-	struct guid_block *gblock;
 	struct wmi_block *wblock;
-	struct list_head *p;
-
-	list_for_each(p, &wmi_block_list) {
-		wblock = list_entry(p, struct wmi_block, list);
-		gblock = &wblock->gblock;
 
-		if (strncmp(gblock->guid, guid_string, 16) == 0)
+	list_for_each_entry(wblock, &wmi_block_list, list)
+		if (strncmp(wblock->gblock.guid, guid_string, 16) == 0)
 			return true;
-	}
-	return false;
-}
 
-static void free_wmi_blocks(void)
-{
-	struct wmi_block *wblock, *next;
-
-	list_for_each_entry_safe(wblock, next, &wmi_block_list, list) {
-		list_del(&wblock->list);
-		kfree(wblock);
-	}
+	return false;
 }
 
 /*
@@ -826,19 +784,19 @@ static acpi_status parse_wdg(acpi_handle handle)
 	struct wmi_block *wblock;
 	char guid_string[37];
 	acpi_status status;
+	int retval;
 	u32 i, total;
 
 	status = acpi_evaluate_object(handle, "_WDG", NULL, &out);
-
 	if (ACPI_FAILURE(status))
-		return status;
+		return -ENXIO;
 
 	obj = (union acpi_object *) out.pointer;
 	if (!obj)
-		return AE_ERROR;
+		return -ENXIO;
 
 	if (obj->type != ACPI_TYPE_BUFFER) {
-		status = AE_ERROR;
+		retval = -ENXIO;
 		goto out_free_pointer;
 	}
 
@@ -858,31 +816,29 @@ static acpi_status parse_wdg(acpi_handle handle)
 			pr_info("Skipping duplicate GUID %s\n", guid_string);
 			continue;
 		}
+
 		if (debug_dump_wdg)
 			wmi_dump_wdg(&gblock[i]);
 
-		wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
-		if (!wblock) {
-			status = AE_NO_MEMORY;
-			goto out_free_pointer;
+		wblock = wmi_create_device(&gblock[i], handle);
+		if (IS_ERR(wblock)) {
+			retval = PTR_ERR(wblock);
+			wmi_free_devices();
+			break;
 		}
 
-		wblock->gblock = gblock[i];
-		wblock->handle = handle;
 		if (debug_event) {
 			wblock->handler = wmi_notify_debug;
 			wmi_method_enable(wblock, 1);
 		}
-		list_add_tail(&wblock->list, &wmi_block_list);
 	}
 
+	retval = 0;
+
 out_free_pointer:
 	kfree(out.pointer);
 
-	if (ACPI_FAILURE(status))
-		free_wmi_blocks();
-
-	return status;
+	return retval;
 }
 
 /*
@@ -961,6 +917,7 @@ static int acpi_wmi_remove(struct acpi_device *device, int type)
 {
 	acpi_remove_address_space_handler(device->handle,
 				ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler);
+	wmi_free_devices();
 
 	return 0;
 }
@@ -968,7 +925,7 @@ static int acpi_wmi_remove(struct acpi_device *device, int type)
 static int acpi_wmi_add(struct acpi_device *device)
 {
 	acpi_status status;
-	int result = 0;
+	int error;
 
 	status = acpi_install_address_space_handler(device->handle,
 						    ACPI_ADR_SPACE_EC,
@@ -979,47 +936,44 @@ static int acpi_wmi_add(struct acpi_device *device)
 		return -ENODEV;
 	}
 
-	status = parse_wdg(device->handle);
-	if (ACPI_FAILURE(status)) {
+	error = parse_wdg(device->handle);
+	if (error) {
 		acpi_remove_address_space_handler(device->handle,
 						  ACPI_ADR_SPACE_EC,
 						  &acpi_wmi_ec_space_handler);
 		pr_err("Failed to parse WDG method\n");
-		return -ENODEV;
+		return error;
 	}
 
-	return result;
+	return 0;
 }
 
 static int __init acpi_wmi_init(void)
 {
-	int result;
+	int error;
 
 	if (acpi_disabled)
 		return -ENODEV;
 
-	result = acpi_bus_register_driver(&acpi_wmi_driver);
-	if (result < 0) {
-		pr_err("Error loading mapper\n");
-		return -ENODEV;
-	}
+	error = class_register(&wmi_class);
+	if (error)
+		return error;
 
-	result = wmi_class_init();
-	if (result) {
-		acpi_bus_unregister_driver(&acpi_wmi_driver);
-		return result;
+	error = acpi_bus_register_driver(&acpi_wmi_driver);
+	if (error) {
+		pr_err("Error loading mapper\n");
+		class_unregister(&wmi_class);
+		return error;
 	}
 
 	pr_info("Mapper loaded\n");
-
 	return 0;
 }
 
 static void __exit acpi_wmi_exit(void)
 {
-	wmi_class_exit();
 	acpi_bus_unregister_driver(&acpi_wmi_driver);
-	free_wmi_blocks();
+	class_unregister(&wmi_class);
 
 	pr_info("Mapper unloaded\n");
 }

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

* Re: [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails
  2010-08-26  7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
                   ` (8 preceding siblings ...)
  2010-08-26  7:15 ` [PATCH 10/10] WMI: embed struct device directly into wmi_block Dmitry Torokhov
@ 2010-09-12  7:29 ` Dmitry Torokhov
  2010-09-12 17:14 ` Carlos Corbacho
  10 siblings, 0 replies; 21+ messages in thread
From: Dmitry Torokhov @ 2010-09-12  7:29 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: Carlos Corbacho, platform-driver-x86

On Thu, Aug 26, 2010 at 12:14:42AM -0700, Dmitry Torokhov wrote:
> Driver initialization was forgetting to remove EC address space handler
> in cases when parse_wdg() method failed.
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

*PING* for this and the other 9 in these series...

Thanks.

> ---
> 
>  drivers/platform/x86/wmi.c |    9 +++++++--
>  1 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index b2978a0..7a77f03 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -968,12 +968,17 @@ static int acpi_wmi_add(struct acpi_device *device)
>  						    ACPI_ADR_SPACE_EC,
>  						    &acpi_wmi_ec_space_handler,
>  						    NULL, NULL);
> -	if (ACPI_FAILURE(status))
> +	if (ACPI_FAILURE(status)) {
> +		printk(KERN_ERR PREFIX "Error installing EC region handler\n");
>  		return -ENODEV;
> +	}
>  
>  	status = parse_wdg(device->handle);
>  	if (ACPI_FAILURE(status)) {
> -		printk(KERN_ERR PREFIX "Error installing EC region handler\n");
> +		acpi_remove_address_space_handler(device->handle,
> +						  ACPI_ADR_SPACE_EC,
> +						  &acpi_wmi_ec_space_handler);
> +		printk(KERN_ERR PREFIX "Failed to parse WDG method\n");
>  		return -ENODEV;
>  	}
>  
> 

-- 
Dmitry

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

* Re: [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails
  2010-08-26  7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
                   ` (9 preceding siblings ...)
  2010-09-12  7:29 ` [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
@ 2010-09-12 17:14 ` Carlos Corbacho
  2010-10-01 17:00   ` Dmitry Torokhov
  10 siblings, 1 reply; 21+ messages in thread
From: Carlos Corbacho @ 2010-09-12 17:14 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Matthew Garrett, platform-driver-x86

On Thursday 26 August 2010 08:14:42 Dmitry Torokhov wrote:
> Driver initialization was forgetting to remove EC address space handler
> in cases when parse_wdg() method failed.
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk>

> ---
> 
>  drivers/platform/x86/wmi.c |    9 +++++++--
>  1 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index b2978a0..7a77f03 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -968,12 +968,17 @@ static int acpi_wmi_add(struct acpi_device *device)
>  						    ACPI_ADR_SPACE_EC,
>  						    &acpi_wmi_ec_space_handler,
>  						    NULL, NULL);
> -	if (ACPI_FAILURE(status))
> +	if (ACPI_FAILURE(status)) {
> +		printk(KERN_ERR PREFIX "Error installing EC region handler\n");
>  		return -ENODEV;
> +	}
> 
>  	status = parse_wdg(device->handle);
>  	if (ACPI_FAILURE(status)) {
> -		printk(KERN_ERR PREFIX "Error installing EC region handler\n");
> +		acpi_remove_address_space_handler(device->handle,
> +						  ACPI_ADR_SPACE_EC,
> +						  &acpi_wmi_ec_space_handler);
> +		printk(KERN_ERR PREFIX "Failed to parse WDG method\n");
>  		return -ENODEV;
>  	}

-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

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

* Re: [PATCH 02/10] WMI: free wmi blocks when parse_wdg() fails
  2010-08-26  7:14 ` [PATCH 02/10] WMI: free wmi blocks when parse_wdg() fails Dmitry Torokhov
@ 2010-09-12 17:19   ` Carlos Corbacho
  0 siblings, 0 replies; 21+ messages in thread
From: Carlos Corbacho @ 2010-09-12 17:19 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Matthew Garrett, platform-driver-x86

On Thursday 26 August 2010 08:14:48 Dmitry Torokhov wrote:
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk>

> ---
> 
>  drivers/platform/x86/wmi.c |   25 +++++++++++++++----------
>  1 files changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index 7a77f03..030d5f2 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -807,6 +807,16 @@ static bool guid_already_parsed(const char
> *guid_string) return false;
>  }
> 
> +static void free_wmi_blocks(void)
> +{
> +	struct wmi_block *wblock, *next;
> +
> +	list_for_each_entry_safe(wblock, next, &wmi_blocks.list, list) {
> +		list_del(&wblock->list);
> +		kfree(wblock);
> +	}
> +}
> +
>  /*
>   * Parse the _WDG method for the GUID data blocks
>   */
> @@ -865,7 +875,7 @@ static acpi_status parse_wdg(acpi_handle handle)
>  		wblock->handle = handle;
>  		if (debug_event) {
>  			wblock->handler = wmi_notify_debug;
> -			status = wmi_method_enable(wblock, 1);
> +			wmi_method_enable(wblock, 1);
>  		}
>  		list_add_tail(&wblock->list, &wmi_blocks.list);
>  	}
> @@ -875,6 +885,9 @@ out_free_gblock:
>  out_free_pointer:
>  	kfree(out.pointer);
> 
> +	if (ACPI_FAILURE(status))
> +		free_wmi_blocks();
> +
>  	return status;
>  }
> 
> @@ -1014,19 +1027,11 @@ static int __init acpi_wmi_init(void)
> 
>  static void __exit acpi_wmi_exit(void)
>  {
> -	struct list_head *p, *tmp;
> -	struct wmi_block *wblock;
> -
>  	wmi_class_exit();
> 
>  	acpi_bus_unregister_driver(&acpi_wmi_driver);
> 
> -	list_for_each_safe(p, tmp, &wmi_blocks.list) {
> -		wblock = list_entry(p, struct wmi_block, list);
> -
> -		list_del(p);
> -		kfree(wblock);
> -	}
> +	free_wmi_blocks();
> 
>  	printk(KERN_INFO PREFIX "Mapper unloaded\n");
>  }

-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

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

* Re: [PATCH 03/10] WMI: fix wmi_gtoa() to actully terminate the string
  2010-08-26  7:14 ` [PATCH 03/10] WMI: fix wmi_gtoa() to actully terminate the string Dmitry Torokhov
@ 2010-09-12 17:28   ` Carlos Corbacho
  0 siblings, 0 replies; 21+ messages in thread
From: Carlos Corbacho @ 2010-09-12 17:28 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Matthew Garrett, platform-driver-x86

On Thursday 26 August 2010 08:14:53 Dmitry Torokhov wrote:
> Courtesy of sparse...
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk>

> ---
> 
>  drivers/platform/x86/wmi.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index 030d5f2..63ad45e 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -232,7 +232,7 @@ static int wmi_gtoa(const char *in, char *out)
>  	for (i = 10; i <= 15; i++)
>  		out += sprintf(out, "%02X", in[i] & 0xFF);
> 
> -	out = '\0';
> +	*out = '\0';
>  	return 0;
>  }

-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

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

* Re: [PATCH 04/10] WMI: do not leak memory in parse_wdg()
  2010-08-26  7:14 ` [PATCH 04/10] WMI: do not leak memory in parse_wdg() Dmitry Torokhov
@ 2010-09-12 17:29   ` Carlos Corbacho
  0 siblings, 0 replies; 21+ messages in thread
From: Carlos Corbacho @ 2010-09-12 17:29 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Matthew Garrett, platform-driver-x86

On Thursday 26 August 2010 08:14:58 Dmitry Torokhov wrote:
> If we _WDG returned object that is not buffer we were forgetting
> to free memory allocated for that object.
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk>

> ---
> 
>  drivers/platform/x86/wmi.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index 63ad45e..5abb2ad 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -837,8 +837,10 @@ static acpi_status parse_wdg(acpi_handle handle)
> 
>  	obj = (union acpi_object *) out.pointer;
> 
> -	if (obj->type != ACPI_TYPE_BUFFER)
> -		return AE_ERROR;
> +	if (obj->type != ACPI_TYPE_BUFFER) {
> +		status = AE_ERROR;
> +		goto out_free_pointer;
> +	}
> 
>  	total = obj->buffer.length / sizeof(struct guid_block);

-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

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

* Re: [PATCH 05/10] WMI: fix potential NULL pointer dereference
  2010-08-26  7:15 ` [PATCH 05/10] WMI: fix potential NULL pointer dereference Dmitry Torokhov
@ 2010-09-12 17:30   ` Carlos Corbacho
  0 siblings, 0 replies; 21+ messages in thread
From: Carlos Corbacho @ 2010-09-12 17:30 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Matthew Garrett, platform-driver-x86

On Thursday 26 August 2010 08:15:03 Dmitry Torokhov wrote:
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk>

> ---
> 
>  drivers/platform/x86/wmi.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index 5abb2ad..4032fa4 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -836,6 +836,8 @@ static acpi_status parse_wdg(acpi_handle handle)
>  		return status;
> 
>  	obj = (union acpi_object *) out.pointer;
> +	if (!obj)
> +		return AE_ERROR;
> 
>  	if (obj->type != ACPI_TYPE_BUFFER) {
>  		status = AE_ERROR;

-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

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

* Re: [PATCH 06/10] WMI: simplify handling of returned WMI blocks in parse_wdg()
  2010-08-26  7:15 ` [PATCH 06/10] WMI: simplify handling of returned WMI blocks in parse_wdg() Dmitry Torokhov
@ 2010-09-12 17:39   ` Carlos Corbacho
  0 siblings, 0 replies; 21+ messages in thread
From: Carlos Corbacho @ 2010-09-12 17:39 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Matthew Garrett, platform-driver-x86

On Thursday 26 August 2010 08:15:09 Dmitry Torokhov wrote:
> There is no reason why we allocate memory and copy data into an
> intermediate buffer, it is not like we are working with data coming
> from userspace.
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk>

> ---
> 
>  drivers/platform/x86/wmi.c |   15 ++++-----------
>  1 files changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index 4032fa4..e9064fb 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -487,7 +487,7 @@ const struct acpi_buffer *in)
>  }
>  EXPORT_SYMBOL_GPL(wmi_set_block);
> 
> -static void wmi_dump_wdg(struct guid_block *g)
> +static void wmi_dump_wdg(const struct guid_block *g)
>  {
>  	char guid_string[37];
> 
> @@ -824,7 +824,7 @@ static acpi_status parse_wdg(acpi_handle handle)
>  {
>  	struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
>  	union acpi_object *obj;
> -	struct guid_block *gblock;
> +	const struct guid_block *gblock;
>  	struct wmi_block *wblock;
>  	char guid_string[37];
>  	acpi_status status;
> @@ -844,14 +844,9 @@ static acpi_status parse_wdg(acpi_handle handle)
>  		goto out_free_pointer;
>  	}
> 
> +	gblock = (const struct guid_block *)obj->buffer.pointer;
>  	total = obj->buffer.length / sizeof(struct guid_block);
> 
> -	gblock = kmemdup(obj->buffer.pointer, obj->buffer.length, GFP_KERNEL);
> -	if (!gblock) {
> -		status = AE_NO_MEMORY;
> -		goto out_free_pointer;
> -	}
> -
>  	for (i = 0; i < total; i++) {
>  		/*
>  		  Some WMI devices, like those for nVidia hooks, have a
> @@ -872,7 +867,7 @@ static acpi_status parse_wdg(acpi_handle handle)
>  		wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
>  		if (!wblock) {
>  			status = AE_NO_MEMORY;
> -			goto out_free_gblock;
> +			goto out_free_pointer;
>  		}
> 
>  		wblock->gblock = gblock[i];
> @@ -884,8 +879,6 @@ static acpi_status parse_wdg(acpi_handle handle)
>  		list_add_tail(&wblock->list, &wmi_blocks.list);
>  	}
> 
> -out_free_gblock:
> -	kfree(gblock);
>  out_free_pointer:
>  	kfree(out.pointer);
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe
> platform-driver-x86" in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

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

* Re: [PATCH 07/10] WMI: use separate list head for storing wmi blocks
  2010-08-26  7:15 ` [PATCH 07/10] WMI: use separate list head for storing wmi blocks Dmitry Torokhov
@ 2010-09-12 17:40   ` Carlos Corbacho
  0 siblings, 0 replies; 21+ messages in thread
From: Carlos Corbacho @ 2010-09-12 17:40 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Matthew Garrett, platform-driver-x86

On Thursday 26 August 2010 08:15:14 Dmitry Torokhov wrote:
> Do not abuse wmi_block structure to hold the head of list
> of blocks, use separate list_head for that.
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk>

> ---
> 
>  drivers/platform/x86/wmi.c |   20 +++++++++-----------
>  1 files changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index e9064fb..7b68dce 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -47,6 +47,7 @@ MODULE_LICENSE("GPL");
>  #define PREFIX "ACPI: WMI: "
> 
>  static DEFINE_MUTEX(wmi_data_lock);
> +static LIST_HEAD(wmi_block_list);
> 
>  struct guid_block {
>  	char guid[16];
> @@ -70,7 +71,6 @@ struct wmi_block {
>  	struct device *dev;
>  };
> 
> -static struct wmi_block wmi_blocks;
> 
>  /*
>   * If the GUID data block is marked as expensive, we must enable and
> @@ -246,7 +246,7 @@ static bool find_guid(const char *guid_string, struct
> wmi_block **out) wmi_parse_guid(guid_string, tmp);
>  	wmi_swap_bytes(tmp, guid_input);
> 
> -	list_for_each(p, &wmi_blocks.list) {
> +	list_for_each(p, &wmi_block_list) {
>  		wblock = list_entry(p, struct wmi_block, list);
>  		block = &wblock->gblock;
> 
> @@ -633,7 +633,7 @@ acpi_status wmi_get_event_data(u32 event, struct
> acpi_buffer *out) params[0].type = ACPI_TYPE_INTEGER;
>  	params[0].integer.value = event;
> 
> -	list_for_each(p, &wmi_blocks.list) {
> +	list_for_each(p, &wmi_block_list) {
>  		wblock = list_entry(p, struct wmi_block, list);
>  		gblock = &wblock->gblock;
> 
> @@ -721,7 +721,7 @@ static int wmi_create_devs(void)
>  	struct device *guid_dev;
> 
>  	/* Create devices for all the GUIDs */
> -	list_for_each(p, &wmi_blocks.list) {
> +	list_for_each(p, &wmi_block_list) {
>  		wblock = list_entry(p, struct wmi_block, list);
> 
>  		guid_dev = kzalloc(sizeof(struct device), GFP_KERNEL);
> @@ -758,7 +758,7 @@ static void wmi_remove_devs(void)
>  	struct device *guid_dev;
> 
>  	/* Delete devices for all the GUIDs */
> -	list_for_each(p, &wmi_blocks.list) {
> +	list_for_each(p, &wmi_block_list) {
>  		wblock = list_entry(p, struct wmi_block, list);
> 
>  		guid_dev = wblock->dev;
> @@ -797,7 +797,7 @@ static bool guid_already_parsed(const char
> *guid_string) struct wmi_block *wblock;
>  	struct list_head *p;
> 
> -	list_for_each(p, &wmi_blocks.list) {
> +	list_for_each(p, &wmi_block_list) {
>  		wblock = list_entry(p, struct wmi_block, list);
>  		gblock = &wblock->gblock;
> 
> @@ -811,7 +811,7 @@ static void free_wmi_blocks(void)
>  {
>  	struct wmi_block *wblock, *next;
> 
> -	list_for_each_entry_safe(wblock, next, &wmi_blocks.list, list) {
> +	list_for_each_entry_safe(wblock, next, &wmi_block_list, list) {
>  		list_del(&wblock->list);
>  		kfree(wblock);
>  	}
> @@ -876,7 +876,7 @@ static acpi_status parse_wdg(acpi_handle handle)
>  			wblock->handler = wmi_notify_debug;
>  			wmi_method_enable(wblock, 1);
>  		}
> -		list_add_tail(&wblock->list, &wmi_blocks.list);
> +		list_add_tail(&wblock->list, &wmi_block_list);
>  	}
> 
>  out_free_pointer:
> @@ -939,7 +939,7 @@ static void acpi_wmi_notify(struct acpi_device *device,
> u32 event) struct list_head *p;
>  	char guid_string[37];
> 
> -	list_for_each(p, &wmi_blocks.list) {
> +	list_for_each(p, &wmi_block_list) {
>  		wblock = list_entry(p, struct wmi_block, list);
>  		block = &wblock->gblock;
> 
> @@ -999,8 +999,6 @@ static int __init acpi_wmi_init(void)
>  {
>  	int result;
> 
> -	INIT_LIST_HEAD(&wmi_blocks.list);
> -
>  	if (acpi_disabled)
>  		return -ENODEV;

-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

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

* Re: [PATCH 08/10] WMI: use pr_err() and friends
  2010-08-26  7:15 ` [PATCH 08/10] WMI: use pr_err() and friends Dmitry Torokhov
@ 2010-09-12 17:42   ` Carlos Corbacho
  0 siblings, 0 replies; 21+ messages in thread
From: Carlos Corbacho @ 2010-09-12 17:42 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Matthew Garrett, platform-driver-x86

On Thursday 26 August 2010 08:15:19 Dmitry Torokhov wrote:
> This makes source more concise and easier to read.
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk>

> ---
> 
>  drivers/platform/x86/wmi.c |   64
> ++++++++++++++++++++------------------------ 1 files changed, 29
> insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index 7b68dce..b4e5bea 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -27,6 +27,8 @@
>   *
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> */
> 
> +#define pr_fmt(fmt)	KBUILD_MODNAME ": " fmt
> +
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/types.h>
> @@ -44,8 +46,6 @@ MODULE_LICENSE("GPL");
> 
>  #define ACPI_WMI_CLASS "wmi"
> 
> -#define PREFIX "ACPI: WMI: "
> -
>  static DEFINE_MUTEX(wmi_data_lock);
>  static LIST_HEAD(wmi_block_list);
> 
> @@ -492,25 +492,24 @@ static void wmi_dump_wdg(const struct guid_block *g)
>  	char guid_string[37];
> 
>  	wmi_gtoa(g->guid, guid_string);
> -	printk(KERN_INFO PREFIX "%s:\n", guid_string);
> -	printk(KERN_INFO PREFIX "\tobject_id: %c%c\n",
> -	       g->object_id[0], g->object_id[1]);
> -	printk(KERN_INFO PREFIX "\tnotify_id: %02X\n", g->notify_id);
> -	printk(KERN_INFO PREFIX "\treserved: %02X\n", g->reserved);
> -	printk(KERN_INFO PREFIX "\tinstance_count: %d\n", g->instance_count);
> -	printk(KERN_INFO PREFIX "\tflags: %#x", g->flags);
> +
> +	pr_info("%s:\n", guid_string);
> +	pr_info("\tobject_id: %c%c\n", g->object_id[0], g->object_id[1]);
> +	pr_info("\tnotify_id: %02X\n", g->notify_id);
> +	pr_info("\treserved: %02X\n", g->reserved);
> +	pr_info("\tinstance_count: %d\n", g->instance_count);
> +	pr_info("\tflags: %#x ", g->flags);
>  	if (g->flags) {
> -		printk(" ");
>  		if (g->flags & ACPI_WMI_EXPENSIVE)
> -			printk("ACPI_WMI_EXPENSIVE ");
> +			pr_cont("ACPI_WMI_EXPENSIVE ");
>  		if (g->flags & ACPI_WMI_METHOD)
> -			printk("ACPI_WMI_METHOD ");
> +			pr_cont("ACPI_WMI_METHOD ");
>  		if (g->flags & ACPI_WMI_STRING)
> -			printk("ACPI_WMI_STRING ");
> +			pr_cont("ACPI_WMI_STRING ");
>  		if (g->flags & ACPI_WMI_EVENT)
> -			printk("ACPI_WMI_EVENT ");
> +			pr_cont("ACPI_WMI_EVENT ");
>  	}
> -	printk("\n");
> +	pr_cont("\n");
> 
>  }
> 
> @@ -522,7 +521,7 @@ static void wmi_notify_debug(u32 value, void *context)
> 
>  	status = wmi_get_event_data(value, &response);
>  	if (status != AE_OK) {
> -		printk(KERN_INFO "wmi: bad event status 0x%x\n", status);
> +		pr_info("bad event status 0x%x\n", status);
>  		return;
>  	}
> 
> @@ -531,22 +530,22 @@ static void wmi_notify_debug(u32 value, void
> *context) if (!obj)
>  		return;
> 
> -	printk(KERN_INFO PREFIX "DEBUG Event ");
> +	pr_info("DEBUG Event ");
>  	switch(obj->type) {
>  	case ACPI_TYPE_BUFFER:
> -		printk("BUFFER_TYPE - length %d\n", obj->buffer.length);
> +		pr_cont("BUFFER_TYPE - length %d\n", obj->buffer.length);
>  		break;
>  	case ACPI_TYPE_STRING:
> -		printk("STRING_TYPE - %s\n", obj->string.pointer);
> +		pr_cont("STRING_TYPE - %s\n", obj->string.pointer);
>  		break;
>  	case ACPI_TYPE_INTEGER:
> -		printk("INTEGER_TYPE - %llu\n", obj->integer.value);
> +		pr_cont("INTEGER_TYPE - %llu\n", obj->integer.value);
>  		break;
>  	case ACPI_TYPE_PACKAGE:
> -		printk("PACKAGE_TYPE - %d elements\n", obj->package.count);
> +		pr_cont("PACKAGE_TYPE - %d elements\n", obj->package.count);
>  		break;
>  	default:
> -		printk("object type 0x%X\n", obj->type);
> +		pr_cont("object type 0x%X\n", obj->type);
>  	}
>  	kfree(obj);
>  }
> @@ -857,8 +856,7 @@ static acpi_status parse_wdg(acpi_handle handle)
>  		*/
>  		if (guid_already_parsed(gblock[i].guid) == true) {
>  			wmi_gtoa(gblock[i].guid, guid_string);
> -			printk(KERN_INFO PREFIX "Skipping duplicate GUID %s\n",
> -				guid_string);
> +			pr_info("Skipping duplicate GUID %s\n", guid_string);
>  			continue;
>  		}
>  		if (debug_dump_wdg)
> @@ -949,8 +947,7 @@ static void acpi_wmi_notify(struct acpi_device *device,
> u32 event) wblock->handler(event, wblock->handler_data);
>  			if (debug_event) {
>  				wmi_gtoa(wblock->gblock.guid, guid_string);
> -				printk(KERN_INFO PREFIX "DEBUG Event GUID:"
> -				       " %s\n", guid_string);
> +				pr_info("DEBUG Event GUID: %s\n", guid_string);
>  			}
> 
>  			acpi_bus_generate_netlink_event(
> @@ -979,7 +976,7 @@ static int acpi_wmi_add(struct acpi_device *device)
>  						    &acpi_wmi_ec_space_handler,
>  						    NULL, NULL);
>  	if (ACPI_FAILURE(status)) {
> -		printk(KERN_ERR PREFIX "Error installing EC region handler\n");
> +		pr_err("Error installing EC region handler\n");
>  		return -ENODEV;
>  	}
> 
> @@ -988,7 +985,7 @@ static int acpi_wmi_add(struct acpi_device *device)
>  		acpi_remove_address_space_handler(device->handle,
>  						  ACPI_ADR_SPACE_EC,
>  						  &acpi_wmi_ec_space_handler);
> -		printk(KERN_ERR PREFIX "Failed to parse WDG method\n");
> +		pr_err("Failed to parse WDG method\n");
>  		return -ENODEV;
>  	}
> 
> @@ -1003,9 +1000,8 @@ static int __init acpi_wmi_init(void)
>  		return -ENODEV;
> 
>  	result = acpi_bus_register_driver(&acpi_wmi_driver);
> -
>  	if (result < 0) {
> -		printk(KERN_INFO PREFIX "Error loading mapper\n");
> +		pr_err("Error loading mapper\n");
>  		return -ENODEV;
>  	}
> 
> @@ -1015,20 +1011,18 @@ static int __init acpi_wmi_init(void)
>  		return result;
>  	}
> 
> -	printk(KERN_INFO PREFIX "Mapper loaded\n");
> +	pr_info("Mapper loaded\n");
> 
> -	return result;
> +	return 0;
>  }
> 
>  static void __exit acpi_wmi_exit(void)
>  {
>  	wmi_class_exit();
> -
>  	acpi_bus_unregister_driver(&acpi_wmi_driver);
> -
>  	free_wmi_blocks();
> 
> -	printk(KERN_INFO PREFIX "Mapper unloaded\n");
> +	pr_info("Mapper unloaded\n");
>  }
> 
>  subsys_initcall(acpi_wmi_init);
> 
> --
> To unsubscribe from this list: send the line "unsubscribe
> platform-driver-x86" in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

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

* Re: [PATCH 09/10] WMI: make use of class device's attributres
  2010-08-26  7:15 ` [PATCH 09/10] WMI: make use of class device's attributres Dmitry Torokhov
@ 2010-09-12 17:50   ` Carlos Corbacho
  0 siblings, 0 replies; 21+ messages in thread
From: Carlos Corbacho @ 2010-09-12 17:50 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Matthew Garrett, platform-driver-x86

On Thursday 26 August 2010 08:15:25 Dmitry Torokhov wrote:
> Instead of adding modalias attribute manually set it up as class's
> device attribute so driver core will create and remove it for us.
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk>

> ---
> 
>  drivers/platform/x86/wmi.c |   15 +++++++--------
>  1 files changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index b4e5bea..781321b 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -661,7 +661,7 @@ EXPORT_SYMBOL_GPL(wmi_has_guid);
>  /*
>   * sysfs interface
>   */
> -static ssize_t show_modalias(struct device *dev, struct device_attribute
> *attr, +static ssize_t modalias_show(struct device *dev, struct
> device_attribute *attr, char *buf)
>  {
>  	char guid_string[37];
> @@ -675,7 +675,11 @@ static ssize_t show_modalias(struct device *dev,
> struct device_attribute *attr,
> 
>  	return sprintf(buf, "wmi:%s\n", guid_string);
>  }
> -static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
> +
> +static struct device_attribute wmi_dev_attrs[] = {
> +	__ATTR_RO(modalias),
> +	__ATTR_NULL
> +};
> 
>  static int wmi_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
>  {
> @@ -708,6 +712,7 @@ static struct class wmi_class = {
>  	.name = "wmi",
>  	.dev_release = wmi_dev_free,
>  	.dev_uevent = wmi_dev_uevent,
> +	.dev_attrs = wmi_dev_attrs,
>  };
> 
>  static int wmi_create_devs(void)
> @@ -740,10 +745,6 @@ static int wmi_create_devs(void)
>  		result = device_register(guid_dev);
>  		if (result)
>  			return result;
> -
> -		result = device_create_file(guid_dev, &dev_attr_modalias);
> -		if (result)
> -			return result;
>  	}
> 
>  	return 0;
> @@ -763,8 +764,6 @@ static void wmi_remove_devs(void)
>  		guid_dev = wblock->dev;
>  		gblock = &wblock->gblock;
> 
> -		device_remove_file(guid_dev, &dev_attr_modalias);
> -
>  		device_unregister(guid_dev);
>  	}
>  }
> 
> --
> To unsubscribe from this list: send the line "unsubscribe
> platform-driver-x86" in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

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

* Re: [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails
  2010-09-12 17:14 ` Carlos Corbacho
@ 2010-10-01 17:00   ` Dmitry Torokhov
  0 siblings, 0 replies; 21+ messages in thread
From: Dmitry Torokhov @ 2010-10-01 17:00 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: platform-driver-x86, Carlos Corbacho

On Sun, Sep 12, 2010 at 06:14:36PM +0100, Carlos Corbacho wrote:
> On Thursday 26 August 2010 08:14:42 Dmitry Torokhov wrote:
> > Driver initialization was forgetting to remove EC address space handler
> > in cases when parse_wdg() method failed.
> > 
> > Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> 
> Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk>
> 

Matthew,

Do you need me to resend the series with Carlos's acks?

Thanks.

-- 
Dmitry

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

end of thread, other threads:[~2010-10-01 17:00 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-26  7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
2010-08-26  7:14 ` [PATCH 02/10] WMI: free wmi blocks when parse_wdg() fails Dmitry Torokhov
2010-09-12 17:19   ` Carlos Corbacho
2010-08-26  7:14 ` [PATCH 03/10] WMI: fix wmi_gtoa() to actully terminate the string Dmitry Torokhov
2010-09-12 17:28   ` Carlos Corbacho
2010-08-26  7:14 ` [PATCH 04/10] WMI: do not leak memory in parse_wdg() Dmitry Torokhov
2010-09-12 17:29   ` Carlos Corbacho
2010-08-26  7:15 ` [PATCH 05/10] WMI: fix potential NULL pointer dereference Dmitry Torokhov
2010-09-12 17:30   ` Carlos Corbacho
2010-08-26  7:15 ` [PATCH 06/10] WMI: simplify handling of returned WMI blocks in parse_wdg() Dmitry Torokhov
2010-09-12 17:39   ` Carlos Corbacho
2010-08-26  7:15 ` [PATCH 07/10] WMI: use separate list head for storing wmi blocks Dmitry Torokhov
2010-09-12 17:40   ` Carlos Corbacho
2010-08-26  7:15 ` [PATCH 08/10] WMI: use pr_err() and friends Dmitry Torokhov
2010-09-12 17:42   ` Carlos Corbacho
2010-08-26  7:15 ` [PATCH 09/10] WMI: make use of class device's attributres Dmitry Torokhov
2010-09-12 17:50   ` Carlos Corbacho
2010-08-26  7:15 ` [PATCH 10/10] WMI: embed struct device directly into wmi_block Dmitry Torokhov
2010-09-12  7:29 ` [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
2010-09-12 17:14 ` Carlos Corbacho
2010-10-01 17:00   ` Dmitry Torokhov

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.