Commit c873879c authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

[BNX2]: Fix nvram write logic.

The nvram dword alignment logic was broken when writing less than 4
bytes on a non-aligned offset.  It was missing logic to round the
length to 4 bytes.

The page erase code is also moved so that it is only called when
using non-buffered flash for better code clarity.

Update version to 1.5.7.

Based on initial patch from Tony Cureington <tony.cureington@hp.com>.
Signed-off-by: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b59e139b
...@@ -54,8 +54,8 @@ ...@@ -54,8 +54,8 @@
#define DRV_MODULE_NAME "bnx2" #define DRV_MODULE_NAME "bnx2"
#define PFX DRV_MODULE_NAME ": " #define PFX DRV_MODULE_NAME ": "
#define DRV_MODULE_VERSION "1.5.6" #define DRV_MODULE_VERSION "1.5.7"
#define DRV_MODULE_RELDATE "March 28, 2007" #define DRV_MODULE_RELDATE "March 29, 2007"
#define RUN_AT(x) (jiffies + (x)) #define RUN_AT(x) (jiffies + (x))
...@@ -3099,21 +3099,19 @@ bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf, ...@@ -3099,21 +3099,19 @@ bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf,
if ((align_start = (offset32 & 3))) { if ((align_start = (offset32 & 3))) {
offset32 &= ~3; offset32 &= ~3;
len32 += (4 - align_start); len32 += align_start;
if (len32 < 4)
len32 = 4;
if ((rc = bnx2_nvram_read(bp, offset32, start, 4))) if ((rc = bnx2_nvram_read(bp, offset32, start, 4)))
return rc; return rc;
} }
if (len32 & 3) { if (len32 & 3) {
if ((len32 > 4) || !align_start) {
align_end = 4 - (len32 & 3); align_end = 4 - (len32 & 3);
len32 += align_end; len32 += align_end;
if ((rc = bnx2_nvram_read(bp, offset32 + len32 - 4, if ((rc = bnx2_nvram_read(bp, offset32 + len32 - 4, end, 4)))
end, 4))) {
return rc; return rc;
} }
}
}
if (align_start || align_end) { if (align_start || align_end) {
align_buf = kmalloc(len32, GFP_KERNEL); align_buf = kmalloc(len32, GFP_KERNEL);
...@@ -3187,6 +3185,10 @@ bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf, ...@@ -3187,6 +3185,10 @@ bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf,
if ((rc = bnx2_enable_nvram_write(bp)) != 0) if ((rc = bnx2_enable_nvram_write(bp)) != 0)
goto nvram_write_end; goto nvram_write_end;
/* Loop to write back the buffer data from page_start to
* data_start */
i = 0;
if (bp->flash_info->buffered == 0) {
/* Erase the page */ /* Erase the page */
if ((rc = bnx2_nvram_erase_page(bp, page_start)) != 0) if ((rc = bnx2_nvram_erase_page(bp, page_start)) != 0)
goto nvram_write_end; goto nvram_write_end;
...@@ -3194,10 +3196,6 @@ bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf, ...@@ -3194,10 +3196,6 @@ bnx2_nvram_write(struct bnx2 *bp, u32 offset, u8 *data_buf,
/* Re-enable the write again for the actual write */ /* Re-enable the write again for the actual write */
bnx2_enable_nvram_write(bp); bnx2_enable_nvram_write(bp);
/* Loop to write back the buffer data from page_start to
* data_start */
i = 0;
if (bp->flash_info->buffered == 0) {
for (addr = page_start; addr < data_start; for (addr = page_start; addr < data_start;
addr += 4, i += 4) { addr += 4, i += 4) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment