[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110127232453.GA3531@ime.usp.br>
Date: Thu, 27 Jan 2011 21:24:56 -0200
From: Rogério Brito <rbrito@....usp.br>
To: linux-kernel@...r.kernel.org
Cc: Alexander Holler <holler@...oftware.de>,
"Gustavo F. Padovan" <padovan@...fusion.mobi>, rbrito@....usp.br
Subject: [PATCH 02/02] ath3k: Avoid duplication of code
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@....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)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists