dvb-usb: unaligned
PATCH 1/1 dvb-usb: unaligned
--- drivers/media/dvb/dvb-usb/dvb-usb-firmware.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +1 -1
@@ -127,7 +127,7 @@ int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,if ((*pos + hx->len +4 ) >= fw->size)return -EINVAL ; - hx->addr =le16_to_cpu ( *((u16 *) &b[1 ]) ); + hx->addr = b[1 ] | (b[2 ] <<8 ); hx->type = b[3 ];if (hx->type ==0x04 ) {
Signature · 1 line
1.5.3.GIT
Quoted 10 lines · Al Viro
Signed-off-by Al Viro <[email protected]>--- drivers/media/dvb/dvb-usb/dvb-usb-firmware.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +0
-0
drivers/media/dvb/dvb-usb/dvb-usb-firmware.c int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, · line 130
Quoted 5 lines
drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +1
-1@@ -127,7 +127,7 @@ int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,if ((*pos + hx->len +4 ) >= fw->size)return -EINVAL ; - hx->addr =le16_to_cpu ( *((u16 *) &b[1 ]) ); + hx->addr = b[1 ] | (b[2 ] <<8 );
hx->addr = get_unaligned_le16(&b[1]);
Cheers,
Harvey
Quoted 14 lines · Harvey Harrison
Quoted 13 lines · Al Viro
Signed-off-by Al Viro <[email protected]>--- drivers/media/dvb/dvb-usb/dvb-usb-firmware.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +0
-0@@ -127,7 +127,7 @@ int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,if ((*pos + hx->len +4 ) >= fw->size)return -EINVAL ;
Quoted 4 lines
drivers/media/dvb/dvb-usb/dvb-usb-firmware.c int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, · line 130
Quoted 2 lines
drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +1
-1- hx->addr =le16_to_cpu ( *((u16 *) &b[1 ]) ); + hx->addr = b[1 ] | (b[2 ] <<8 );???hx->addr =
get_unaligned_le16(&b[1]);
Again, what's the benefit? Having a function doesn't mean that we need to use it religiously - if it doesn't make things more clear...
Quoted 15 lines · Al Viro
Quoted 14 lines · Harvey Harrison
Quoted 13 lines · Al Viro
Signed-off-by Al Viro <[email protected]>--- drivers/media/dvb/dvb-usb/dvb-usb-firmware.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +0
-0@@ -127,7 +127,7 @@ int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,if ((*pos + hx->len +4 ) >= fw->size)return -EINVAL ;
Quoted 7 lines
Quoted 4 lines
drivers/media/dvb/dvb-usb/dvb-usb-firmware.c int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, · line 130
Quoted 2 lines
drivers/media/dvb/dvb-usb/dvb-usb-firmware.c +1
-1- hx->addr =le16_to_cpu ( *((u16 *) &b[1 ]) ); + hx->addr = b[1 ] | (b[2 ] <<8 );???hx->addr =
get_unaligned_le16(&b[1]);Again, what's the benefit? Having a function doesn't mean that we need to use it religiously - if it doesn't make things more clear...
Just curious, is gcc smart enough to just turn this into a 2-byte load on x86 (little-endian with no particular alignment constraints). Otherwise it would have a better chance at doing this using the helper function.
You're right though, it is a small consideration.
Harvey