All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] staging: keucr: remove unused typedef VOID
@ 2011-03-02 23:48 Jonathan Neuschäfer
  2011-03-02 23:48 ` [PATCH 2/2] staging: keucr: use kernel byteorder functions Jonathan Neuschäfer
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Neuschäfer @ 2011-03-02 23:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Al Cho; +Cc: devel, linux-kernel, Jonathan Neuschäfer

---
 drivers/staging/keucr/common.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/keucr/common.h b/drivers/staging/keucr/common.h
index 8693c54..f2be045 100644
--- a/drivers/staging/keucr/common.h
+++ b/drivers/staging/keucr/common.h
@@ -1,7 +1,6 @@
 #ifndef COMMON_INCD
 #define COMMON_INCD
 
-typedef void VOID;
 typedef u8 BOOLEAN;
 typedef u8 BYTE;
 typedef u8 *PBYTE;
-- 
1.7.4.1


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

* [PATCH 2/2] staging: keucr: use kernel byteorder functions
  2011-03-02 23:48 [PATCH 1/2] staging: keucr: remove unused typedef VOID Jonathan Neuschäfer
@ 2011-03-02 23:48 ` Jonathan Neuschäfer
  2011-03-03  7:58   ` Jack Stone
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Neuschäfer @ 2011-03-02 23:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Al Cho; +Cc: devel, linux-kernel, Jonathan Neuschäfer

---
 drivers/staging/keucr/TODO     |    1 -
 drivers/staging/keucr/common.h |   12 ------------
 drivers/staging/keucr/ms.c     |   28 +++++++++++++++-------------
 3 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/keucr/TODO b/drivers/staging/keucr/TODO
index 179b7fe..1c48e40 100644
--- a/drivers/staging/keucr/TODO
+++ b/drivers/staging/keucr/TODO
@@ -6,7 +6,6 @@ TODO:
 	  be merged into the drivers/usb/storage/ directory and
 	  infrastructure instead.
 	- review by the USB developer community
-	- common.h: use kernel swap, le, & be functions
 	- smcommon.h & smilsub.c: use kernel hweight8(), hweight16()
 
 Please send any patches for this driver to Al Cho <acho@novell.com> and
diff --git a/drivers/staging/keucr/common.h b/drivers/staging/keucr/common.h
index f2be045..b87dc7a 100644
--- a/drivers/staging/keucr/common.h
+++ b/drivers/staging/keucr/common.h
@@ -9,17 +9,5 @@ typedef u16 *PWORD;
 typedef u32 DWORD;
 typedef u32 *PDWORD;
 
-#define swapWORD(w)	((((unsigned short)(w) << 8) & 0xff00) |	\
-			 (((unsigned short)(w) >> 8) & 0x00ff))
-#define swapDWORD(dw)	((((unsigned long)(dw) << 24) & 0xff000000) |	\
-			 (((unsigned long)(dw) <<  8) & 0x00ff0000) |	\
-			 (((unsigned long)(dw) >>  8) & 0x0000ff00) |	\
-			 (((unsigned long)(dw) >> 24) & 0x000000ff))
-
-#define LittleEndianWORD(w)	(w)
-#define LittleEndianDWORD(dw)	(dw)
-#define BigEndianWORD(w)	swapWORD(w)
-#define BigEndianDWORD(dw)	swapDWORD(dw)
-
 #endif
 
diff --git a/drivers/staging/keucr/ms.c b/drivers/staging/keucr/ms.c
index 452ea8f..e33b7e3 100644
--- a/drivers/staging/keucr/ms.c
+++ b/drivers/staging/keucr/ms.c
@@ -1,4 +1,6 @@
 #include <linux/slab.h>
+#include <asm/byteorder.h>
+
 #include "usb.h"
 #include "scsiglue.h"
 #include "transport.h"
@@ -166,8 +168,8 @@ int MS_CardInit(struct us_data *us)
 			continue;
 
 		if (((extdat.mngflg & MS_REG_MNG_SYSFLG) == MS_REG_MNG_SYSFLG_USER) ||
-			(BigEndianWORD(((MemStickBootBlockPage0 *)PageBuffer0)->header.wBlockID) != MS_BOOT_BLOCK_ID) ||
-			(BigEndianWORD(((MemStickBootBlockPage0 *)PageBuffer0)->header.wFormatVersion) != MS_BOOT_BLOCK_FORMAT_VERSION) ||
+			(be16_to_cpu(((MemStickBootBlockPage0 *)PageBuffer0)->header.wBlockID) != MS_BOOT_BLOCK_ID) ||
+			(be16_to_cpu(((MemStickBootBlockPage0 *)PageBuffer0)->header.wFormatVersion) != MS_BOOT_BLOCK_FORMAT_VERSION) ||
 			(((MemStickBootBlockPage0 *)PageBuffer0)->header.bNumberOfDataEntry != MS_BOOT_BLOCK_DATA_ENTRIES))
 				continue;
 
@@ -266,7 +268,7 @@ int MS_LibCheckDisableBlock(struct us_data *us, WORD PhyBlock)
 	MS_ReaderReadPage(us, PhyBlock, 1, (DWORD *)PageBuf, &extdat);
 	do
 	{
-		blk = BigEndianWORD(PageBuf[index]);
+		blk = be16_to_cpu(PageBuf[index]);
 		if (blk == MS_LB_NOT_USED)
 			break;
 		if (blk == us->MS_Lib.Log2PhyMap[0])
@@ -355,7 +357,7 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 	SysInfo= &(((MemStickBootBlockPage0 *)PageData)->sysinf);
 
 	if ((SysInfo->bMsClass != MS_SYSINF_MSCLASS_TYPE_1)                                   ||
-		(BigEndianWORD(SysInfo->wPageSize) != MS_SYSINF_PAGE_SIZE)                       ||
+		(be16_to_cpu(SysInfo->wPageSize) != MS_SYSINF_PAGE_SIZE)                       ||
 		((SysInfo->bSecuritySupport & MS_SYSINF_SECURITY) == MS_SYSINF_SECURITY_SUPPORT) ||
 		(SysInfo->bReserved1 != MS_SYSINF_RESERVED1)                                     ||
 		(SysInfo->bReserved2 != MS_SYSINF_RESERVED2)                                     ||
@@ -376,12 +378,12 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 			goto exit;
 	}
 
-	us->MS_Lib.blockSize        = BigEndianWORD(SysInfo->wBlockSize);
-	us->MS_Lib.NumberOfPhyBlock = BigEndianWORD(SysInfo->wBlockNumber);
-	us->MS_Lib.NumberOfLogBlock = BigEndianWORD(SysInfo->wTotalBlockNumber)- 2;
+	us->MS_Lib.blockSize        = be16_to_cpu(SysInfo->wBlockSize);
+	us->MS_Lib.NumberOfPhyBlock = be16_to_cpu(SysInfo->wBlockNumber);
+	us->MS_Lib.NumberOfLogBlock = be16_to_cpu(SysInfo->wTotalBlockNumber) - 2;
 	us->MS_Lib.PagesPerBlock    = us->MS_Lib.blockSize * SIZE_OF_KIRO / MS_BYTES_PER_PAGE;
 	us->MS_Lib.NumberOfSegment  = us->MS_Lib.NumberOfPhyBlock / MS_PHYSICAL_BLOCKS_PER_SEGMENT;
-	us->MS_Model                = BigEndianWORD(SysInfo->wMemorySize);
+	us->MS_Model                = be16_to_cpu(SysInfo->wMemorySize);
 
 	if (MS_LibAllocLogicalMap(us))			//Allocate to all number of logicalblock and physicalblock
 		goto exit;
@@ -394,10 +396,10 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 	{
 		DWORD  EntryOffset, EntrySize;
 
-		if ((EntryOffset = BigEndianDWORD(SysEntry->entry[i].dwStart)) == 0xffffff)
+		if ((EntryOffset = be32_to_cpu(SysEntry->entry[i].dwStart)) == 0xffffff)
 			continue;
 
-		if ((EntrySize = BigEndianDWORD(SysEntry->entry[i].dwSize)) == 0)
+		if ((EntrySize = be32_to_cpu(SysEntry->entry[i].dwSize)) == 0)
 			continue;
 
 		if (EntryOffset + MS_BYTES_PER_PAGE + EntrySize > us->MS_Lib.blockSize * (DWORD)SIZE_OF_KIRO)
@@ -429,7 +431,7 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 					PrevPageNumber = PageNumber;
 				}
 
-				if ((phyblk = BigEndianWORD(*(WORD *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))) < 0x0fff)
+				if ((phyblk = be16_to_cpu(*(WORD *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))) < 0x0fff)
 					MS_LibSetInitialErrorBlock(us, phyblk);
 
 				EntryOffset += 2;
@@ -455,10 +457,10 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 			}
 
 			idi = &((MemStickBootBlockCIS_IDI *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))->idi.idi;
-			if (LittleEndianWORD(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
+			if (le16_to_cpu(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
 				goto exit;
 
-			us->MS_Lib.BytesPerSector = LittleEndianWORD(idi->wIDIbytesPerSector);
+			us->MS_Lib.BytesPerSector = be16_to_cpu(idi->wIDIbytesPerSector);
 			if (us->MS_Lib.BytesPerSector != MS_BYTES_PER_PAGE)
 				goto exit;
 		}
-- 
1.7.4.1


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

* Re: [PATCH 2/2] staging: keucr: use kernel byteorder functions
  2011-03-02 23:48 ` [PATCH 2/2] staging: keucr: use kernel byteorder functions Jonathan Neuschäfer
