From: Ralf Baechle <ralf@linux-mips.org>
To: Florian Fainelli <florian.fainelli@telecomint.eu>
Cc: Daniel Laird <daniel.j.laird@nxp.com>, linux-mips@linux-mips.org
Subject: Re: [PATCH] : Add support for NXP PNX833x (STB222/5) into linux kernel (UPDATE)
Date: Thu, 12 Jun 2008 13:49:20 +0100 [thread overview]
Message-ID: <20080612124920.GA24343@linux-mips.org> (raw)
In-Reply-To: <200806121441.01705.florian.fainelli@telecomint.eu>
On Thu, Jun 12, 2008 at 02:41:00PM +0200, Florian Fainelli wrote:
> Le Thursday 12 June 2008 14:29:47 Daniel Laird, vous avez écrit :
> > linux-2.6.26-rc4.orig/include/asm-mips/mach-pnx833x/gpio.h
> > linux-2.6.26-rc4/include/asm-mips/mach-pnx833x/gpio.h
> > +
> > +/* Initialize GPIO to a known state */
> > +static inline void pnx833x_gpio_init(void)
> > +{
> > + PNX833X_PIO_DIR = 0;
> > + PNX833X_PIO_DIR2 = 0;
> > + PNX833X_PIO_SEL = 0;
> > + PNX833X_PIO_SEL2 = 0;
> > + PNX833X_PIO_INT_EDGE = 0;
> > + PNX833X_PIO_INT_HI = 0;
> > + PNX833X_PIO_INT_LO = 0;
>
> It would be better if you for instance map a structure to your PIO registers,
> like this :
>
> struct pnx833x_pio_reg {
> u32 in;
> u32 out;
> [..]
> };
>
> Then the gpio code would ioremap this registers like this in
> pnx833x_gpio_init :
>
> struct pnx833x_pio_reg *gpio_reg = ioremap_nocache(0xF00, sizeof(struct
> pnx833x_gpio_reg));
> [..]
>
> So that you could use writel/readl like this :
>
> writel(0, &gpio_reg->in);
>
> which looks nicer.
Actually for portable drivers the practice of using structs is discouraged.
The alignment rules are not the same on every architecture, so:
struct example {
u16 var1;
u32 var2;
};
Would have var2 at offset 2 on m68k but on offset 4 on MIPS. So hardcoding
the offsets by some other means is preferable for portable code. As for
this code which is meant to be MIPS only I'd not be religous but it's good
practice to try to always write portable code.
Ralf
next prev parent reply other threads:[~2008-06-12 12:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-12 12:29 [PATCH] : Add support for NXP PNX833x (STB222/5) into linux kernel (UPDATE) Daniel Laird
2008-06-12 12:41 ` Florian Fainelli
2008-06-12 12:49 ` Ralf Baechle [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-06-12 12:41 Daniel Laird
2008-06-16 8:38 Daniel Laird
2008-06-16 9:23 ` Ralf Baechle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080612124920.GA24343@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=daniel.j.laird@nxp.com \
--cc=florian.fainelli@telecomint.eu \
--cc=linux-mips@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox