Re: [PATCH] acer-wmi: add error checks in module_init

Previous thread: [PATCH] x86: check for ioremap() failure in copy_oldmem_page() by Akinobu Mita on Sunday, September 21, 2008 - 7:27 am. (3 messages)

Next thread: [PATCH] tc1100-wmi: add error checks in module_init by Akinobu Mita on Sunday, September 21, 2008 - 7:35 am. (1 message)
From: Akinobu Mita
Date: Sunday, September 21, 2008 - 7:29 am

There are sevaral bugs in module_init and module_exit for acer-wmi.

- No error handlings for platform_device_alloc() and platform_device_add()

- acer_platform_device is not freeed in module_exit

This patch fixes these bugs by using platform_device_register_simple()
and platform_device_unregister() respectively.

This patch also makes create_sysfs() take a argument struct
platform_device pointer so that it looks symmetrical to remove_sysfs().

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>
---
 drivers/misc/acer-wmi.c |   48 +++++++++++++++++++++++++++---------------------
 1 file changed, 27 insertions(+), 21 deletions(-)

Index: 2.6-git/drivers/misc/acer-wmi.c
===================================================================
--- 2.6-git.orig/drivers/misc/acer-wmi.c
+++ 2.6-git/drivers/misc/acer-wmi.c
@@ -1129,40 +1129,36 @@ static int remove_sysfs(struct platform_
 	return 0;
 }
 
-static int create_sysfs(void)
+static int create_sysfs(struct platform_device *device)
 {
 	int retval = -ENOMEM;
 
 	if (has_cap(ACER_CAP_WIRELESS)) {
-		retval = device_create_file(&acer_platform_device->dev,
-			&dev_attr_wireless);
+		retval = device_create_file(&device->dev, &dev_attr_wireless);
 		if (retval)
 			goto error_sysfs;
 	}
 
 	if (has_cap(ACER_CAP_BLUETOOTH)) {
-		retval = device_create_file(&acer_platform_device->dev,
-			&dev_attr_bluetooth);
+		retval = device_create_file(&device->dev, &dev_attr_bluetooth);
 		if (retval)
 			goto error_sysfs;
 	}
 
 	if (has_cap(ACER_CAP_THREEG)) {
-		retval = device_create_file(&acer_platform_device->dev,
-			&dev_attr_threeg);
+		retval = device_create_file(&device->dev, &dev_attr_threeg);
 		if (retval)
 			goto error_sysfs;
 	}
 
-	retval = device_create_file(&acer_platform_device->dev,
-		&dev_attr_interface);
+	retval = device_create_file(&device->dev, &dev_attr_interface);
 	if (retval)
 		goto error_sysfs;
 
 	return 0;
 
 ...
From: Carlos Corbacho
Date: Sunday, September 21, 2008 - 10:52 am

[Adding Greg KH to CC]

Last I heard, platform_device_register_simple() was in the process of being 
deprecated and then slated for future removal. Has this changed?

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

Previous thread: [PATCH] x86: check for ioremap() failure in copy_oldmem_page() by Akinobu Mita on Sunday, September 21, 2008 - 7:27 am. (3 messages)

Next thread: [PATCH] tc1100-wmi: add error checks in module_init by Akinobu Mita on Sunday, September 21, 2008 - 7:35 am. (1 message)