Re: [RFC/PATCH 2/8] usb: ncm: added ncm.h with auxiliary definitions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 9 Apr 2010, Yauheni Kaliuta wrote:

>  > >  > > +static inline void put_ncm(__le16 **p, unsigned size, unsigned val)
>  > >  > > +{
>  > >  > > +        switch (size) {
>  > >  > > +        case 1:
>  > >  > > +                put_unaligned_le16((uint16_t)val, *p);
>  > >  > > +                break;
>  > >  > > +        case 2:
>  > >  > > +                put_unaligned_le32((uint32_t)val, *p);

You can (and should) use u16 and u32 instead of uint16_t and uint32_t.

>  > >  > > +
>  > >  > > +                break;
>  > >  > > +        default:
>  > >  > > +                BUG();
>  > >  > > +        }
>  > >  > > +
>  > >  > > +        *p += size;
>  > >  > > +}
>  > > 
>  > >  > Don't we have functions for this type of thing already?
>  > > 
>  > > Thanks a lot, but I could not find it. Could you point?
> 
>  > I have not looked that hard, but it should be somewhere.
> 
> Whould be fine, because I checked and could not find. I asked couple of
> guys around, they do not know as well.

I have never heard of any function that would do a variable-length copy 
combined with a byte swap.  Of course, the HID driver has to copy 
fields whose lengths can be a variable number of bits (not bytes!), 
which is even harder.

Alan Stern

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

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux