aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2013-12-29 17:47:36 -0500
committerMatthew Garrett <matthew.garrett@nebula.com>2014-01-21 08:44:17 -0500
commitb30bb89f0fb29502f573d01419391a1e2a4cc4f1 (patch)
tree7698fd123c24738df516325564cadca74997e559 /drivers/platform
parent97f440c23f2b02fac8af0558cba9ca0bed603794 (diff)
fujitsu-laptop: fix error return code
These functions mix the use of result and error. In acpi_fujitsu_add, result does not seem useful; it would seem reasonable to propagate the return value of acpi_bus_update_power in an error case. On the other hand, in the case of acpi_fujitsu_hotkey_add, there is an initialization of result that can lead to what looks like a failure case, but that does not abort the function. The variable result is kept for this case. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when != ret = e1 when != &ret *if(...) { ... when != ret = e2 when forall return ret; } // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 9d30d69aa78f..be02bcc346d3 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -633,7 +633,6 @@ static struct dmi_system_id fujitsu_dmi_table[] = {
633 633
634static int acpi_fujitsu_add(struct acpi_device *device) 634static int acpi_fujitsu_add(struct acpi_device *device)
635{ 635{
636 int result = 0;
637 int state = 0; 636 int state = 0;
638 struct input_dev *input; 637 struct input_dev *input;
639 int error; 638 int error;
@@ -669,8 +668,8 @@ static int acpi_fujitsu_add(struct acpi_device *device)
669 if (error) 668 if (error)
670 goto err_free_input_dev; 669 goto err_free_input_dev;
671 670
672 result = acpi_bus_update_power(fujitsu->acpi_handle, &state); 671 error = acpi_bus_update_power(fujitsu->acpi_handle, &state);
673 if (result) { 672 if (error) {
674 pr_err("Error reading power state\n"); 673 pr_err("Error reading power state\n");
675 goto err_unregister_input_dev; 674 goto err_unregister_input_dev;
676 } 675 }
@@ -700,7 +699,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
700 fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS; 699 fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS;
701 get_lcd_level(); 700 get_lcd_level();
702 701
703 return result; 702 return 0;
704 703
705err_unregister_input_dev: 704err_unregister_input_dev:
706 input_unregister_device(input); 705 input_unregister_device(input);
@@ -708,7 +707,7 @@ err_unregister_input_dev:
708err_free_input_dev: 707err_free_input_dev:
709 input_free_device(input); 708 input_free_device(input);
710err_stop: 709err_stop:
711 return result; 710 return error;
712} 711}
713 712
714static int acpi_fujitsu_remove(struct acpi_device *device) 713static int acpi_fujitsu_remove(struct acpi_device *device)
@@ -831,8 +830,8 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
831 if (error) 830 if (error)
832 goto err_free_input_dev; 831 goto err_free_input_dev;
833 832
834 result = acpi_bus_update_power(fujitsu_hotkey->acpi_handle, &state); 833 error = acpi_bus_update_power(fujitsu_hotkey->acpi_handle, &state);
835 if (result) { 834 if (error) {
836 pr_err("Error reading power state\n"); 835 pr_err("Error reading power state\n");
837 goto err_unregister_input_dev; 836 goto err_unregister_input_dev;
838 } 837 }
@@ -907,7 +906,7 @@ err_free_input_dev:
907err_free_fifo: 906err_free_fifo:
908 kfifo_free(&fujitsu_hotkey->fifo); 907 kfifo_free(&fujitsu_hotkey->fifo);
909err_stop: 908err_stop:
910 return result; 909 return error;
911} 910}
912 911
913static int acpi_fujitsu_hotkey_remove(struct acpi_device *device) 912static int acpi_fujitsu_hotkey_remove(struct acpi_device *device)