public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 02/02] ath3k: Avoid duplication of code
@ 2011-01-27 23:24 Rogério Brito
  2011-01-28  8:56 ` Alexander Holler
  0 siblings, 1 reply; 6+ messages in thread
From: Rogério Brito @ 2011-01-27 23:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: Alexander Holler, Gustavo F. Padovan, rbrito

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

---

This is the second (preferred?) version of the patch in question.

---

diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index a126e61..d51c5a3 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -116,13 +116,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;
 }
 
 static void ath3k_disconnect(struct usb_interface *intf)

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-02-02 16:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox