2008-02-29 15:53:24

by Johannes Berg

[permalink] [raw]
Subject: p54: fix EEPROM structure endianness

Since the EEPROM structure is read from hardware, it is
always little endian, annotate that in the struct and
make sure to convert where applicable.

Signed-off-by: Johannes Berg <[email protected]>
Cc: Michael Wu <[email protected]>
---
Does anybody have a p54 card and big endian hardware to test it on? I'm
fairly sure this is a correct change but if it currently works on big
endian the change would be bad (and I'd be rather surprised.)

drivers/net/wireless/p54common.c | 2 +-
drivers/net/wireless/p54common.h | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)

--- everything.orig/drivers/net/wireless/p54common.c 2008-02-28 17:26:23.000000000 +0100
+++ everything/drivers/net/wireless/p54common.c 2008-02-29 13:53:05.000000000 +0100
@@ -212,7 +212,7 @@ int p54_parse_eeprom(struct ieee80211_hw
int err;

wrap = (struct eeprom_pda_wrap *) eeprom;
- entry = (void *)wrap->data + wrap->len;
+ entry = (void *)wrap->data + le16_to_cpu(wrap->len);
i += 2;
i += le16_to_cpu(entry->len)*2;
while (i < len) {
--- everything.orig/drivers/net/wireless/p54common.h 2008-02-19 23:10:32.000000000 +0100
+++ everything/drivers/net/wireless/p54common.h 2008-02-29 13:53:05.000000000 +0100
@@ -53,10 +53,10 @@ struct pda_entry {
} __attribute__ ((packed));

struct eeprom_pda_wrap {
- u32 magic;
- u16 pad;
- u16 len;
- u32 arm_opcode;
+ __le32 magic;
+ __le16 pad;
+ __le16 len;
+ __le32 arm_opcode;
u8 data[0];
} __attribute__ ((packed));





2008-03-02 12:25:07

by Florian Fainelli

[permalink] [raw]
Subject: Re: p54: fix EEPROM structure endianness

Hi Johannes,

Le vendredi 29 f=E9vrier 2008, Johannes Berg a =E9crit=A0:
> ---
> Does anybody have a p54 card and big endian hardware to test it on? I=
'm
> fairly sure this is a correct change but if it currently works on big
> endian the change would be bad (and I'd be rather surprised.)
>

This patch fixes the eeprom fields reading errors that I mentionned on =
the=20
list : http://article.gmane.org/gmane.linux.kernel.wireless.general/117=
94.=20
This also makes the dongle work on my iBook G4.

Can you pleas merge it ?

Thanks.

2008-03-02 13:56:28

by Johannes Berg

[permalink] [raw]
Subject: Re: p54: fix EEPROM structure endianness


On Sun, 2008-03-02 at 13:24 +0100, Florian Fainelli wrote:
> Hi Johannes,
>
> Le vendredi 29 février 2008, Johannes Berg a écrit :
> > ---
> > Does anybody have a p54 card and big endian hardware to test it on? I'm
> > fairly sure this is a correct change but if it currently works on big
> > endian the change would be bad (and I'd be rather surprised.)
> >
>
> This patch fixes the eeprom fields reading errors that I mentionned on the
> list : http://article.gmane.org/gmane.linux.kernel.wireless.general/11794.
> This also makes the dongle work on my iBook G4.
>
> Can you pleas merge it ?

You mean my patch fixes it?

johannes


Attachments:
signature.asc (828.00 B)
This is a digitally signed message part

2008-03-02 14:59:25

by Florian Fainelli

[permalink] [raw]
Subject: Re: p54: fix EEPROM structure endianness

Hi Johannes,

Le dimanche 2 mars 2008, Johannes Berg a =E9crit=A0:
> You mean my patch fixes it?

Yes absolutely, before, I got error from the eeprom parsing function th=
at it=20
could not read all required eeprom fields, leading to a non-working wir=
eless=20
interface, causing oopses sometimes.

With your patch, MAC address, calibration values are read correctly and=
I can=20
use the USB dongle successfully. Of course the dongle does not oops any=
more=20
on big-endian hosts.

Tested-by: Florian Fainelli <[email protected]>

2008-03-02 15:12:16

by Johannes Berg

[permalink] [raw]
Subject: Re: p54: fix EEPROM structure endianness


> Le dimanche 2 mars 2008, Johannes Berg a écrit :
> > You mean my patch fixes it?
>
> Yes absolutely, before, I got error from the eeprom parsing function that it
> could not read all required eeprom fields, leading to a non-working wireless
> interface, causing oopses sometimes.
>
> With your patch, MAC address, calibration values are read correctly and I can
> use the USB dongle successfully. Of course the dongle does not oops anymore
> on big-endian hosts.
>
> Tested-by: Florian Fainelli <[email protected]>

Great, thanks for testing, confirms my suspicions about the eeprom
reading code. Can you do me a favour and also test my patch titled
"[PATCH] p54: fix eeprom parser length sanity checks"?

johannes


Attachments:
signature.asc (828.00 B)
This is a digitally signed message part