powerpc/pmac: Use string library in nvram code
- Use memchr_inv to check if the data contains all 0xFF bytes. It is faster than looping for each byte. - Use memcmp to compare memory areas Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
parent
ad5b7f1350
commit
2d4b971287
@ -279,7 +279,7 @@ static u32 core99_check(u8* datas)
|
||||
|
||||
static int sm_erase_bank(int bank)
|
||||
{
|
||||
int stat, i;
|
||||
int stat;
|
||||
unsigned long timeout;
|
||||
|
||||
u8 __iomem *base = (u8 __iomem *)nvram_data + core99_bank*NVRAM_SIZE;
|
||||
@ -301,8 +301,7 @@ static int sm_erase_bank(int bank)
|
||||
out_8(base, SM_FLASH_CMD_CLEAR_STATUS);
|
||||
out_8(base, SM_FLASH_CMD_RESET);
|
||||
|
||||
for (i=0; i<NVRAM_SIZE; i++)
|
||||
if (base[i] != 0xff) {
|
||||
if (memchr_inv(base, 0xff, NVRAM_SIZE)) {
|
||||
printk(KERN_ERR "nvram: Sharp/Micron flash erase failed !\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
@ -336,8 +335,7 @@ static int sm_write_bank(int bank, u8* datas)
|
||||
}
|
||||
out_8(base, SM_FLASH_CMD_CLEAR_STATUS);
|
||||
out_8(base, SM_FLASH_CMD_RESET);
|
||||
for (i=0; i<NVRAM_SIZE; i++)
|
||||
if (base[i] != datas[i]) {
|
||||
if (memcmp(base, datas, NVRAM_SIZE)) {
|
||||
printk(KERN_ERR "nvram: Sharp/Micron flash write failed !\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
@ -346,7 +344,7 @@ static int sm_write_bank(int bank, u8* datas)
|
||||
|
||||
static int amd_erase_bank(int bank)
|
||||
{
|
||||
int i, stat = 0;
|
||||
int stat = 0;
|
||||
unsigned long timeout;
|
||||
|
||||
u8 __iomem *base = (u8 __iomem *)nvram_data + core99_bank*NVRAM_SIZE;
|
||||
@ -383,8 +381,7 @@ static int amd_erase_bank(int bank)
|
||||
out_8(base, 0xf0);
|
||||
udelay(1);
|
||||
|
||||
for (i=0; i<NVRAM_SIZE; i++)
|
||||
if (base[i] != 0xff) {
|
||||
if (memchr_inv(base, 0xff, NVRAM_SIZE)) {
|
||||
printk(KERN_ERR "nvram: AMD flash erase failed !\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
@ -429,8 +426,7 @@ static int amd_write_bank(int bank, u8* datas)
|
||||
out_8(base, 0xf0);
|
||||
udelay(1);
|
||||
|
||||
for (i=0; i<NVRAM_SIZE; i++)
|
||||
if (base[i] != datas[i]) {
|
||||
if (memcmp(base, datas, NVRAM_SIZE)) {
|
||||
printk(KERN_ERR "nvram: AMD flash write failed !\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user