aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-07-31 04:46:02 -0400
committerLen Brown <len.brown@intel.com>2009-08-28 15:17:08 -0400
commit72afeeafe54853881a4e53dc78d538e249130ad8 (patch)
treef31f9be2ed7856762b7c763f9c00aabc9b69f6b2 /drivers/platform
parent67059406219d30a36b7ca93f863eb1f3032f05ce (diff)
fujitsu-laptop: driver [un]registration fixes
* Move led_classdev_unregister() calls from fujitsu_cleanup() to acpi_fujitsu_hotkey_remove(). * Fix ordering in fujitsu_cleanup(). * Fix backlight_device_register() failure handling in fujitsu_init(). * Add missing sysfs group removal on failure to fujitsu_init(). * Add input device unregistering on failure to acpi_fujitsu_add() and acpi_fujitsu_hotkey_add(). * Add input device unregistering/freeing to acpi_fujitsu_remove() and acpi_fujitsu_hotkey_remove() (also remove superfluous 'device' and 'acpi_driver_data(device)' checks while at it). * Do few minor cleanups. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Acked-by: Jonathan Woithe <jwoithe@physics.adelaide.edu.au> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c86
1 files changed, 41 insertions, 45 deletions
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index f9e3e3afca13..b87a5a2084a9 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -691,7 +691,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
691 result = acpi_bus_get_power(fujitsu->acpi_handle, &state); 691 result = acpi_bus_get_power(fujitsu->acpi_handle, &state);
692 if (result) { 692 if (result) {
693 printk(KERN_ERR "Error reading power state\n"); 693 printk(KERN_ERR "Error reading power state\n");
694 goto end; 694 goto err_unregister_input_dev;
695 } 695 }
696 696
697 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", 697 printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
@@ -722,22 +722,22 @@ static int acpi_fujitsu_add(struct acpi_device *device)
722 722
723 return result; 723 return result;
724 724
725end: 725err_unregister_input_dev:
726 input_unregister_device(input);
726err_free_input_dev: 727err_free_input_dev:
727 input_free_device(input); 728 input_free_device(input);
728err_stop: 729err_stop:
729
730 return result; 730 return result;
731} 731}
732 732
733static int acpi_fujitsu_remove(struct acpi_device *device, int type) 733static int acpi_fujitsu_remove(struct acpi_device *device, int type)
734{ 734{
735 struct fujitsu_t *fujitsu = NULL; 735 struct fujitsu_t *fujitsu = acpi_driver_data(device);
736 struct input_dev *input = fujitsu->input;
736 737
737 if (!device || !acpi_driver_data(device)) 738 input_unregister_device(input);
738 return -EINVAL;
739 739
740 fujitsu = acpi_driver_data(device); 740 input_free_device(input);
741 741
742 fujitsu->acpi_handle = NULL; 742 fujitsu->acpi_handle = NULL;
743 743
@@ -862,7 +862,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
862 result = acpi_bus_get_power(fujitsu_hotkey->acpi_handle, &state); 862 result = acpi_bus_get_power(fujitsu_hotkey->acpi_handle, &state);
863 if (result) { 863 if (result) {
864 printk(KERN_ERR "Error reading power state\n"); 864 printk(KERN_ERR "Error reading power state\n");
865 goto end; 865 goto err_unregister_input_dev;
866 } 866 }
867 867
868 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", 868 printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
@@ -902,7 +902,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
902 printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n", 902 printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n",
903 call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0)); 903 call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0));
904 904
905 #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) 905#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
906 if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) { 906 if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) {
907 result = led_classdev_register(&fujitsu->pf_device->dev, 907 result = led_classdev_register(&fujitsu->pf_device->dev,
908 &logolamp_led); 908 &logolamp_led);
@@ -925,33 +925,41 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
925 "LED handler for keyboard lamps, error %i\n", result); 925 "LED handler for keyboard lamps, error %i\n", result);
926 } 926 }
927 } 927 }
928 #endif 928#endif
929 929
930 return result; 930 return result;
931 931
932end: 932err_unregister_input_dev:
933 input_unregister_device(input);
933err_free_input_dev: 934err_free_input_dev:
934 input_free_device(input); 935 input_free_device(input);
935err_free_fifo: 936err_free_fifo:
936 kfifo_free(fujitsu_hotkey->fifo); 937 kfifo_free(fujitsu_hotkey->fifo);
937err_stop: 938err_stop:
938
939 return result; 939 return result;
940} 940}
941 941
942static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type) 942static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type)
943{ 943{
944 struct fujitsu_hotkey_t *fujitsu_hotkey = NULL; 944 struct fujitsu_hotkey_t *fujitsu_hotkey = acpi_driver_data(device);
945 struct input_dev *input = fujitsu_hotkey->input;
945 946
946 if (!device || !acpi_driver_data(device)) 947#ifdef CONFIG_LEDS_CLASS
947 return -EINVAL; 948 if (fujitsu_hotkey->logolamp_registered)
949 led_classdev_unregister(&logolamp_led);
950
951 if (fujitsu_hotkey->kblamps_registered)
952 led_classdev_unregister(&kblamps_led);
953#endif
948 954
949 fujitsu_hotkey = acpi_driver_data(device); 955 input_unregister_device(input);
950 956
951 fujitsu_hotkey->acpi_handle = NULL; 957 input_free_device(input);
952 958
953 kfifo_free(fujitsu_hotkey->fifo); 959 kfifo_free(fujitsu_hotkey->fifo);
954 960
961 fujitsu_hotkey->acpi_handle = NULL;
962
955 return 0; 963 return 0;
956} 964}
957 965
@@ -1121,8 +1129,11 @@ static int __init fujitsu_init(void)
1121 fujitsu->bl_device = 1129 fujitsu->bl_device =
1122 backlight_device_register("fujitsu-laptop", NULL, NULL, 1130 backlight_device_register("fujitsu-laptop", NULL, NULL,
1123 &fujitsubl_ops); 1131 &fujitsubl_ops);
1124 if (IS_ERR(fujitsu->bl_device)) 1132 if (IS_ERR(fujitsu->bl_device)) {
1125 return PTR_ERR(fujitsu->bl_device); 1133 ret = PTR_ERR(fujitsu->bl_device);
1134 fujitsu->bl_device = NULL;
1135 goto fail_sysfs_group;
1136 }
1126 max_brightness = fujitsu->max_brightness; 1137 max_brightness = fujitsu->max_brightness;
1127 fujitsu->bl_device->props.max_brightness = max_brightness - 1; 1138 fujitsu->bl_device->props.max_brightness = max_brightness - 1;
1128 fujitsu->bl_device->props.brightness = fujitsu->brightness_level; 1139 fujitsu->bl_device->props.brightness = fujitsu->brightness_level;
@@ -1162,32 +1173,22 @@ static int __init fujitsu_init(void)
1162 return 0; 1173 return 0;
1163 1174
1164fail_hotkey1: 1175fail_hotkey1:
1165
1166 kfree(fujitsu_hotkey); 1176 kfree(fujitsu_hotkey);
1167
1168fail_hotkey: 1177fail_hotkey:
1169
1170 platform_driver_unregister(&fujitsupf_driver); 1178 platform_driver_unregister(&fujitsupf_driver);
1171
1172fail_backlight: 1179fail_backlight:
1173
1174 if (fujitsu->bl_device) 1180 if (fujitsu->bl_device)
1175 backlight_device_unregister(fujitsu->bl_device); 1181 backlight_device_unregister(fujitsu->bl_device);
1176 1182fail_sysfs_group:
1183 sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
1184 &fujitsupf_attribute_group);
1177fail_platform_device2: 1185fail_platform_device2:
1178
1179 platform_device_del(fujitsu->pf_device); 1186 platform_device_del(fujitsu->pf_device);
1180
1181fail_platform_device1: 1187fail_platform_device1:
1182
1183 platform_device_put(fujitsu->pf_device); 1188 platform_device_put(fujitsu->pf_device);
1184
1185fail_platform_driver: 1189fail_platform_driver:
1186
1187 acpi_bus_unregister_driver(&acpi_fujitsu_driver); 1190 acpi_bus_unregister_driver(&acpi_fujitsu_driver);
1188
1189fail_acpi: 1191fail_acpi:
1190
1191 kfree(fujitsu); 1192 kfree(fujitsu);
1192 1193
1193 return ret; 1194 return ret;
@@ -1195,28 +1196,23 @@ fail_acpi:
1195 1196
1196static void __exit fujitsu_cleanup(void) 1197static void __exit fujitsu_cleanup(void)
1197{ 1198{
1198 #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) 1199 acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver);
1199 if (fujitsu_hotkey->logolamp_registered != 0)
1200 led_classdev_unregister(&logolamp_led);
1201 1200
1202 if (fujitsu_hotkey->kblamps_registered != 0) 1201 kfree(fujitsu_hotkey);
1203 led_classdev_unregister(&kblamps_led);
1204 #endif
1205 1202
1206 sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
1207 &fujitsupf_attribute_group);
1208 platform_device_unregister(fujitsu->pf_device);
1209 platform_driver_unregister(&fujitsupf_driver); 1203 platform_driver_unregister(&fujitsupf_driver);
1204
1210 if (fujitsu->bl_device) 1205 if (fujitsu->bl_device)
1211 backlight_device_unregister(fujitsu->bl_device); 1206 backlight_device_unregister(fujitsu->bl_device);
1212 1207
1213 acpi_bus_unregister_driver(&acpi_fujitsu_driver); 1208 sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
1209 &fujitsupf_attribute_group);
1214 1210
1215 kfree(fujitsu); 1211 platform_device_unregister(fujitsu->pf_device);
1216 1212
1217 acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver); 1213 acpi_bus_unregister_driver(&acpi_fujitsu_driver);
1218 1214
1219 kfree(fujitsu_hotkey); 1215 kfree(fujitsu);
1220 1216
1221 printk(KERN_INFO "fujitsu-laptop: driver unloaded.\n"); 1217 printk(KERN_INFO "fujitsu-laptop: driver unloaded.\n");
1222} 1218}