Re: [PATCH] add missing intialisation of bgc->dir

From: Lothar WaÃmann
Date: Mon Jul 04 2011 - 12:19:30 EST


Hi,

Grant Likely writes:
> On Mon, Jul 4, 2011 at 9:51 AM, Lothar WaÃmann <LW@xxxxxxxxxxxxxxxxxxx> wrote:
> > Hi,
> >
> >> > > I don't know if this is a valid thing to do or not. ÂNot every GPIO
> >> > > controller supports reading back the initial state from the direction
> >> > > register. ÂI suspect it is better to leave initialization of the
> >> > > direction to the gpio controller driver itself.
> >> > >
> >> > That would mean, that external software would have to have access to
> >> > the bgpio internal data structures which is a Bad Thing(TM) IMO. Or we
> >> > need a function that allows to explicitly initialize the internal
> >> > shadow registers.
> >>
> >> What device are you using this for. ÂAre you using the basic gpio
> >> platform_driver, or do you have a driver using the library part of the
> >> basic gpio code?
> >>
> > I'm using it via drivers/gpio/gpio-mxc.
>
> You can safely do the "bgc->dir = bgc->read_reg(bgc->reg_dir);" in
> gpio-mxc after bgpio_init returns.
>
I know I can do that, but IMO it's a horrible way of programming, to
let a higher SW layer freely mess with the data structures of another
SW layer. There should be accessor functions to do that!


Lothar WaÃmann
--
___________________________________________________________

Ka-Ro electronics GmbH | PascalstraÃe 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
GeschÃftsfÃhrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@xxxxxxxxxxxxxxxxxxx
___________________________________________________________
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/