From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Stefan Roese <sr@denx.de>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: PPC440EPx gpio driver
Date: Thu, 9 Oct 2008 23:03:40 +0400 [thread overview]
Message-ID: <20081009190340.GA28107@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <200810092046.44665.sr@denx.de>
On Thu, Oct 09, 2008 at 08:46:44PM +0200, Stefan Roese wrote:
[...]
> > +struct ppc4xx_gpio_chip {
> > + struct of_mm_gpio_chip mm_gc;
> > + spinlock_t lock;
> > + u32 shadow_or;
> > + u32 shadow_tcr;
> > + u32 shadow_osrl;
> > + u32 shadow_osrh;
> > + u32 shadow_tsrl;
> > + u32 shadow_tsrh;
> > + u32 shadow_odr;
> > +};
>
> Do we really need all those shadow registers? Access to the "real" registers
> is done while holding the spinlock.
The shadowed registers aren't about holding a spinlock, but are
about open drain pins and the fact that some GPIO controllers are
using single "data" register for "read state", "set state" and
"clear state" GPIO operations.
See Grant's reply:
http://ozlabs.org/pipermail/linuxppc-dev/2008-January/050826.html
(I didn't look for the hardware details of this driver, so I don't
know if the driver really needs to shadow the registers.)
[...]
> > + for_each_compatible_node(np, NULL, "amcc,ppc4xx-gpio") {
> > + int ret;
> > + struct ppc4xx_gpio_chip *ppc4xx_gc;
> > + struct of_mm_gpio_chip *mm_gc;
> > + struct of_gpio_chip *of_gc;
> > + struct gpio_chip *gc;
> > +
> > + ppc4xx_gc = kzalloc(sizeof(*ppc4xx_gc), GFP_KERNEL);
> > + if (!ppc4xx_gc) {
> > + ret = -ENOMEM;
> > + goto err;
> > + }
> > +
> > + spin_lock_init(&ppc4xx_gc->lock);
> > +
> > + mm_gc = &ppc4xx_gc->mm_gc;
> > + of_gc = &mm_gc->of_gc;
> > + gc = &of_gc->gc;
> > +
> > + mm_gc->save_regs = ppc4xx_gpio_save_regs;
> > + of_gc->gpio_cells = 2;
> > + gc->ngpio = 32;
> > + gc->direction_input = ppc4xx_gpio_dir_in;
> > + gc->direction_output = ppc4xx_gpio_dir_out;
> > + gc->get = ppc4xx_gpio_get;
> > + gc->set = ppc4xx_gpio_set;
> > +
> > + ret = of_mm_gpiochip_add(np, mm_gc);
> > + if (ret)
> > + goto err;
> > + continue;
> > +err:
> > + pr_err("%s: registration failed with status %d\n",
> > + np->full_name, ret);
> > + kfree(ppc4xx_gc);
>
> This probably crashes if the kzalloc() fails above.
kfree(NULL); is defined to be a no-op.
Thanks,
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
next prev parent reply other threads:[~2008-10-09 19:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-08 20:56 PPC440EPx gpio driver Steven A. Falco
2008-10-08 21:33 ` Steven A. Falco
2008-10-09 13:49 ` Anton Vorontsov
2008-10-09 14:23 ` Stefan Roese
2008-10-09 15:10 ` Steven A. Falco
2008-10-09 15:19 ` Stefan Roese
2008-10-09 16:08 ` Anton Vorontsov
2008-10-09 16:55 ` Steven A. Falco
2008-10-09 17:09 ` Steven A. Falco
2008-10-09 17:38 ` Anton Vorontsov
2008-10-09 18:04 ` Steven A. Falco
2008-10-09 18:46 ` Stefan Roese
2008-10-09 19:03 ` Anton Vorontsov [this message]
2008-10-09 22:08 ` Sean MacLennan
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=20081009190340.GA28107@oksana.dev.rtsoft.ru \
--to=avorontsov@ru.mvista.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=sr@denx.de \
/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;
as well as URLs for NNTP newsgroup(s).