Skip to content

Commit

Permalink
Bluetooth: ath3k: Avoid duplication of code
Browse files Browse the repository at this point in the history
In commit 86e0928, 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>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
  • Loading branch information
Rogério Brito authored and Gustavo F. Padovan committed Feb 8, 2011
1 parent d37f50e commit 84f0e17
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions drivers/bluetooth/ath3k.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,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);

Expand All @@ -118,13 +119,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;
}

static void ath3k_disconnect(struct usb_interface *intf)
Expand Down

0 comments on commit 84f0e17

Please sign in to comment.