All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
To: "Rogério Brito" <rbrito@ime.usp.br>
Cc: linux-kernel@vger.kernel.org,
	Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
	Alexander Holler <holler@ahsoftware.de>
Subject: Re: [PATCH] ath3k: Avoid duplication of code
Date: Wed, 2 Feb 2011 14:37:34 -0200	[thread overview]
Message-ID: <20110202163734.GE2273@joana> (raw)
In-Reply-To: <20110128221807.GA9741@ime.usp.br>

Hi Rogério,

* Rogério Brito <rbrito@ime.usp.br> [2011-01-28 20:18:10 -0200]:

> 
> Hi.
> 
> In commit 86e09287e4f8c81831b4d4118a48597565f0d21b, to reduce memory
> usage, the functions of the ath3k module were rewritten to release the
> firmware blob after it has been loaded (successfully or not).
> 
> The resuting code has some redundancy and the compiler can potentially
> produce better code if we omit a function call that is unconditionally
> executed in
> 
> ,----
> | 	if (ath3k_load_firmware(udev, firmware)) {
> | 		release_firmware(firmware);
> | 		return -EIO;
> |	}
> |	release_firmware(firmware);
> |
> |	return 0;
> | }
> `----
> 
> It may also be argued that the rewritten code becomes easier to read,
> and also to see the code coverage of the snippet in question.
> 
> 
> Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
> Cc: Alexander Holler <holler@ahsoftware.de>
> Cc: "Gustavo F. Padovan" <padovan@profusion.mobi>
> Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>

Please send me your patch in a 'git format-patch' way, so I can apply it
without having to edit the commit message. And add "Bluetooth:" to the
beginning of the commit title.

> 
> ---
> 
> Thanks for all the feedback on the previous patches. The one that didn't
> compile before was sent without a hunk. This time everything all the
> basics are verified.
> 
> 
> diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
> index a126e61..42fa531 100644
> --- a/drivers/bluetooth/ath3k.c
> +++ b/drivers/bluetooth/ath3k.c
> @@ -106,6 +106,7 @@ static int ath3k_probe(struct usb_interface *intf,
>  {
>  	const struct firmware *firmware;
>  	struct usb_device *udev = interface_to_usbdev(intf);
> +	int ret;
>  
>  	BT_DBG("intf %p id %p", intf, id);
>  
> @@ -116,13 +117,10 @@ static int ath3k_probe(struct usb_interface *intf,
>  		return -EIO;
>  	}
>  
> -	if (ath3k_load_firmware(udev, firmware)) {
> -		release_firmware(firmware);
> -		return -EIO;
> -	}
> +	ret = ath3k_load_firmware(udev, firmware);
>  	release_firmware(firmware);
>  
> -	return 0;
> +	return ret ? -EIO : 0;

just return ret;
It is enough.

Regards,

-- 
Gustavo F. Padovan
http://profusion.mobi

      parent reply	other threads:[~2011-02-02 16:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-27 23:24 [PATCH 02/02] ath3k: Avoid duplication of code Rogério Brito
2011-01-28  8:56 ` Alexander Holler
2011-01-28 22:18   ` [PATCH] " Rogério Brito
2011-01-29 11:59     ` Alexander Holler
2011-01-30 21:38       ` Rogério Brito
2011-02-02 16:37     ` Gustavo F. Padovan [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=20110202163734.GE2273@joana \
    --to=padovan@profusion.mobi \
    --cc=holler@ahsoftware.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=rbrito@ime.usp.br \
    /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.