linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Use of data types
@ 2010-01-18 12:43 Khushhua Mogambo
  2010-01-18 13:41 ` Uwe Kleine-König
  0 siblings, 1 reply; 9+ messages in thread
From: Khushhua Mogambo @ 2010-01-18 12:43 UTC (permalink / raw)
  To: linux-arm-kernel

Hi
  I starting to port Linux kernel to my companies new ARM based
SoC and development board.

Some of the regs is 16bits wide and some is 32bits width. I ask if
my using u16 and u32 in place of 'unsigned short' and 'unsigned int'
in the whole porting would be acceptable or not?

In different wording, using only u16 and u32 always is considered good
quality or bad?

many thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Use of data types
  2010-01-18 12:43 Use of data types Khushhua Mogambo
@ 2010-01-18 13:41 ` Uwe Kleine-König
  2010-01-18 13:42   ` Matthias Kaehlcke
  2010-01-18 13:48   ` Russell King - ARM Linux
  0 siblings, 2 replies; 9+ messages in thread
From: Uwe Kleine-König @ 2010-01-18 13:41 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On Mon, Jan 18, 2010 at 09:43:12PM +0900, Khushhua Mogambo wrote:
> Hi
>   I starting to port Linux kernel to my companies new ARM based
> SoC and development board.
> 
> Some of the regs is 16bits wide and some is 32bits width. I ask if
> my using u16 and u32 in place of 'unsigned short' and 'unsigned int'
> in the whole porting would be acceptable or not?
> 
> In different wording, using only u16 and u32 always is considered good
> quality or bad?
I prefer using u32 over int.  Still more if your register space isn't uniform.

Best regards
Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-K?nig            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Use of data types
  2010-01-18 13:41 ` Uwe Kleine-König
@ 2010-01-18 13:42   ` Matthias Kaehlcke
  2010-01-18 13:52     ` Russell King - ARM Linux
       [not found]     ` <4B546900.3020506@ru.mvista.com>
  2010-01-18 13:48   ` Russell King - ARM Linux
  1 sibling, 2 replies; 9+ messages in thread
From: Matthias Kaehlcke @ 2010-01-18 13:42 UTC (permalink / raw)
  To: linux-arm-kernel

El Mon, Jan 18, 2010 at 02:41:20PM +0100 Uwe Kleine-K?nig ha dit:

> On Mon, Jan 18, 2010 at 09:43:12PM +0900, Khushhua Mogambo wrote:
> > Hi
> >   I starting to port Linux kernel to my companies new ARM based
> > SoC and development board.
> > 
> > Some of the regs is 16bits wide and some is 32bits width. I ask if
> > my using u16 and u32 in place of 'unsigned short' and 'unsigned int'
> > in the whole porting would be acceptable or not?
> > 
> > In different wording, using only u16 and u32 always is considered good
> > quality or bad?
> I prefer using u32 over int.  Still more if your register space isn't uniform.

ditto

how about using the C99 types uint32_t, ... in the kernel? 

-- 
Matthias Kaehlcke
Embedded Linux Developer
Barcelona

              Insanity: doing the same thing over and over
                again and expecting different results
                            (Albert Einstein)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Use of data types
  2010-01-18 13:41 ` Uwe Kleine-König
  2010-01-18 13:42   ` Matthias Kaehlcke
@ 2010-01-18 13:48   ` Russell King - ARM Linux
  1 sibling, 0 replies; 9+ messages in thread
From: Russell King - ARM Linux @ 2010-01-18 13:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jan 18, 2010 at 02:41:20PM +0100, Uwe Kleine-K?nig wrote:
> Hello,
> 
> On Mon, Jan 18, 2010 at 09:43:12PM +0900, Khushhua Mogambo wrote:
> > Hi
> >   I starting to port Linux kernel to my companies new ARM based
> > SoC and development board.
> > 
> > Some of the regs is 16bits wide and some is 32bits width. I ask if
> > my using u16 and u32 in place of 'unsigned short' and 'unsigned int'
> > in the whole porting would be acceptable or not?
> > 
> > In different wording, using only u16 and u32 always is considered good
> > quality or bad?
> I prefer using u32 over int.  Still more if your register space isn't uniform.

u32 should be used for things that you want to be an unsigned 32-bit and
nothing else.  int and unsigned int for integers where the size doesn't
matter that much.

So, if you want a data type that is unsigned 32-bit, use u32.  If not,
use unsigned int or similar.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Use of data types
  2010-01-18 13:42   ` Matthias Kaehlcke
@ 2010-01-18 13:52     ` Russell King - ARM Linux
       [not found]     ` <4B546900.3020506@ru.mvista.com>
  1 sibling, 0 replies; 9+ messages in thread
From: Russell King - ARM Linux @ 2010-01-18 13:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jan 18, 2010 at 02:42:15PM +0100, Matthias Kaehlcke wrote:
> El Mon, Jan 18, 2010 at 02:41:20PM +0100 Uwe Kleine-K?nig ha dit:
> 
> > On Mon, Jan 18, 2010 at 09:43:12PM +0900, Khushhua Mogambo wrote:
> > > Hi
> > >   I starting to port Linux kernel to my companies new ARM based
> > > SoC and development board.
> > > 
> > > Some of the regs is 16bits wide and some is 32bits width. I ask if
> > > my using u16 and u32 in place of 'unsigned short' and 'unsigned int'
> > > in the whole porting would be acceptable or not?
> > > 
> > > In different wording, using only u16 and u32 always is considered good
> > > quality or bad?
> > I prefer using u32 over int.  Still more if your register space isn't uniform.
> 
> ditto
> 
> how about using the C99 types uint32_t, ... in the kernel? 

You might want to read Documentation/CodingStyle chapter 5, which covers
some of these issues.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Use of data types
       [not found]     ` <4B546900.3020506@ru.mvista.com>
