From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Axel Lin <axel.lin@gmail.com>, Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 08/11] firmware: gsmi: remove sysfs entries when unload the module
Date: Tue, 26 Jul 2011 21:05:18 -0700 [thread overview]
Message-ID: <1311739521-11014-8-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <1311739521-11014-1-git-send-email-gregkh@suse.de>
From: Axel Lin <axel.lin@gmail.com>
This patch removes sysfs entries in gsmi_exit() and gsmi_init() error path.
Also move the driver successfully loaded message to the end of gsmi_init()
and return proper error if register_efivars() fails.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/firmware/google/gsmi.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index fa7f0b3..68810fd 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -869,8 +869,6 @@ static __init int gsmi_init(void)
goto out_err;
}
- printk(KERN_INFO "gsmi version " DRIVER_VERSION " loaded\n");
-
/* Register in the firmware directory */
ret = -ENOMEM;
gsmi_kobj = kobject_create_and_add("gsmi", firmware_kobj);
@@ -890,12 +888,13 @@ static __init int gsmi_init(void)
ret = sysfs_create_files(gsmi_kobj, gsmi_attrs);
if (ret) {
printk(KERN_INFO "gsmi: Failed to add attrs");
- goto out_err;
+ goto out_remove_bin_file;
}
- if (register_efivars(&efivars, &efivar_ops, gsmi_kobj)) {
+ ret = register_efivars(&efivars, &efivar_ops, gsmi_kobj);
+ if (ret) {
printk(KERN_INFO "gsmi: Failed to register efivars\n");
- goto out_err;
+ goto out_remove_sysfs_files;
}
register_reboot_notifier(&gsmi_reboot_notifier);
@@ -903,9 +902,15 @@ static __init int gsmi_init(void)
atomic_notifier_chain_register(&panic_notifier_list,
&gsmi_panic_notifier);
+ printk(KERN_INFO "gsmi version " DRIVER_VERSION " loaded\n");
+
return 0;
- out_err:
+out_remove_sysfs_files:
+ sysfs_remove_files(gsmi_kobj, gsmi_attrs);
+out_remove_bin_file:
+ sysfs_remove_bin_file(gsmi_kobj, &eventlog_bin_attr);
+out_err:
kobject_put(gsmi_kobj);
gsmi_buf_free(gsmi_dev.param_buf);
gsmi_buf_free(gsmi_dev.data_buf);
@@ -925,6 +930,8 @@ static void __exit gsmi_exit(void)
&gsmi_panic_notifier);
unregister_efivars(&efivars);
+ sysfs_remove_files(gsmi_kobj, gsmi_attrs);
+ sysfs_remove_bin_file(gsmi_kobj, &eventlog_bin_attr);
kobject_put(gsmi_kobj);
gsmi_buf_free(gsmi_dev.param_buf);
gsmi_buf_free(gsmi_dev.data_buf);
--
1.7.6
next prev parent reply other threads:[~2011-07-27 4:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-26 4:57 [GIT PATCH] driver core merge for 3.1 Greg KH
2011-07-27 4:05 ` [PATCH 01/11] pti: pti_tty_install documentation mispelling Greg Kroah-Hartman
2011-07-27 4:05 ` [PATCH 02/11] DOCUMENTATION: Update overview.txt in Doc/driver-model Greg Kroah-Hartman
2011-07-27 4:05 ` [PATCH 03/11] DOCUMENTATION: Replace create_device() with device_create() Greg Kroah-Hartman
2011-07-27 4:05 ` [PATCH 04/11] driver-core: Kconfig grammar corrections in firmware configuration Greg Kroah-Hartman
2011-07-27 4:05 ` [PATCH 05/11] driver-core: modify FIRMWARE_IN_KERNEL help message Greg Kroah-Hartman
2011-07-27 4:05 ` [PATCH 06/11] driver core: add more help description for "path to uevent helper" Greg Kroah-Hartman
2011-07-27 4:05 ` [PATCH 07/11] Documentation/zh_CN: Fix messy code file email-clients.txt Greg Kroah-Hartman
2011-07-27 4:05 ` Greg Kroah-Hartman [this message]
2011-07-27 4:05 ` [PATCH 09/11] uio: uio_pdrv_genirq: Add OF support Greg Kroah-Hartman
2011-07-27 8:17 ` Hans J. Koch
2011-07-27 4:05 ` [PATCH 10/11] debugfs: add documentation for debugfs_create_x64 Greg Kroah-Hartman
2011-07-27 4:05 ` [PATCH 11/11] updated Documentation/ja_JP/SubmittingPatches Greg Kroah-Hartman
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=1311739521-11014-8-git-send-email-gregkh@suse.de \
--to=gregkh@suse.de \
--cc=axel.lin@gmail.com \
--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
Powered by JetHome