Skip to contentSkip to conversation

bt8xx: unaligned access

PATCH In review Al Viro 3 participants 4 messages May 21, 2008 Media (V4L/DVB)

lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 1/1 bt8xx: unaligned access

---
 drivers/media/video/bt8xx/bttv-cards.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/media/video/bt8xx/bttv-cards.c +3 -2
index f20a01c..8ef0424 100644
@@ -34,6 +34,7 @@
 #include <linux/firmware.h>
 #include <net/checksum.h>
 
+#include <asm/unaligned.h>
 #include <asm/io.h>
 
 #include "bttvp.h"
@@ -3858,7 +3859,7 @@ static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256])
 		ee += i;
 
 		/* found a valid descriptor */
-		type = be16_to_cpup((u16*)(ee+4));
+		type = get_unaligned_be16((__be16 *)(ee+4));
 
 		switch(type) {
 		/* 848 based */
@@ -3918,7 +3919,7 @@ static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256])
 			       btv->c.nr, type);
 			break;
 		}
-		serial = be32_to_cpup((u32*)(ee+6));
+		serial = get_unaligned_be32((__be32 *)(ee+6));
 	}
 
 	printk(KERN_INFO "bttv%d: osprey eeprom: card=%d '%s' serial=%u\n",
Signature · 1 line
1.5.3.GIT
#1 lore raw
Quoted 18 lines · Al Viro
---
 drivers/media/video/bt8xx/bttv-cards.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/media/video/bt8xx/bttv-cards.c +1 -0
index f20a01c..8ef0424 100644
@@ -34,6 +34,7 @@
 #include <linux/firmware.h>
 #include <net/checksum.h>
 
+#include <asm/unaligned.h>
 #include <asm/io.h>
 
 #include "bttvp.h"

drivers/media/video/bt8xx/bttv-cards.c static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256]) · line 3862

Quoted 5 lines
drivers/media/video/bt8xx/bttv-cards.c +1 -1
@@ -3858,7 +3859,7 @@ static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256])
 		ee += i;
 
 		/* found a valid descriptor */
-		type = be16_to_cpup((u16*)(ee+4));
+		type = get_unaligned_be16((__be16 *)(ee+4));

The casts aren't strictly necessary here. Any reason to keep it?

drivers/media/video/bt8xx/bttv-cards.c static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256]) · line 3922

Quoted 9 lines
drivers/media/video/bt8xx/bttv-cards.c +1 -1
 		switch(type) {
 		/* 848 based */
@@ -3918,7 +3919,7 @@ static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256])
 			       btv->c.nr, type);
 			break;
 		}
-		serial = be32_to_cpup((u32*)(ee+6));
+		serial = get_unaligned_be32((__be32 *)(ee+6));

Ditto.

Cheers,

Harvey

#2 lore raw
Quoted 4 lines · Harvey Harrison

drivers/media/video/bt8xx/bttv-cards.c static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256]) · line 3862

Quoted 2 lines
drivers/media/video/bt8xx/bttv-cards.c +1 -1
-		type = be16_to_cpup((u16*)(ee+4));
+		type = get_unaligned_be16((__be16 *)(ee+4));

The casts aren't strictly necessary here. Any reason to keep it?

I'd rather have them explicit *and* make get_unaligned_* take the pointer of right type, so that it'd eat things like void * and __be16 *, but warn on int * et.al. One too many brainos seen in that area...

#3 lore raw
Quoted 9 lines · Al Viro
Quoted 4 lines · Harvey Harrison

drivers/media/video/bt8xx/bttv-cards.c static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256]) · line 3862

Quoted 2 lines
drivers/media/video/bt8xx/bttv-cards.c +1 -1
-		type = be16_to_cpup((u16*)(ee+4));
+		type = get_unaligned_be16((__be16 *)(ee+4));

The casts aren't strictly necessary here. Any reason to keep it?

I'd rather have them explicit *and* make get_unaligned_* take the pointer of right type, so that it'd eat things like void * and __be16 *, but warn on int * et.al. One too many brainos seen in that area...

You want me to patch the unaligned guys to take typed pointers and follow it through? Or do you mind?

Cheers,

Harvey