From: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
To: Michael Hanselmann <linux-kernel@hansmi.ch>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ams: check return values from device_create_file()
Date: Wed, 20 Sep 2006 21:56:47 -0300 [thread overview]
Message-ID: <20060921005647.GC16002@cathedrallabs.org> (raw)
This patch changes ams driver in order to check device_create_file()
return values and simplifies ams_sensor_attach().
Andrew, I've been using this driver for a while (not with -mm, but
applying individual patches on latest -linus daily) and never had
problems.
Signed-off-by: Aristeu S. Rozanski F. <aris@cathedrallabs.org>
--- mm.orig/drivers/hwmon/ams/ams-core.c 2006-09-20 21:04:57.000000000 -0300
+++ mm/drivers/hwmon/ams/ams-core.c 2006-09-20 21:12:46.000000000 -0300
@@ -163,28 +163,37 @@
result = pmf_register_irq_client(ams_info.of_node,
"accel-int-2",
&ams_shock_client);
- if (result < 0) {
- pmf_unregister_irq_client(&ams_freefall_client);
- return -ENODEV;
- }
+ if (result < 0)
+ goto release_freefall;
/* Create device */
ams_info.of_dev = of_platform_device_create(ams_info.of_node, "ams", NULL);
- if (!ams_info.of_dev) {
- pmf_unregister_irq_client(&ams_shock_client);
- pmf_unregister_irq_client(&ams_freefall_client);
- return -ENODEV;
- }
+ if (!ams_info.of_dev)
+ goto release_shock;
/* Create attributes */
- device_create_file(&ams_info.of_dev->dev, &dev_attr_current);
+ result = device_create_file(&ams_info.of_dev->dev, &dev_attr_current);
+ if (result)
+ goto release_of;
ams_info.vflag = !!(ams_info.get_vendor() & 0x10);
/* Init mouse device */
- ams_mouse_init();
-
- return 0;
+ result = ams_mouse_init();
+ if (result)
+ goto release_device_file;
+
+out:
+ return result;
+release_device_file:
+ device_remove_file(&ams_info.of_dev->dev, &dev_attr_current);
+release_of:
+ of_device_unregister(ams_info.of_dev);
+release_shock:
+ pmf_unregister_irq_client(&ams_freefall_client);
+release_freefall:
+ pmf_unregister_irq_client(&ams_freefall_client);
+ goto out;
}
int __init ams_init(void)
--- mm.orig/drivers/hwmon/ams/ams-mouse.c 2006-09-20 21:07:26.000000000 -0300
+++ mm/drivers/hwmon/ams/ams-mouse.c 2006-09-20 21:08:50.000000000 -0300
@@ -127,12 +127,15 @@
ams_mouse_show_mouse, ams_mouse_store_mouse);
/* Call with ams_info.lock held! */
-void ams_mouse_init()
+int ams_mouse_init(void)
{
- device_create_file(&ams_info.of_dev->dev, &dev_attr_mouse);
+ int result;
- if (mouse)
+ result = device_create_file(&ams_info.of_dev->dev, &dev_attr_mouse);
+
+ if (!result && mouse)
ams_mouse_enable();
+ return result;
}
/* Call with ams_info.lock held! */
next reply other threads:[~2006-09-21 0:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-21 0:56 Aristeu Sergio Rozanski Filho [this message]
2006-09-21 6:37 ` [PATCH] ams: check return values from device_create_file() Michael Hanselmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060921005647.GC16002@cathedrallabs.org \
--to=aris@cathedrallabs.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@hansmi.ch \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox