The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Andres Salomon <dilinger@collabora.co.uk>, Tobias_Mueller@twam.info
Cc: akpm@linux-foundation.org, Randy Dunlap <randy.dunlap@oracle.com>,
	deepak@laptop.org, Takashi Iwai <tiwai@suse.de>,
	linux-kernel@vger.kernel.org, linux-geode@lists.infradead.org,
	jordan@cosmicpenguin.net, cjb@laptop.org
Subject: Re: [PATCH 1/2] cs5535-gpio: add AMD CS5535/CS5536 GPIO driver   support
Date: Wed, 1 Jul 2009 15:32:34 -0700	[thread overview]
Message-ID: <200907011532.34677.david-b@pacbell.net> (raw)
In-Reply-To: <20090611172850.6c418b1d@mycelium.queued.net>

On Thursday 11 June 2009, Andres Salomon wrote:
> 
> > I mentioned this in an ealier mail too. When I request the GPIO from
> > userspace the direction file always contains "in", so I thought
> > this is the standard direction after resetting as I should be in a
> > defined state after requesting. But I didn't found anything
> > about this in GPIO lib documentation, so I would be fine to change
> > this if there is any common default behavoir.
> 
> To be honest, I'd have to play around with it a bit before I
> knew whether it actually breaks anything or not. I'm not sure if
> it would break anything on OLPC, and I don't have any other geode
> machines that do anything interesting w/ GPIOs.
> 
> Maybe David can clear up whether this behavior is correct from the
> userspace GPIO usage standpoint..

Correct-but-annoying ... and maybe worth changing.  The
direction *displayed* may not reflect the actual hardware
until after that GPIO signal is initialized.  Boot firmware
may well have set the direction; Linux shouldn't change it
without explicit instructions to do so.

The issue is that when it first comes up, nobody has tod
Linux that direction ... so instead of defining an "unknown"
state, that code applies a heuristic.  In gpiochip_add():

                for (id = base; id < base + chip->ngpio; id++) {
                        gpio_desc[id].chip = chip;

                        /* REVISIT:  most hardware initializes GPIOs as
                         * inputs (often with pullups enabled) so power
                         * usage is minimized.  Linux code should set the
                         * gpio direction first thing; but until it does,
                         * we may expose the wrong direction in sysfs.
                         */
                        gpio_desc[id].flags = !chip->direction_input
                                ? (1 << FLAG_IS_OUT)
                                : 0;
                }

Now, as far as heuristics go that one seems to cover most
of the common cases.  But like all heuristics, the result
produced may be wrong.

So it would be nice to remove the heuristic.  The best
way would be to add a new method to query gpio direction.
Then that when it's available, instead of the heuristic.

- Dave


  parent reply	other threads:[~2009-07-01 22:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-10  4:10 [PATCH 1/2] cs5535-gpio: add AMD CS5535/CS5536 GPIO driver support Andres Salomon
2009-06-11 14:46 ` Tobias Müller
2009-06-11 15:16   ` Andres Salomon
2009-06-11 18:52 ` Tobias Müller
2009-06-11 20:00   ` Andres Salomon
2009-06-11 20:11     ` Tobias Müller
2009-06-11 21:28       ` Andres Salomon
2009-06-11 21:35         ` Tobias Müller
2009-06-13  0:23           ` Andres Salomon
2009-06-20 10:20             ` Tobias Müller
2009-07-01 22:32         ` David Brownell [this message]
2009-08-15 10:59           ` Tobias Müller
2009-08-18  4:43             ` Andres Salomon
2009-08-18  8:32               ` Tobias Müller

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=200907011532.34677.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=Tobias_Mueller@twam.info \
    --cc=akpm@linux-foundation.org \
    --cc=cjb@laptop.org \
    --cc=deepak@laptop.org \
    --cc=dilinger@collabora.co.uk \
    --cc=jordan@cosmicpenguin.net \
    --cc=linux-geode@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=randy.dunlap@oracle.com \
    --cc=tiwai@suse.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