public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Darren Hart <dvhart@infradead.org>
To: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Cc: mjg59@srcf.ucam.org, platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: Re: [PATCH 2/2] intel-rst: Clean up ACPI add function
Date: Tue, 16 Sep 2014 16:25:49 -0700	[thread overview]
Message-ID: <20140916232549.GA18698@vmdeb7> (raw)
In-Reply-To: <1410902036-10282-3-git-send-email-peter.ujfalusi@gmail.com>

On Wed, Sep 17, 2014 at 12:13:56AM +0300, Peter Ujfalusi wrote:
> There is no need to initialize the error since it is going to be assigned
> with the return status of at least on of the device_create_file() call.
> 
> We can return directly in case the first file creation fails.
> All the labels for goto can be removed (along with the gotos) as well.
> Tell the compiler that the failures are unlikely so it can create better
> binaries.

Looks reasonable to me.

Cc: linux-acpi


> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
> ---
>  drivers/platform/x86/intel-rst.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel-rst.c b/drivers/platform/x86/intel-rst.c
> index 8c6a8fe..7344d84 100644
> --- a/drivers/platform/x86/intel-rst.c
> +++ b/drivers/platform/x86/intel-rst.c
> @@ -119,21 +119,16 @@ static struct device_attribute irst_timeout_attr = {
>  
>  static int irst_add(struct acpi_device *acpi)
>  {
> -	int error = 0;
> +	int error;
>  
>  	error = device_create_file(&acpi->dev, &irst_timeout_attr);
> -	if (error)
> -		goto out;
> +	if (unlikely(error))
> +		return error;
>  
>  	error = device_create_file(&acpi->dev, &irst_wakeup_attr);
> -	if (error)
> -		goto out_timeout;
> +	if (unlikely(error))
> +		device_remove_file(&acpi->dev, &irst_timeout_attr);
>  
> -	return 0;
> -
> -out_timeout:
> -	device_remove_file(&acpi->dev, &irst_timeout_attr);
> -out:
>  	return error;
>  }
>  
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
Darren Hart
Intel Open Source Technology Center

      reply	other threads:[~2014-09-16 23:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16 21:13 [PATCH 0/2] intel-rst: Small cleanups Peter Ujfalusi
2014-09-16 21:13 ` [PATCH 1/2] intel-rst: Use ACPI_FAILURE() macro instead !ACPI_SUCCESS() for error checking Peter Ujfalusi
2014-09-16 22:49   ` Darren Hart
2014-09-16 21:13 ` [PATCH 2/2] intel-rst: Clean up ACPI add function Peter Ujfalusi
2014-09-16 23:25   ` Darren Hart [this message]

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=20140916232549.GA18698@vmdeb7 \
    --to=dvhart@infradead.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=peter.ujfalusi@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox