lkml.org 
[lkml]   [2014]   [Jan]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] mfd: Add realtek USB card reader driver
On Wed, Jan 08, 2014 at 03:56:05PM +0800, Roger Tseng wrote:
> Hi Dan,
>
> >> +int rtsx_usb_ep0_write_register(struct rtsx_ucr *ucr, u16 addr,
> >> + u8 mask, u8 data)
> >> +{
> >> + u16 value = 0, index = 0;
> >> +
> >> + value |= (u16)(3 & 0x03) << 14;
> >> + value |= (u16)(addr & 0x3FFF);
> >
> >Don't do pointless things:
> >
> > value |= 0x03 << 14;
> > value |= addr & 0x3FFF;
> >
> >> + value = ((value << 8) & 0xFF00) | ((value >> 8) & 0x00FF);
> >
> >This is an endian conversion? It is buggy. Use the kernel endian
> >conversion functions cpu_to_le16().
>
> This is not a conversion for endianess with respect to CPU but for
> command format of the device. It should always be performed
> regardless of platform.
>
> In other words, it could be equivalent to:
> value |= 0x03 << 6; // lower byte
> value |= (addr & 0x3F00) >> 8; // lower byte
> value |= (addr & 0xFF) << 8; //higher byte
>
> We think the previous form is easier to read. Should we keep it or
> change to the later one?

To me it's really weird that the standard would specify that the address
is in byte swapped reversed CPU-endian order. But if that's what it
says then I don't care about formatting details. The original code is
fine.

regards,
dan carpenter


\
 
 \ /
  Last update: 2014-01-08 14:41    [W:0.038 / U:0.544 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site