public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: David Brownell <dbrownell@users.sourceforge.net>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	David Miller <davem@davemloft.net>,
	Michal Simek <monstr@monstr.eu>,
	linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org,
	devicetree-discuss@lists.ozlabs.org,
	microblaze-uclinux@itee.uq.edu.au
Subject: Re: [PATCH 3/3] of/gpio: Introduce of_put_gpio(), add ref counting for OF GPIO chips
Date: Mon, 15 Feb 2010 23:59:24 +0300	[thread overview]
Message-ID: <20100215205924.GA23654@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <fa686aa41002151149u158bc2fbn5af16f6bd714d36c@mail.gmail.com>

On Mon, Feb 15, 2010 at 12:49:56PM -0700, Grant Likely wrote:
[...]
> Okay, I'm convinced now.  The model is wrong.  struct of_gc does need
> to be a member of struct gpio_chip and conditionally compiled against
> CONFIG_OF_GPIO.  This locking requirement is just too plain ugly,

And how would you implement of_get_gpio(np, index) then?
You don't have 'struct gpio_chip' in of_get_gpio(), so you can't
get of_gc out of it.

It's possible to lookup all GPIOs (gpio[0..ARCH_NR_GPIOS]) matching
on chip->dev->archdata.node == np, but you're just moving this stuff
into gpiolib, where you'll have to grab global gpio_lock instead of
devtree lock. And just as with np->data_lock or global devtree lock,
you'll have to grab gpio_lock in of_gpio_put(), of_gpio_chip_register
and of_gpio_chip_unregister().

See? Your suggestion doesn't make things better or simpler, instead
it turns the OF GPIO inside out, exposing arch details to the generic
code.

There is really no excuse for the arch-specific (OF) stuff being in
the generic code. Not in the irq subsystem, not in the gpio
subsystem. My implementation actually proves that.

> and
> dereferencing the np->data pointer in this way is dangerous
> (what if
> something that is not struct of_gc is stored there).

Not possible with the safe np->data accessors.

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

  reply	other threads:[~2010-02-15 20:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-05 20:49 [PATCH RFC 0/3] Implement refcounting for OF GPIO chips Anton Vorontsov
2010-02-05 20:50 ` [PATCH 1/3] of platforms: Move common static initialization to of_node_init() Anton Vorontsov
2010-02-09 17:22   ` Grant Likely
2010-02-05 20:50 ` [PATCH 2/3] of: Introduce safe accessors for node->data Anton Vorontsov
2010-02-09 17:25   ` Grant Likely
2010-02-09 19:10     ` Anton Vorontsov
2010-02-05 20:50 ` [PATCH 3/3] of/gpio: Introduce of_put_gpio(), add ref counting for OF GPIO chips Anton Vorontsov
2010-02-09  9:15   ` Michal Simek
2010-02-09  9:20     ` Michal Simek
2010-02-09 17:28   ` Grant Likely
2010-02-09 19:14     ` Anton Vorontsov
2010-02-15 19:49       ` Grant Likely
2010-02-15 20:59         ` Anton Vorontsov [this message]
2010-02-09  9:40 ` [PATCH RFC 0/3] Implement refcounting " Michal Simek
2010-02-09 17:29   ` Grant Likely
2010-02-09 19:06   ` Anton Vorontsov

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=20100215205924.GA23654@oksana.dev.rtsoft.ru \
    --to=avorontsov@ru.mvista.com \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=dbrownell@users.sourceforge.net \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=microblaze-uclinux@itee.uq.edu.au \
    --cc=monstr@monstr.eu \
    /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