Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: keucr: use kernel byteorder functions

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Reviewed-by: Jack Stone <jwjstone@fastmail.fm>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Jonathan Neuschäfer and committed by
Greg Kroah-Hartman
2145cff5 22a55690

+15 -26
-1
drivers/staging/keucr/TODO
··· 6 6 be merged into the drivers/usb/storage/ directory and 7 7 infrastructure instead. 8 8 - review by the USB developer community 9 - - common.h: use kernel swap, le, & be functions 10 9 - smcommon.h & smilsub.c: use kernel hweight8(), hweight16() 11 10 12 11 Please send any patches for this driver to Al Cho <acho@novell.com> and
-12
drivers/staging/keucr/common.h
··· 9 9 typedef u32 DWORD; 10 10 typedef u32 *PDWORD; 11 11 12 - #define swapWORD(w) ((((unsigned short)(w) << 8) & 0xff00) | \ 13 - (((unsigned short)(w) >> 8) & 0x00ff)) 14 - #define swapDWORD(dw) ((((unsigned long)(dw) << 24) & 0xff000000) | \ 15 - (((unsigned long)(dw) << 8) & 0x00ff0000) | \ 16 - (((unsigned long)(dw) >> 8) & 0x0000ff00) | \ 17 - (((unsigned long)(dw) >> 24) & 0x000000ff)) 18 - 19 - #define LittleEndianWORD(w) (w) 20 - #define LittleEndianDWORD(dw) (dw) 21 - #define BigEndianWORD(w) swapWORD(w) 22 - #define BigEndianDWORD(dw) swapDWORD(dw) 23 - 24 12 #endif 25 13
+15 -13
drivers/staging/keucr/ms.c
··· 1 1 #include <linux/slab.h> 2 + #include <asm/byteorder.h> 3 + 2 4 #include "usb.h" 3 5 #include "scsiglue.h" 4 6 #include "transport.h" ··· 168 166 continue; 169 167 170 168 if (((extdat.mngflg & MS_REG_MNG_SYSFLG) == MS_REG_MNG_SYSFLG_USER) || 171 - (BigEndianWORD(((MemStickBootBlockPage0 *)PageBuffer0)->header.wBlockID) != MS_BOOT_BLOCK_ID) || 172 - (BigEndianWORD(((MemStickBootBlockPage0 *)PageBuffer0)->header.wFormatVersion) != MS_BOOT_BLOCK_FORMAT_VERSION) || 169 + (be16_to_cpu(((MemStickBootBlockPage0 *)PageBuffer0)->header.wBlockID) != MS_BOOT_BLOCK_ID) || 170 + (be16_to_cpu(((MemStickBootBlockPage0 *)PageBuffer0)->header.wFormatVersion) != MS_BOOT_BLOCK_FORMAT_VERSION) || 173 171 (((MemStickBootBlockPage0 *)PageBuffer0)->header.bNumberOfDataEntry != MS_BOOT_BLOCK_DATA_ENTRIES)) 174 172 continue; 175 173 ··· 268 266 MS_ReaderReadPage(us, PhyBlock, 1, (DWORD *)PageBuf, &extdat); 269 267 do 270 268 { 271 - blk = BigEndianWORD(PageBuf[index]); 269 + blk = be16_to_cpu(PageBuf[index]); 272 270 if (blk == MS_LB_NOT_USED) 273 271 break; 274 272 if (blk == us->MS_Lib.Log2PhyMap[0]) ··· 357 355 SysInfo= &(((MemStickBootBlockPage0 *)PageData)->sysinf); 358 356 359 357 if ((SysInfo->bMsClass != MS_SYSINF_MSCLASS_TYPE_1) || 360 - (BigEndianWORD(SysInfo->wPageSize) != MS_SYSINF_PAGE_SIZE) || 358 + (be16_to_cpu(SysInfo->wPageSize) != MS_SYSINF_PAGE_SIZE) || 361 359 ((SysInfo->bSecuritySupport & MS_SYSINF_SECURITY) == MS_SYSINF_SECURITY_SUPPORT) || 362 360 (SysInfo->bReserved1 != MS_SYSINF_RESERVED1) || 363 361 (SysInfo->bReserved2 != MS_SYSINF_RESERVED2) || ··· 378 376 goto exit; 379 377 } 380 378 381 - us->MS_Lib.blockSize = BigEndianWORD(SysInfo->wBlockSize); 382 - us->MS_Lib.NumberOfPhyBlock = BigEndianWORD(SysInfo->wBlockNumber); 383 - us->MS_Lib.NumberOfLogBlock = BigEndianWORD(SysInfo->wTotalBlockNumber)- 2; 379 + us->MS_Lib.blockSize = be16_to_cpu(SysInfo->wBlockSize); 380 + us->MS_Lib.NumberOfPhyBlock = be16_to_cpu(SysInfo->wBlockNumber); 381 + us->MS_Lib.NumberOfLogBlock = be16_to_cpu(SysInfo->wTotalBlockNumber) - 2; 384 382 us->MS_Lib.PagesPerBlock = us->MS_Lib.blockSize * SIZE_OF_KIRO / MS_BYTES_PER_PAGE; 385 383 us->MS_Lib.NumberOfSegment = us->MS_Lib.NumberOfPhyBlock / MS_PHYSICAL_BLOCKS_PER_SEGMENT; 386 - us->MS_Model = BigEndianWORD(SysInfo->wMemorySize); 384 + us->MS_Model = be16_to_cpu(SysInfo->wMemorySize); 387 385 388 386 if (MS_LibAllocLogicalMap(us)) //Allocate to all number of logicalblock and physicalblock 389 387 goto exit; ··· 396 394 { 397 395 DWORD EntryOffset, EntrySize; 398 396 399 - if ((EntryOffset = BigEndianDWORD(SysEntry->entry[i].dwStart)) == 0xffffff) 397 + if ((EntryOffset = be32_to_cpu(SysEntry->entry[i].dwStart)) == 0xffffff) 400 398 continue; 401 399 402 - if ((EntrySize = BigEndianDWORD(SysEntry->entry[i].dwSize)) == 0) 400 + if ((EntrySize = be32_to_cpu(SysEntry->entry[i].dwSize)) == 0) 403 401 continue; 404 402 405 403 if (EntryOffset + MS_BYTES_PER_PAGE + EntrySize > us->MS_Lib.blockSize * (DWORD)SIZE_OF_KIRO) ··· 431 429 PrevPageNumber = PageNumber; 432 430 } 433 431 434 - if ((phyblk = BigEndianWORD(*(WORD *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))) < 0x0fff) 432 + if ((phyblk = be16_to_cpu(*(WORD *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))) < 0x0fff) 435 433 MS_LibSetInitialErrorBlock(us, phyblk); 436 434 437 435 EntryOffset += 2; ··· 457 455 } 458 456 459 457 idi = &((MemStickBootBlockCIS_IDI *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))->idi.idi; 460 - if (LittleEndianWORD(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF) 458 + if (le16_to_cpu(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF) 461 459 goto exit; 462 460 463 - us->MS_Lib.BytesPerSector = LittleEndianWORD(idi->wIDIbytesPerSector); 461 + us->MS_Lib.BytesPerSector = le16_to_cpu(idi->wIDIbytesPerSector); 464 462 if (us->MS_Lib.BytesPerSector != MS_BYTES_PER_PAGE) 465 463 goto exit; 466 464 }