All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] fs/fat: simplify get_fatent for FAT12
@ 2016-12-17  2:55 Stefan Brüns
  2016-12-27 23:01 ` [U-Boot] " Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Brüns @ 2016-12-17  2:55 UTC (permalink / raw)
  To: u-boot

From: Stefan Br??ns <stefan.bruens@rwth-aachen.de>

Instead of shuffling bits from two adjacent 16 bit words, use one 16 bit
word with the appropriate byte offset in the buffer.

Signed-off-by: Stefan Br?ns <stefan.bruens@rwth-aachen.de>
---
 fs/fat/fat.c | 34 +++++-----------------------------
 1 file changed, 5 insertions(+), 29 deletions(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 73c3dd7f85..fe899d0442 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -181,7 +181,6 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)
 	__u32 bufnum;
 	__u32 off16, offset;
 	__u32 ret = 0x00;
-	__u16 val1, val2;
 
 	if (CHECK_CLUST(entry, mydata->fatsize)) {
 		printf("Error: Invalid FAT entry: 0x%08x\n", entry);
@@ -243,35 +242,12 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)
 		ret = FAT2CPU16(((__u16 *) mydata->fatbuf)[offset]);
 		break;
 	case 12:
-		off16 = (offset * 3) / 4;
+		off16 = (offset * 3) / 2;
+		ret = FAT2CPU16(*(__u16 *)(mydata->fatbuf + off16));
 
-		switch (offset & 0x3) {
-		case 0:
-			ret = FAT2CPU16(((__u16 *) mydata->fatbuf)[off16]);
-			ret &= 0xfff;
-			break;
-		case 1:
-			val1 = FAT2CPU16(((__u16 *)mydata->fatbuf)[off16]);
-			val1 &= 0xf000;
-			val2 = FAT2CPU16(((__u16 *)mydata->fatbuf)[off16 + 1]);
-			val2 &= 0x00ff;
-			ret = (val2 << 4) | (val1 >> 12);
-			break;
-		case 2:
-			val1 = FAT2CPU16(((__u16 *)mydata->fatbuf)[off16]);
-			val1 &= 0xff00;
-			val2 = FAT2CPU16(((__u16 *)mydata->fatbuf)[off16 + 1]);
-			val2 &= 0x000f;
-			ret = (val2 << 8) | (val1 >> 8);
-			break;
-		case 3:
-			ret = FAT2CPU16(((__u16 *)mydata->fatbuf)[off16]);
-			ret = (ret & 0xfff0) >> 4;
-			break;
-		default:
-			break;
-		}
-		break;
+		if (offset & 0x1)
+			ret >>= 4;
+		ret &= 0xfff;
 	}
 	debug("FAT%d: ret: 0x%08x, entry: 0x%08x, offset: 0x%04x\n",
 	       mydata->fatsize, ret, entry, offset);
-- 
2.11.0

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

* [U-Boot] fs/fat: simplify get_fatent for FAT12
  2016-12-17  2:55 [U-Boot] [PATCH] fs/fat: simplify get_fatent for FAT12 Stefan Brüns
@ 2016-12-27 23:01 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2016-12-27 23:01 UTC (permalink / raw)
  To: u-boot

On Sat, Dec 17, 2016 at 03:55:10AM +0100, Stefan Br?ns wrote:

> From: Stefan Br??ns <stefan.bruens@rwth-aachen.de>
> 
> Instead of shuffling bits from two adjacent 16 bit words, use one 16 bit
> word with the appropriate byte offset in the buffer.
> 
> Signed-off-by: Stefan Br?ns <stefan.bruens@rwth-aachen.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161227/768ad4e7/attachment.sig>

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

end of thread, other threads:[~2016-12-27 23:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-17  2:55 [U-Boot] [PATCH] fs/fat: simplify get_fatent for FAT12 Stefan Brüns
2016-12-27 23:01 ` [U-Boot] " Tom Rini

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.