aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2011-06-29 03:57:53 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-07-01 18:17:16 -0400
commit1e4de81653bae3f5e6d06e3384853d31d564bbec (patch)
treed33b0c0f33180db07e4f452149022ba2b60efd0e /drivers/firmware
parent48d9854285635dd8b0535af7cb0d508b08db9e98 (diff)
firmware: gsmi: remove sysfs entries when unload the module
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>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/google/gsmi.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index fa7f0b3e81dd..68810fd1a59d 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -869,8 +869,6 @@ static __init int gsmi_init(void)
869 goto out_err; 869 goto out_err;
870 } 870 }
871 871
872 printk(KERN_INFO "gsmi version " DRIVER_VERSION " loaded\n");
873
874 /* Register in the firmware directory */ 872 /* Register in the firmware directory */
875 ret = -ENOMEM; 873 ret = -ENOMEM;
876 gsmi_kobj = kobject_create_and_add("gsmi", firmware_kobj); 874 gsmi_kobj = kobject_create_and_add("gsmi", firmware_kobj);
@@ -890,12 +888,13 @@ static __init int gsmi_init(void)
890 ret = sysfs_create_files(gsmi_kobj, gsmi_attrs); 888 ret = sysfs_create_files(gsmi_kobj, gsmi_attrs);
891 if (ret) { 889 if (ret) {
892 printk(KERN_INFO "gsmi: Failed to add attrs"); 890 printk(KERN_INFO "gsmi: Failed to add attrs");
893 goto out_err; 891 goto out_remove_bin_file;
894 } 892 }
895 893
896 if (register_efivars(&efivars, &efivar_ops, gsmi_kobj)) { 894 ret = register_efivars(&efivars, &efivar_ops, gsmi_kobj);
895 if (ret) {
897 printk(KERN_INFO "gsmi: Failed to register efivars\n"); 896 printk(KERN_INFO "gsmi: Failed to register efivars\n");
898 goto out_err; 897 goto out_remove_sysfs_files;
899 } 898 }
900 899
901 register_reboot_notifier(&gsmi_reboot_notifier); 900 register_reboot_notifier(&gsmi_reboot_notifier);
@@ -903,9 +902,15 @@ static __init int gsmi_init(void)
903 atomic_notifier_chain_register(&panic_notifier_list, 902 atomic_notifier_chain_register(&panic_notifier_list,
904 &gsmi_panic_notifier); 903 &gsmi_panic_notifier);
905 904
905 printk(KERN_INFO "gsmi version " DRIVER_VERSION " loaded\n");
906
906 return 0; 907 return 0;
907 908
908 out_err: 909out_remove_sysfs_files:
910 sysfs_remove_files(gsmi_kobj, gsmi_attrs);
911out_remove_bin_file:
912 sysfs_remove_bin_file(gsmi_kobj, &eventlog_bin_attr);
913out_err:
909 kobject_put(gsmi_kobj); 914 kobject_put(gsmi_kobj);
910 gsmi_buf_free(gsmi_dev.param_buf); 915 gsmi_buf_free(gsmi_dev.param_buf);
911 gsmi_buf_free(gsmi_dev.data_buf); 916 gsmi_buf_free(gsmi_dev.data_buf);
@@ -925,6 +930,8 @@ static void __exit gsmi_exit(void)
925 &gsmi_panic_notifier); 930 &gsmi_panic_notifier);
926 unregister_efivars(&efivars); 931 unregister_efivars(&efivars);
927 932
933 sysfs_remove_files(gsmi_kobj, gsmi_attrs);
934 sysfs_remove_bin_file(gsmi_kobj, &eventlog_bin_attr);
928 kobject_put(gsmi_kobj); 935 kobject_put(gsmi_kobj);
929 gsmi_buf_free(gsmi_dev.param_buf); 936 gsmi_buf_free(gsmi_dev.param_buf);
930 gsmi_buf_free(gsmi_dev.data_buf); 937 gsmi_buf_free(gsmi_dev.data_buf);