[PATCH v2 3/3][MTD] P4080/mtd: Fix the freescale lbc issue with 36bit mode

Zang Roy-R61911 r61911 at freescale.com
Tue Sep 14 16:20:16 EST 2010



> -----Original Message-----
> From: Artem Bityutskiy [mailto:dedekind1 at gmail.com]
> Sent: Monday, September 13, 2010 22:28 PM
> To: Timur Tabi
> Cc: Zang Roy-R61911; Anton Vorontsov; Wood Scott-B07421; Lan Chunhe-B25806;
> linuxppc-dev at ozlabs.org; linux-mtd at lists.infradead.org; akpm at linux-
> foundation.org; dwmw2 at infradead.org; Gala Kumar-B11780
> Subject: Re: [PATCH v2 3/3][MTD] P4080/mtd: Fix the freescale lbc issue with
> 36bit mode
> 
> On Mon, 2010-09-13 at 09:10 -0500, Timur Tabi wrote:
> > On Mon, Sep 13, 2010 at 2:30 AM, Zang Roy-R61911 <r61911 at freescale.com>
> wrote:
> >
> > > What is the different for unsigned int and u32? I think they are same.
> >
> > Roy, please don't ever write code that assumes that sizeof(int) == 4.
> > There's a reason why we have unsized integer types (like int, long,
> > and short) and sized integer types (like u8, u16, u32).  If you want
> > an integer of a specific size, you should use a sized integer type.
> 
> Yes, sizeof(int) == 4 assumption is not good.
> 
> But sizeof(int) >= 4 is perfectly fine.
> 
> It is OK to rely on the fact that unsigned int is _at least_ 32-bit, not
> less. And if you know 32 bits is enough, and you are fine with more, it
> is _better_ to avoid u32. Simply because with unsigned int you do not
> limit the compiler and CPU and let them use native integers, rather than
> strictly 32-bit. This potentially gives the compiler and CPU more room
> for optimization.
> 
> I see people use u32 and the friends too much. It is safe and better to
> use native types, unless you really have to make the variable to be
> strictly u32.
> 
> I did not follow this particular conversation and do not judge which
> type is better in this case. I am talking in general. :-)

The function will return fixed 32bit. so u32 should be OK.
Thanks.
Roy


More information about the Linuxppc-dev mailing list