@ 2010-01-19 11:57       ` Khushhua Mogambo
  2010-01-19 17:42         ` Russell King - ARM Linux
  2010-01-20  5:25         ` Ben Dooks
  0 siblings, 2 replies; 9+ messages in thread
From: Khushhua Mogambo @ 2010-01-19 11:57 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jan 18, 2010 at 10:58 PM, Sergei Shtylyov
<sshtylyov@ru.mvista.com> wrote:
> Hello.
>
> Matthias Kaehlcke wrote:
>
>>>> Hi
>>>> ?I starting to port Linux kernel to my companies new ARM based
>>>> SoC and development board.
>>>>
>>>> Some of the regs is 16bits wide and some is 32bits width. I ask if
>>>> my using u16 and u32 in place of 'unsigned short' and 'unsigned int'
>>>> in the whole porting would be acceptable or not?
>>>>
>>>> In different wording, using only u16 and u32 always is considered good
>>>> quality or bad?
>>>>
>>>
>>> I prefer using u32 over int. ?Still more if your register space isn't
>>> uniform.
>>>
>>
>> ditto
>>
>> how about using the C99 types uint32_t, ... in the kernel?
>
> ?They are actually used in some places but this is generally frowned upon.
> They are for userspace.
>
> WBR, Sergei

from thread, i understand that u32 is encouraged whenever we have reason. I m
going to use u8,16,32 heavily.

Thanks to every one who replied and helped me.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Use of data types
  2010-01-19 11:57       ` Khushhua Mogambo
@ 2010-01-19 17:42         ` Russell King - ARM Linux
  2010-01-20 12:15           ` Khushhua Mogambo
  2010-01-20  5:25         ` Ben Dooks
  1 sibling, 1 reply; 9+ messages in thread
From: Russell King - ARM Linux @ 2010-01-19 17:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 19, 2010 at 08:57:03PM +0900, Khushhua Mogambo wrote:
> from thread, i understand that u32 is encouraged whenever we have reason. I m
> going to use u8,16,32 heavily.

Incorrect.

As I said, use u8,u16,u32 when you need something that's of that size
(eg, for storing values from hardware registers.)  If you don't require
something of a specific size, then don't use them.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Use of data types
  2010-01-19 11:57       ` Khushhua Mogambo
  2010-01-19 17:42         ` Russell King - ARM Linux
@ 2010-01-20  5:25         ` Ben Dooks
  1 sibling, 0 replies; 9+ messages in thread
From: Ben Dooks @ 2010-01-20  5:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 19, 2010 at 08:57:03PM +0900, Khushhua Mogambo wrote:
> On Mon, Jan 18, 2010 at 10:58 PM, Sergei Shtylyov
> <sshtylyov@ru.mvista.com> wrote:
> > Hello.
> >
> > Matthias Kaehlcke wrote:
> >
> >>>> Hi
> >>>> ?I starting to port Linux kernel to my companies new ARM based
> >>>> SoC and development board.
> >>>>
> >>>> Some of the regs is 16bits wide and some is 32bits width. I ask if
> >>>> my using u16 and u32 in place of 'unsigned short' and 'unsigned int'
> >>>> in the whole porting would be acceptable or not?
> >>>>
> >>>> In different wording, using only u16 and u32 always is considered good
> >>>> quality or bad?
> >>>>
> >>>
> >>> I prefer using u32 over int. ?Still more if your register space isn't
> >>> uniform.
> >>>
> >>
> >> ditto
> >>
> >> how about using the C99 types uint32_t, ... in the kernel?
> >
> > ?They are actually used in some places but this is generally frowned upon.
> > They are for userspace.
> >
> > WBR, Sergei
> 
> from thread, i understand that u32 is encouraged whenever we have reason. I m
> going to use u8,16,32 heavily.

It can depend on where it is being used, passing u8 and u16 around from
function to function can cost as the compiler tends to output code
to restrict the range of the registers' contents, thus u32 can end up
being a better choice.

-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Use of data types
  2010-01-19 17:42         ` Russell King - ARM Linux
@ 2010-01-20 12:15           ` Khushhua Mogambo
  0 siblings, 0 replies; 9+ messages in thread
From: Khushhua Mogambo @ 2010-01-20 12:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jan 20, 2010 at 2:42 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Tue, Jan 19, 2010 at 08:57:03PM +0900, Khushhua Mogambo wrote:
>> from thread, i understand that u32 is encouraged whenever we have reason. I m
>> going to use u8,16,32 heavily.
>
> Incorrect.
>
> As I said, use u8,u16,u32 when you need something that's of that size
> (eg, for storing values from hardware registers.) ?If you don't require
> something of a specific size, then don't use them.
ok I undrstand. thanking you very much.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-01-20 12:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-18 12:43 Use of data types Khushhua Mogambo
2010-01-18 13:41 ` Uwe Kleine-König
2010-01-18 13:42   ` Matthias Kaehlcke
2010-01-18 13:52     ` Russell King - ARM Linux
     [not found]     ` <4B546900.3020506@ru.mvista.com>
2010-01-19 11:57       ` Khushhua Mogambo
2010-01-19 17:42         ` Russell King - ARM Linux
2010-01-20 12:15           ` Khushhua Mogambo
2010-01-20  5:25         ` Ben Dooks
2010-01-18 13:48   ` Russell King - ARM Linux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).