lkml.org 
[lkml]   [2008]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] misc drivers/net endianness noise
From
Date
On Wed, 2008-05-21 at 01:34 +0100, Al Viro wrote:
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
> tx_buf = catc->tx_buf[catc->tx_idx] + catc->tx_ptr;
> - *((u16*)tx_buf) = (catc->is_f5u011) ? cpu_to_be16((u16)skb->len) : cpu_to_le16((u16)skb->len);
> + if (catc->is_f5u011)
> + *(__be16 *)tx_buf = cpu_to_be16(skb->len);
> + else
> + *(__le16 *)tx_buf = cpu_to_le16(skb->len);
> skb_copy_from_linear_data(skb, tx_buf + 2, skb->len);

I was contemplating an api like:

void put_le16(u16 val, __le16 *ptr)
{
*ptr = cpu_to_le16(val);
}

which would allow the above to become:

if (catc->is_f5u011)
put_be16(skb->len, tx_buf);
else
put_le16(skb->len, tx_buf);

Thoughts?

Harvey



\
 
 \ /
  Last update: 2008-05-21 02:51    [W:0.062 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site