Re: [PATCH] misc drivers/net endianness noise

From: Harvey Harrison
Date: Tue May 20 2008 - 20:48:21 EST


On Wed, 2008-05-21 at 01:34 +0100, Al Viro wrote:
> Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> ---
> 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/