The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Linux Kernel list <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [patch 2.6.24-rc1] resource_len() utility function
Date: Wed, 24 Oct 2007 19:39:17 -0700	[thread overview]
Message-ID: <200710241939.17576.david-b@pacbell.net> (raw)
In-Reply-To: <20071025024405.3e960e9c@the-village.bc.nu>

On Wednesday 24 October 2007, Alan Cox wrote:
> On Wed, 24 Oct 2007 18:20:52 -0700
> David Brownell <david-b@pacbell.net> wrote:
> 
> > Add a new resource_len() function, so drivers can start using this
> > instead of driver-private code for a common idiom.  The call can be
> > useful with at least:
> > 
> >  - request_region(), release_region()
> >  - request_mem_region(), release_mem_region()
> >  - ioremap()
> > 
> > Candidate drivers include those using platform or PNP busses, and
> > maybe some others.  PCI already has a similar function.
> > 
> > This patch also updates a representative set of drivers in two
> > subsystems to use this call (SPI, and USB peripheral/gadget).
> 
> PCI also increasingly is using functions that allow the user to choose to
> map a resource as a resource (eg pci_iomap). So is it better to have
> functions request_mem_resource(res)  free_mem_resource(res) and similar
> instead or as well ?

This was intended to be a minor band-aid.  ;)

We already have request_resource(), which does something
different than the request_*region() calls.  I think calls
with those names would complicate an already-too-strange
interface, adding oddball siblings to request_resource().

I'd hope that when those resource calls were defined they
made sense ... but to me, they don't do so today.  Consider
that the *typical* caller is given a "struct resource", and
then to claim the specified address space it must convert
it into a "start + length" representation before getting
back a *NEW* "struct resource" ... with identical contents,
other than the value of one all-but-undocumented flag bit.
Then, if it's I/O space the address is usable already; but
for memory space, it still needs an ioremap()...

Oh, and PCI has its own resource structs ("BAR") that don't
look or act the same as other resources.


So while I like the notion of starting to abolish that
conversion step, this wasn't an attempt to fix all the
bizarre behaviors of the resource API.

I could imagine a call taking a resource and returning
a "void __iomem *" to use for IO, which implicitly claims
the region (in either memory or i/o space) and does any
ioremap needed for memory space.  With a sibling call to
undo all that.  If that's the answer, someone else should
develop the patch and update drivers...

- Dave

      parent reply	other threads:[~2007-10-25  2:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-25  1:20 [patch 2.6.24-rc1] resource_len() utility function David Brownell
2007-10-25  1:44 ` Alan Cox
2007-10-25  2:08   ` Jeff Garzik
2007-10-25  2:47     ` David Brownell
2007-10-25  3:46       ` Jeff Garzik
2007-10-25  4:38         ` David Brownell
2007-10-25 12:29           ` Alan Cox
2007-10-25 16:31             ` David Brownell
2007-10-25  2:39   ` David Brownell [this message]

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=200710241939.17576.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox