All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Woithe <jwoithe@just42.net>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: kernel-janitors@vger.kernel.org,
	Matthew Garrett <matthew.garrett@nebula.com>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, jwoithe@just42.net
Subject: Re: [PATCH 21/25] fujitsu-laptop: fix error return code
Date: Tue, 31 Dec 2013 23:35:12 +1030	[thread overview]
Message-ID: <20131231130512.GB20866@marvin.atrad.com.au> (raw)
In-Reply-To: <1388357260-4843-22-git-send-email-Julia.Lawall@lip6.fr>

On Sun, Dec 29, 2013 at 11:47:36PM +0100, Julia Lawall wrote:
> 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.

Agreed.

> 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.

The handling of result in acpi_fujitsu_hotkey_add() applies to machines
which I don't have physical access to - the code was contributed by others. 
My understanding is that on these machines the failure of the LED class
registration is not necessarily grounds for aborting the function
immediately.  That said, the change made to acpi_fujitsu_hotkey_add() in
this patch look correct to me: the err_stop label should be returning
"error", and consequently the acpi_bus_update_power() return should be saved
to "error".

Acked-off-by: Jonathan Woithe <jwoithe@just42.net>

> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
> Not tested.  Not sure to be doing the right thing with result in the second
> case.
> 
>  drivers/platform/x86/fujitsu-laptop.c |   15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 9d30d69..be02bcc 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[] = {
>  
>  static int acpi_fujitsu_add(struct acpi_device *device)
>  {
> -	int result = 0;
>  	int state = 0;
>  	struct input_dev *input;
>  	int error;
> @@ -669,8 +668,8 @@ static int acpi_fujitsu_add(struct acpi_device *device)
>  	if (error)
>  		goto err_free_input_dev;
>  
> -	result = acpi_bus_update_power(fujitsu->acpi_handle, &state);
> -	if (result) {
> +	error = acpi_bus_update_power(fujitsu->acpi_handle, &state);
> +	if (error) {
>  		pr_err("Error reading power state\n");
>  		goto err_unregister_input_dev;
>  	}
> @@ -700,7 +699,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
>  		fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS;
>  	get_lcd_level();
>  
> -	return result;
> +	return 0;
>  
>  err_unregister_input_dev:
>  	input_unregister_device(input);
> @@ -708,7 +707,7 @@ err_unregister_input_dev:
>  err_free_input_dev:
>  	input_free_device(input);
>  err_stop:
> -	return result;
> +	return error;
>  }
>  
>  static int acpi_fujitsu_remove(struct acpi_device *device)
> @@ -831,8 +830,8 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
>  	if (error)
>  		goto err_free_input_dev;
>  
> -	result = acpi_bus_update_power(fujitsu_hotkey->acpi_handle, &state);
> -	if (result) {
> +	error = acpi_bus_update_power(fujitsu_hotkey->acpi_handle, &state);
> +	if (error) {
>  		pr_err("Error reading power state\n");
>  		goto err_unregister_input_dev;
>  	}
> @@ -907,7 +906,7 @@ err_free_input_dev:
>  err_free_fifo:
>  	kfifo_free(&fujitsu_hotkey->fifo);
>  err_stop:
> -	return result;
> +	return error;
>  }
>  
>  static int acpi_fujitsu_hotkey_remove(struct acpi_device *device)
> 
> --

WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Woithe <jwoithe@just42.net>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: kernel-janitors@vger.kernel.org,
	Matthew Garrett <matthew.garrett@nebula.com>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, jwoithe@just42.net
Subject: Re: [PATCH 21/25] fujitsu-laptop: fix error return code
Date: Tue, 31 Dec 2013 13:17:12 +0000	[thread overview]
Message-ID: <20131231130512.GB20866@marvin.atrad.com.au> (raw)
In-Reply-To: <1388357260-4843-22-git-send-email-Julia.Lawall@lip6.fr>

On Sun, Dec 29, 2013 at 11:47:36PM +0100, Julia Lawall wrote:
> 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.

Agreed.

> 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.

The handling of result in acpi_fujitsu_hotkey_add() applies to machines
which I don't have physical access to - the code was contributed by others. 
My understanding is that on these machines the failure of the LED class
registration is not necessarily grounds for aborting the function
immediately.  That said, the change made to acpi_fujitsu_hotkey_add() in
this patch look correct to me: the err_stop label should be returning
"error", and consequently the acpi_bus_update_power() return should be saved
to "error".

Acked-off-by: Jonathan Woithe <jwoithe@just42.net>

> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
> Not tested.  Not sure to be doing the right thing with result in the second
> case.
> 
>  drivers/platform/x86/fujitsu-laptop.c |   15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 9d30d69..be02bcc 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[] = {
>  
>  static int acpi_fujitsu_add(struct acpi_device *device)
>  {
> -	int result = 0;
>  	int state = 0;
>  	struct input_dev *input;
>  	int error;
> @@ -669,8 +668,8 @@ static int acpi_fujitsu_add(struct acpi_device *device)
>  	if (error)
>  		goto err_free_input_dev;
>  
> -	result = acpi_bus_update_power(fujitsu->acpi_handle, &state);
> -	if (result) {
> +	error = acpi_bus_update_power(fujitsu->acpi_handle, &state);
> +	if (error) {
>  		pr_err("Error reading power state\n");
>  		goto err_unregister_input_dev;
>  	}
> @@ -700,7 +699,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
>  		fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS;
>  	get_lcd_level();
>  
> -	return result;
> +	return 0;
>  
>  err_unregister_input_dev:
>  	input_unregister_device(input);
> @@ -708,7 +707,7 @@ err_unregister_input_dev:
>  err_free_input_dev:
>  	input_free_device(input);
>  err_stop:
> -	return result;
> +	return error;
>  }
>  
>  static int acpi_fujitsu_remove(struct acpi_device *device)
> @@ -831,8 +830,8 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
>  	if (error)
>  		goto err_free_input_dev;
>  
> -	result = acpi_bus_update_power(fujitsu_hotkey->acpi_handle, &state);
> -	if (result) {
> +	error = acpi_bus_update_power(fujitsu_hotkey->acpi_handle, &state);
> +	if (error) {
>  		pr_err("Error reading power state\n");
>  		goto err_unregister_input_dev;
>  	}
> @@ -907,7 +906,7 @@ err_free_input_dev:
>  err_free_fifo:
>  	kfifo_free(&fujitsu_hotkey->fifo);
>  err_stop:
> -	return result;
> +	return error;
>  }
>  
>  static int acpi_fujitsu_hotkey_remove(struct acpi_device *device)
> 
> --

  reply	other threads:[~2013-12-31 13:17 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-29 21:58 [PATCH 0/25] fix error return code Julia Lawall
2013-12-29 22:47 ` Julia Lawall
2013-12-29 22:47 ` Julia Lawall
2013-12-29 22:47 ` Julia Lawall
2013-12-29 22:47 ` Julia Lawall
2013-12-29 22:47 ` Julia Lawall
2013-12-29 21:52 ` [PATCH 23/25] thermal: exynos: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-30  1:31   ` Jingoo Han
2013-12-30  1:31     ` Jingoo Han
2013-12-30  1:31     ` Jingoo Han
2014-01-02  1:55   ` Zhang Rui
2014-01-02  1:55     ` Zhang Rui
2014-01-02  1:55     ` Zhang Rui
2013-12-29 21:53 ` [PATCH 21/25] fujitsu-laptop: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-31 13:05   ` Jonathan Woithe [this message]
2013-12-31 13:17     ` Jonathan Woithe
2013-12-29 21:53 ` [PATCH 20/25] " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:53 ` [PATCH 15/25] " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:54 ` [PATCH 13/25] hamradio: 6pack: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2014-01-02  8:31   ` David Miller
2014-01-02  8:31     ` David Miller
2013-12-29 21:54 ` [PATCH 24/25] " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:54 ` [PATCH 22/25] RDMA/nes: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:54 ` [PATCH 14/25] RDMA/amso1100: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:54 ` [PATCH 9/25] " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:55 ` [PATCH 19/25] " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:58   ` Geert Uytterhoeven
2013-12-29 21:58     ` Geert Uytterhoeven
2013-12-29 21:58     ` Geert Uytterhoeven
2013-12-29 21:55 ` [PATCH 11/25] pcmcia: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:55 ` [PATCH 12/25] HID: sony: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2014-01-02 12:51   ` Jiri Kosina
2014-01-02 12:51     ` Jiri Kosina
2013-12-29 21:56 ` [PATCH 10/25] usb: gadget: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:56 ` [PATCH 18/25] mtd: nand: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:56 ` [PATCH 16/25] block: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:57 ` [PATCH 17/25] " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:57 ` [PATCH 6/25] " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2014-01-03  9:08   ` Jiri Kosina
2014-01-03  9:08     ` Jiri Kosina
2013-12-29 21:57 ` [PATCH 8/25] drivers/dma: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2014-01-20  9:28   ` Vinod Koul
2014-01-20  9:40     ` Vinod Koul
2013-12-29 21:59 ` [PATCH 7/25] net: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2014-01-02  8:31   ` David Miller
2014-01-02  8:31     ` David Miller
2013-12-29 21:59 ` [PATCH 5/25] IB/mlx4: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
     [not found]   ` <1388357260-4843-6-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2013-12-31  7:52     ` Jack Morgenstein
2013-12-31  7:52       ` Jack Morgenstein
2013-12-31  7:52       ` Jack Morgenstein
2013-12-29 21:59 ` [PATCH 3/25] " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 21:59 ` [PATCH 4/25] UBI: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-31 11:30   ` Richard Weinberger
2013-12-31 11:30     ` Richard Weinberger
2013-12-31 11:30     ` Richard Weinberger
2014-01-02 15:16   ` Artem Bityutskiy
2014-01-02 15:16     ` Artem Bityutskiy
2014-01-02 15:16     ` Artem Bityutskiy
2013-12-29 22:00 ` [PATCH 2/25] rsxx: " Julia Lawall
2013-12-29 22:47   ` Julia Lawall
2013-12-29 22:00 ` [PATCH 1/25] " Julia Lawall
2013-12-29 22:47   ` Julia Lawall

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=20131231130512.GB20866@marvin.atrad.com.au \
    --to=jwoithe@just42.net \
    --cc=Julia.Lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.garrett@nebula.com \
    --cc=platform-driver-x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.