@ 2011-03-03  7:58   ` Jack Stone
  2011-03-03 11:32     ` Jonathan Neuschäfer
  0 siblings, 1 reply; 8+ messages in thread
From: Jack Stone @ 2011-03-03  7:58 UTC (permalink / raw)
  To: Jonathan Neuschäfer; +Cc: Greg Kroah-Hartman, Al Cho, devel, linux-kernel

> @@ -455,10 +457,10 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
>  			}
>  
>  			idi = &((MemStickBootBlockCIS_IDI *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))->idi.idi;
> -			if (LittleEndianWORD(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
> +			if (le16_to_cpu(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
>  				goto exit;
>  
> -			us->MS_Lib.BytesPerSector = LittleEndianWORD(idi->wIDIbytesPerSector);
> +			us->MS_Lib.BytesPerSector = be16_to_cpu(idi->wIDIbytesPerSector);

Shouldn't this be le16_to_cpu?

>  			if (us->MS_Lib.BytesPerSector != MS_BYTES_PER_PAGE)
>  				goto exit;
>  		}

Thanks,

Jack

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

* Re: [PATCH 2/2] staging: keucr: use kernel byteorder functions
  2011-03-03  7:58   ` Jack Stone
@ 2011-03-03 11:32     ` Jonathan Neuschäfer
  2011-03-03 11:38       ` [PATCH v2] " Jonathan Neuschäfer
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Neuschäfer @ 2011-03-03 11:32 UTC (permalink / raw)
  To: Jack Stone
  Cc: Jonathan Neuschäfer, Greg Kroah-Hartman, Al Cho, devel,
	linux-kernel

On Thu, Mar 03, 2011 at 07:58:59AM +0000, Jack Stone wrote:
> >  
> > -			us->MS_Lib.BytesPerSector = LittleEndianWORD(idi->wIDIbytesPerSector);
> > +			us->MS_Lib.BytesPerSector = be16_to_cpu(idi->wIDIbytesPerSector);
> 
> Shouldn't this be le16_to_cpu?

Right. Thanks for pointing out.

Jonathan Neuschäfer

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

* [PATCH v2] staging: keucr: use kernel byteorder functions
  2011-03-03 11:32     ` Jonathan Neuschäfer
@ 2011-03-03 11:38       ` Jonathan Neuschäfer
  2011-03-03 11:51         ` Jack Stone
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Neuschäfer @ 2011-03-03 11:38 UTC (permalink / raw)
  To: Jack Stone
  Cc: Greg Kroah-Hartman, Al Cho, devel, linux-kernel,
	Jonathan Neuschäfer

---
 drivers/staging/keucr/TODO     |    1 -
 drivers/staging/keucr/common.h |   12 ------------
 drivers/staging/keucr/ms.c     |   28 +++++++++++++++-------------
 3 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/keucr/TODO b/drivers/staging/keucr/TODO
index 179b7fe..1c48e40 100644
--- a/drivers/staging/keucr/TODO
+++ b/drivers/staging/keucr/TODO
@@ -6,7 +6,6 @@ TODO:
 	  be merged into the drivers/usb/storage/ directory and
 	  infrastructure instead.
 	- review by the USB developer community
-	- common.h: use kernel swap, le, & be functions
 	- smcommon.h & smilsub.c: use kernel hweight8(), hweight16()
 
 Please send any patches for this driver to Al Cho <acho@novell.com> and
diff --git a/drivers/staging/keucr/common.h b/drivers/staging/keucr/common.h
index f2be045..b87dc7a 100644
--- a/drivers/staging/keucr/common.h
+++ b/drivers/staging/keucr/common.h
@@ -9,17 +9,5 @@ typedef u16 *PWORD;
 typedef u32 DWORD;
 typedef u32 *PDWORD;
 
-#define swapWORD(w)	((((unsigned short)(w) << 8) & 0xff00) |	\
-			 (((unsigned short)(w) >> 8) & 0x00ff))
-#define swapDWORD(dw)	((((unsigned long)(dw) << 24) & 0xff000000) |	\
-			 (((unsigned long)(dw) <<  8) & 0x00ff0000) |	\
-			 (((unsigned long)(dw) >>  8) & 0x0000ff00) |	\
-			 (((unsigned long)(dw) >> 24) & 0x000000ff))
-
-#define LittleEndianWORD(w)	(w)
-#define LittleEndianDWORD(dw)	(dw)
-#define BigEndianWORD(w)	swapWORD(w)
-#define BigEndianDWORD(dw)	swapDWORD(dw)
-
 #endif
 
diff --git a/drivers/staging/keucr/ms.c b/drivers/staging/keucr/ms.c
index 452ea8f..48496e4 100644
--- a/drivers/staging/keucr/ms.c
+++ b/drivers/staging/keucr/ms.c
@@ -1,4 +1,6 @@
 #include <linux/slab.h>
+#include <asm/byteorder.h>
+
 #include "usb.h"
 #include "scsiglue.h"
 #include "transport.h"
@@ -166,8 +168,8 @@ int MS_CardInit(struct us_data *us)
 			continue;
 
 		if (((extdat.mngflg & MS_REG_MNG_SYSFLG) == MS_REG_MNG_SYSFLG_USER) ||
-			(BigEndianWORD(((MemStickBootBlockPage0 *)PageBuffer0)->header.wBlockID) != MS_BOOT_BLOCK_ID) ||
-			(BigEndianWORD(((MemStickBootBlockPage0 *)PageBuffer0)->header.wFormatVersion) != MS_BOOT_BLOCK_FORMAT_VERSION) ||
+			(be16_to_cpu(((MemStickBootBlockPage0 *)PageBuffer0)->header.wBlockID) != MS_BOOT_BLOCK_ID) ||
+			(be16_to_cpu(((MemStickBootBlockPage0 *)PageBuffer0)->header.wFormatVersion) != MS_BOOT_BLOCK_FORMAT_VERSION) ||
 			(((MemStickBootBlockPage0 *)PageBuffer0)->header.bNumberOfDataEntry != MS_BOOT_BLOCK_DATA_ENTRIES))
 				continue;
 
@@ -266,7 +268,7 @@ int MS_LibCheckDisableBlock(struct us_data *us, WORD PhyBlock)
 	MS_ReaderReadPage(us, PhyBlock, 1, (DWORD *)PageBuf, &extdat);
 	do
 	{
-		blk = BigEndianWORD(PageBuf[index]);
+		blk = be16_to_cpu(PageBuf[index]);
 		if (blk == MS_LB_NOT_USED)
 			break;
 		if (blk == us->MS_Lib.Log2PhyMap[0])
@@ -355,7 +357,7 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 	SysInfo= &(((MemStickBootBlockPage0 *)PageData)->sysinf);
 
 	if ((SysInfo->bMsClass != MS_SYSINF_MSCLASS_TYPE_1)                                   ||
-		(BigEndianWORD(SysInfo->wPageSize) != MS_SYSINF_PAGE_SIZE)                       ||
+		(be16_to_cpu(SysInfo->wPageSize) != MS_SYSINF_PAGE_SIZE)                       ||
 		((SysInfo->bSecuritySupport & MS_SYSINF_SECURITY) == MS_SYSINF_SECURITY_SUPPORT) ||
 		(SysInfo->bReserved1 != MS_SYSINF_RESERVED1)                                     ||
 		(SysInfo->bReserved2 != MS_SYSINF_RESERVED2)                                     ||
@@ -376,12 +378,12 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 			goto exit;
 	}
 
-	us->MS_Lib.blockSize        = BigEndianWORD(SysInfo->wBlockSize);
-	us->MS_Lib.NumberOfPhyBlock = BigEndianWORD(SysInfo->wBlockNumber);
-	us->MS_Lib.NumberOfLogBlock = BigEndianWORD(SysInfo->wTotalBlockNumber)- 2;
+	us->MS_Lib.blockSize        = be16_to_cpu(SysInfo->wBlockSize);
+	us->MS_Lib.NumberOfPhyBlock = be16_to_cpu(SysInfo->wBlockNumber);
+	us->MS_Lib.NumberOfLogBlock = be16_to_cpu(SysInfo->wTotalBlockNumber) - 2;
 	us->MS_Lib.PagesPerBlock    = us->MS_Lib.blockSize * SIZE_OF_KIRO / MS_BYTES_PER_PAGE;
 	us->MS_Lib.NumberOfSegment  = us->MS_Lib.NumberOfPhyBlock / MS_PHYSICAL_BLOCKS_PER_SEGMENT;
-	us->MS_Model                = BigEndianWORD(SysInfo->wMemorySize);
+	us->MS_Model                = be16_to_cpu(SysInfo->wMemorySize);
 
 	if (MS_LibAllocLogicalMap(us))			//Allocate to all number of logicalblock and physicalblock
 		goto exit;
@@ -394,10 +396,10 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 	{
 		DWORD  EntryOffset, EntrySize;
 
-		if ((EntryOffset = BigEndianDWORD(SysEntry->entry[i].dwStart)) == 0xffffff)
+		if ((EntryOffset = be32_to_cpu(SysEntry->entry[i].dwStart)) == 0xffffff)
 			continue;
 
-		if ((EntrySize = BigEndianDWORD(SysEntry->entry[i].dwSize)) == 0)
+		if ((EntrySize = be32_to_cpu(SysEntry->entry[i].dwSize)) == 0)
 			continue;
 
 		if (EntryOffset + MS_BYTES_PER_PAGE + EntrySize > us->MS_Lib.blockSize * (DWORD)SIZE_OF_KIRO)
@@ -429,7 +431,7 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 					PrevPageNumber = PageNumber;
 				}
 
-				if ((phyblk = BigEndianWORD(*(WORD *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))) < 0x0fff)
+				if ((phyblk = be16_to_cpu(*(WORD *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))) < 0x0fff)
 					MS_LibSetInitialErrorBlock(us, phyblk);
 
 				EntryOffset += 2;
@@ -455,10 +457,10 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 			}
 
 			idi = &((MemStickBootBlockCIS_IDI *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))->idi.idi;
-			if (LittleEndianWORD(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
+			if (le16_to_cpu(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
 				goto exit;
 
-			us->MS_Lib.BytesPerSector = LittleEndianWORD(idi->wIDIbytesPerSector);
+			us->MS_Lib.BytesPerSector = le16_to_cpu(idi->wIDIbytesPerSector);
 			if (us->MS_Lib.BytesPerSector != MS_BYTES_PER_PAGE)
 				goto exit;
 		}
-- 
1.7.4.1


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

* Re: [PATCH v2] staging: keucr: use kernel byteorder functions
  2011-03-03 11:38       ` [PATCH v2] " Jonathan Neuschäfer
@ 2011-03-03 11:51         ` Jack Stone
  2011-03-03 13:25           ` [PATCH v3 1/2] staging: keucr: remove unused typedef VOID Jonathan Neuschäfer
  0 siblings, 1 reply; 8+ messages in thread
From: Jack Stone @ 2011-03-03 11:51 UTC (permalink / raw)
  To: Jonathan Neuschäfer; +Cc: Greg Kroah-Hartman, Al Cho, devel, linux-kernel

On 03/03/2011 11:38, Jonathan Neuschäfer wrote:
> ---
>  drivers/staging/keucr/TODO     |    1 -
>  drivers/staging/keucr/common.h |   12 ------------
>  drivers/staging/keucr/ms.c     |   28 +++++++++++++++-------------
>  3 files changed, 15 insertions(+), 26 deletions(-)

You'll need at least a Signed-off-by and possibly a brief changelog

Pending that

Reviewed-by: Jack Stone <jwjstone@fastmail.fm>

Thanks,

Jack

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

* [PATCH v3 1/2] staging: keucr: remove unused typedef VOID
  2011-03-03 11:51         ` Jack Stone
@ 2011-03-03 13:25           ` Jonathan Neuschäfer
  2011-03-03 13:25             ` [PATCH v3 2/2] staging: keucr: use kernel byteorder functions Jonathan Neuschäfer
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Neuschäfer @ 2011-03-03 13:25 UTC (permalink / raw)
  To: Jack Stone
  Cc: Greg Kroah-Hartman, Al Cho, devel, linux-kernel,
	Jonathan Neuschäfer

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
Changes:
v2 .. v3: add an "Signed-off-by:" line
---
 drivers/staging/keucr/common.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/keucr/common.h b/drivers/staging/keucr/common.h
index 8693c54..f2be045 100644
--- a/drivers/staging/keucr/common.h
+++ b/drivers/staging/keucr/common.h
@@ -1,7 +1,6 @@
 #ifndef COMMON_INCD
 #define COMMON_INCD
 
-typedef void VOID;
 typedef u8 BOOLEAN;
 typedef u8 BYTE;
 typedef u8 *PBYTE;
-- 
1.7.4.1


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

* [PATCH v3 2/2] staging: keucr: use kernel byteorder functions
  2011-03-03 13:25           ` [PATCH v3 1/2] staging: keucr: remove unused typedef VOID Jonathan Neuschäfer
@ 2011-03-03 13:25             ` Jonathan Neuschäfer
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Neuschäfer @ 2011-03-03 13:25 UTC (permalink / raw)
  To: Jack Stone
  Cc: Greg Kroah-Hartman, Al Cho, devel, linux-kernel,
	Jonathan Neuschäfer

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Reviewed-by: Jack Stone <jwjstone@fastmail.fm>
---
Changes:
v1 .. v2: correctly replace LittleEndianWORD with le16_to_cpu
v2 .. v3: add an "Signed-off-by:" line
---
 drivers/staging/keucr/TODO     |    1 -
 drivers/staging/keucr/common.h |   12 ------------
 drivers/staging/keucr/ms.c     |   28 +++++++++++++++-------------
 3 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/keucr/TODO b/drivers/staging/keucr/TODO
index 179b7fe..1c48e40 100644
--- a/drivers/staging/keucr/TODO
+++ b/drivers/staging/keucr/TODO
@@ -6,7 +6,6 @@ TODO:
 	  be merged into the drivers/usb/storage/ directory and
 	  infrastructure instead.
 	- review by the USB developer community
-	- common.h: use kernel swap, le, & be functions
 	- smcommon.h & smilsub.c: use kernel hweight8(), hweight16()
 
 Please send any patches for this driver to Al Cho <acho@novell.com> and
diff --git a/drivers/staging/keucr/common.h b/drivers/staging/keucr/common.h
index f2be045..b87dc7a 100644
--- a/drivers/staging/keucr/common.h
+++ b/drivers/staging/keucr/common.h
@@ -9,17 +9,5 @@ typedef u16 *PWORD;
 typedef u32 DWORD;
 typedef u32 *PDWORD;
 
-#define swapWORD(w)	((((unsigned short)(w) << 8) & 0xff00) |	\
-			 (((unsigned short)(w) >> 8) & 0x00ff))
-#define swapDWORD(dw)	((((unsigned long)(dw) << 24) & 0xff000000) |	\
-			 (((unsigned long)(dw) <<  8) & 0x00ff0000) |	\
-			 (((unsigned long)(dw) >>  8) & 0x0000ff00) |	\
-			 (((unsigned long)(dw) >> 24) & 0x000000ff))
-
-#define LittleEndianWORD(w)	(w)
-#define LittleEndianDWORD(dw)	(dw)
-#define BigEndianWORD(w)	swapWORD(w)
-#define BigEndianDWORD(dw)	swapDWORD(dw)
-
 #endif
 
diff --git a/drivers/staging/keucr/ms.c b/drivers/staging/keucr/ms.c
index 452ea8f..48496e4 100644
--- a/drivers/staging/keucr/ms.c
+++ b/drivers/staging/keucr/ms.c
@@ -1,4 +1,6 @@
 #include <linux/slab.h>
+#include <asm/byteorder.h>
+
 #include "usb.h"
 #include "scsiglue.h"
 #include "transport.h"
@@ -166,8 +168,8 @@ int MS_CardInit(struct us_data *us)
 			continue;
 
 		if (((extdat.mngflg & MS_REG_MNG_SYSFLG) == MS_REG_MNG_SYSFLG_USER) ||
-			(BigEndianWORD(((MemStickBootBlockPage0 *)PageBuffer0)->header.wBlockID) != MS_BOOT_BLOCK_ID) ||
-			(BigEndianWORD(((MemStickBootBlockPage0 *)PageBuffer0)->header.wFormatVersion) != MS_BOOT_BLOCK_FORMAT_VERSION) ||
+			(be16_to_cpu(((MemStickBootBlockPage0 *)PageBuffer0)->header.wBlockID) != MS_BOOT_BLOCK_ID) ||
+			(be16_to_cpu(((MemStickBootBlockPage0 *)PageBuffer0)->header.wFormatVersion) != MS_BOOT_BLOCK_FORMAT_VERSION) ||
 			(((MemStickBootBlockPage0 *)PageBuffer0)->header.bNumberOfDataEntry != MS_BOOT_BLOCK_DATA_ENTRIES))
 				continue;
 
@@ -266,7 +268,7 @@ int MS_LibCheckDisableBlock(struct us_data *us, WORD PhyBlock)
 	MS_ReaderReadPage(us, PhyBlock, 1, (DWORD *)PageBuf, &extdat);
 	do
 	{
-		blk = BigEndianWORD(PageBuf[index]);
+		blk = be16_to_cpu(PageBuf[index]);
 		if (blk == MS_LB_NOT_USED)
 			break;
 		if (blk == us->MS_Lib.Log2PhyMap[0])
@@ -355,7 +357,7 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 	SysInfo= &(((MemStickBootBlockPage0 *)PageData)->sysinf);
 
 	if ((SysInfo->bMsClass != MS_SYSINF_MSCLASS_TYPE_1)                                   ||
-		(BigEndianWORD(SysInfo->wPageSize) != MS_SYSINF_PAGE_SIZE)                       ||
+		(be16_to_cpu(SysInfo->wPageSize) != MS_SYSINF_PAGE_SIZE)                       ||
 		((SysInfo->bSecuritySupport & MS_SYSINF_SECURITY) == MS_SYSINF_SECURITY_SUPPORT) ||
 		(SysInfo->bReserved1 != MS_SYSINF_RESERVED1)                                     ||
 		(SysInfo->bReserved2 != MS_SYSINF_RESERVED2)                                     ||
@@ -376,12 +378,12 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 			goto exit;
 	}
 
-	us->MS_Lib.blockSize        = BigEndianWORD(SysInfo->wBlockSize);
-	us->MS_Lib.NumberOfPhyBlock = BigEndianWORD(SysInfo->wBlockNumber);
-	us->MS_Lib.NumberOfLogBlock = BigEndianWORD(SysInfo->wTotalBlockNumber)- 2;
+	us->MS_Lib.blockSize        = be16_to_cpu(SysInfo->wBlockSize);
+	us->MS_Lib.NumberOfPhyBlock = be16_to_cpu(SysInfo->wBlockNumber);
+	us->MS_Lib.NumberOfLogBlock = be16_to_cpu(SysInfo->wTotalBlockNumber) - 2;
 	us->MS_Lib.PagesPerBlock    = us->MS_Lib.blockSize * SIZE_OF_KIRO / MS_BYTES_PER_PAGE;
 	us->MS_Lib.NumberOfSegment  = us->MS_Lib.NumberOfPhyBlock / MS_PHYSICAL_BLOCKS_PER_SEGMENT;
-	us->MS_Model                = BigEndianWORD(SysInfo->wMemorySize);
+	us->MS_Model                = be16_to_cpu(SysInfo->wMemorySize);
 
 	if (MS_LibAllocLogicalMap(us))			//Allocate to all number of logicalblock and physicalblock
 		goto exit;
@@ -394,10 +396,10 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 	{
 		DWORD  EntryOffset, EntrySize;
 
-		if ((EntryOffset = BigEndianDWORD(SysEntry->entry[i].dwStart)) == 0xffffff)
+		if ((EntryOffset = be32_to_cpu(SysEntry->entry[i].dwStart)) == 0xffffff)
 			continue;
 
-		if ((EntrySize = BigEndianDWORD(SysEntry->entry[i].dwSize)) == 0)
+		if ((EntrySize = be32_to_cpu(SysEntry->entry[i].dwSize)) == 0)
 			continue;
 
 		if (EntryOffset + MS_BYTES_PER_PAGE + EntrySize > us->MS_Lib.blockSize * (DWORD)SIZE_OF_KIRO)
@@ -429,7 +431,7 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 					PrevPageNumber = PageNumber;
 				}
 
-				if ((phyblk = BigEndianWORD(*(WORD *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))) < 0x0fff)
+				if ((phyblk = be16_to_cpu(*(WORD *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))) < 0x0fff)
 					MS_LibSetInitialErrorBlock(us, phyblk);
 
 				EntryOffset += 2;
@@ -455,10 +457,10 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 			}
 
 			idi = &((MemStickBootBlockCIS_IDI *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))->idi.idi;
-			if (LittleEndianWORD(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
+			if (le16_to_cpu(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
 				goto exit;
 
-			us->MS_Lib.BytesPerSector = LittleEndianWORD(idi->wIDIbytesPerSector);
+			us->MS_Lib.BytesPerSector = le16_to_cpu(idi->wIDIbytesPerSector);
 			if (us->MS_Lib.BytesPerSector != MS_BYTES_PER_PAGE)
 				goto exit;
 		}
-- 
1.7.4.1


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

end of thread, other threads:[~2011-03-03 13:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-02 23:48 [PATCH 1/2] staging: keucr: remove unused typedef VOID Jonathan Neuschäfer
2011-03-02 23:48 ` [PATCH 2/2] staging: keucr: use kernel byteorder functions Jonathan Neuschäfer
2011-03-03  7:58   ` Jack Stone
2011-03-03 11:32     ` Jonathan Neuschäfer
2011-03-03 11:38       ` [PATCH v2] " Jonathan Neuschäfer
2011-03-03 11:51         ` Jack Stone
2011-03-03 13:25           ` [PATCH v3 1/2] staging: keucr: remove unused typedef VOID Jonathan Neuschäfer
2011-03-03 13:25             ` [PATCH v3 2/2] staging: keucr: use kernel byteorder functions Jonathan Neuschäfer

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.