From: David Brownell <david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
To: Ned Forrester <nforrester-/d+BM93fTQY@public.gmane.org>,
Eric Miao <eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
Russell King - ARM Linux
<linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
Subject: Re: [PATCH] spi: pxa2xx_spi introduce chip select gpio to simplify the common cases
Date: Tue, 9 Sep 2008 10:49:49 -0700 [thread overview]
Message-ID: <200809091049.49327.david-b@pacbell.net> (raw)
In-Reply-To: <48C5CFEE.6070601-/d+BM93fTQY@public.gmane.org>
> > + /* NOTE: setup() can be called multiple times, possibly with
> > + * different chip_info, previously requested GPIO shall be
> > + * released, stumped :(
> > + */
No; chip_info should be regarded as immutable between the time the
initializing setup() call is invoked and, should it ever happen,
the cleanup() is invoked. Anyone mucking around with that controller
data deserves the chaos they will have started.
> > + if (gpio_is_valid(chip_info->gpio_cs)) {
> > + err = gpio_request(chip_info->gpio_cs, "SPI_CS");
I'd actually pass dev_name(&spi->dev) not "SPI_CS", since I
happen to like seeing /sys/kernel/debug/gpio be informative.
Seeing half a dozen "SPI_CS" (uppercase, yeech!) labels is
not informative; seeing "spi1.0", "spi1.1", "spi2.5" etc is
more useful ... you can probably cross-check them with the
board schematics to detect errors, instead of just omissions.
> > + if (err) {
> > + dev_err(&spi->dev, "failed to request CS GPIO%d\n",
> > + chip_info->gpio_cs);
>
> I do not agree that this is an error, though David may argue that it is.
It's an error all right. If that signal is in use by some
other driver, this one should never touch it.
> Feel free to reduce this to KERN_INFO and eliminate the following
> return. It is not illegal to omit the chip select on a one-chip bus,
> when the chip does not use CS; there is no need to allocate and waste a
> pin if it is not connected to anything.
But such "not illegal" cases wouldn't hit this "if (err) ... " branch...
> > + if (gpio_is_valid(chip->gpio_cs))
> > + gpio_free(chip->gpio_cs);
>
> Again, this does not belong in the master driver, IMHO; the resource
> should have been allocated outside the master.
No; drivers do request_resource(), and gpio_request() is the same
kind of thing. And they need to clean up the resources which they
requested on various paths -- even when those resources are GPIOs.
Of course, if the cs_control() route is used, then pxa2xx_spi isn't
going to be allocating any underlying GPIOs, so it won't have to
free them either.
- Dave
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
next prev parent reply other threads:[~2008-09-09 17:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <f17812d70809040221y477ec4x5c05460650266be8@mail.gmail.com>
[not found] ` <f17812d70809040403u4c33e376vd8b3a2c5f034081c@mail.gmail.com>
[not found] ` <f17812d70809040403u4c33e376vd8b3a2c5f034081c-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-09-09 0:04 ` [PATCH] spi: pxa2xx_spi introduce chip select gpio to simplify the common cases David Brownell
[not found] ` <200809081704.43404.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-09-09 1:22 ` Ned Forrester
[not found] ` <48C5CFEE.6070601-/d+BM93fTQY@public.gmane.org>
2008-09-09 1:42 ` Eric Miao
[not found] ` <f17812d70809081842l703fa346k139cc14dc033d877-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-09-09 2:42 ` Eric Miao
[not found] ` <f17812d70809081942t718aa081p23f4711ee53d8019-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-09-09 2:52 ` Ned Forrester
2008-09-09 2:50 ` Ned Forrester
[not found] ` <48C5E47F.7070705-/d+BM93fTQY@public.gmane.org>
2008-09-09 3:02 ` Eric Miao
[not found] ` <f17812d70809082002w4b7e3cd1n948ad39fd6cd7833-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-09-09 17:49 ` David Brownell
2008-09-09 17:49 ` David Brownell [this message]
[not found] ` <200809091049.49327.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-09-10 1:25 ` Eric Miao
2008-09-09 10:23 ` Jonathan Cameron
[not found] ` <48C64EBE.6090003-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2008-09-11 6:08 ` David Brownell
[not found] ` <200809102308.31675.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-09-11 13:32 ` Ned Forrester
[not found] ` <48C91DFD.5020308-/d+BM93fTQY@public.gmane.org>
2008-09-11 18:35 ` David Brownell
[not found] ` <200809111135.44364.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-09-12 18:18 ` Jonathan Cameron
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=200809091049.49327.david-b@pacbell.net \
--to=david-b-ybekhbn/0ldr7s880joybq@public.gmane.org \
--cc=eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
--cc=nforrester-/d+BM93fTQY@public.gmane.org \
--cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.