qlge: bugfix: Fix endian issue when reading flash.

Signed-off-by: Ron Mercer <ron.mercer@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Ron Mercer 2009-02-02 13:53:57 -08:00 committed by David S. Miller
parent e408b8dcb5
commit 26351479ed
2 changed files with 12 additions and 9 deletions

View file

@ -787,12 +787,12 @@ struct mbox_params {
struct flash_params { struct flash_params {
u8 dev_id_str[4]; u8 dev_id_str[4];
u16 size; __le16 size;
u16 csum; __le16 csum;
u16 ver; __le16 ver;
u16 sub_dev_id; __le16 sub_dev_id;
u8 mac_addr[6]; u8 mac_addr[6];
u16 res; __le16 res;
}; };

View file

@ -641,7 +641,7 @@ static void ql_enable_all_completion_interrupts(struct ql_adapter *qdev)
} }
static int ql_read_flash_word(struct ql_adapter *qdev, int offset, u32 *data) static int ql_read_flash_word(struct ql_adapter *qdev, int offset, __le32 *data)
{ {
int status = 0; int status = 0;
/* wait for reg to come ready */ /* wait for reg to come ready */
@ -656,8 +656,11 @@ static int ql_read_flash_word(struct ql_adapter *qdev, int offset, u32 *data)
FLASH_ADDR, FLASH_ADDR_RDY, FLASH_ADDR_ERR); FLASH_ADDR, FLASH_ADDR_RDY, FLASH_ADDR_ERR);
if (status) if (status)
goto exit; goto exit;
/* get the data */ /* This data is stored on flash as an array of
*data = ql_read32(qdev, FLASH_DATA); * __le32. Since ql_read32() returns cpu endian
* we need to swap it back.
*/
*data = cpu_to_le32(ql_read32(qdev, FLASH_DATA));
exit: exit:
return status; return status;
} }
@ -666,7 +669,7 @@ static int ql_get_flash_params(struct ql_adapter *qdev)
{ {
int i; int i;
int status; int status;
u32 *p = (u32 *)&qdev->flash; __le32 *p = (__le32 *)&qdev->flash;
if (ql_sem_spinlock(qdev, SEM_FLASH_MASK)) if (ql_sem_spinlock(qdev, SEM_FLASH_MASK))
return -ETIMEDOUT; return -ETIMEDOUT;