mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Felipe Balbi <me@felipebalbi.com>
To: Joe Perches <joe@perches.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Question of resource_size() implementation
Date: Wed, 30 Dec 2009 02:16:11 +0200	[thread overview]
Message-ID: <1262132171.28789.136.camel@gandalf> (raw)
In-Reply-To: <1262131932.1888.202.camel@Joe-Laptop.home>

On Tue, 2009-12-29 at 16:12 -0800, Joe Perches wrote:
> On Wed, 2009-12-30 at 01:43 +0200, Felipe Balbi wrote:
> > I'm wondering whether the +1 in resource_size() is actually necessary.
> > resource_size() is defined as:
> []
> > static inline resource_size_t resource_size(const struct resource *res)
> > {
> > 	return res->end - res->start + 1;
> > }
> > Are we off-by-one
> > here ? Or is this all expected ?
> 
> Imagine you have 1 byte sized resources.
> 
> AREA1 = 0x40000000
> AREA2 = 0x40000001
> 
> area1.start = 0x40000000
> area1.end   = 0x40000000
> 
> area2.start = 0x40000001
> area2.end   = 0x40000001

(adding lkml back to the loop)

in that you wouldn't use any of the SZ_* macros and simply hardcode
start and end, right ? then you would define:

area1.start = 0x40000000
area1.end = 0x40000001

and ioremap 2 bytes due to +1 in resource_size().

-- 
balbi


  parent reply	other threads:[~2009-12-30  0:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-29 23:43 Felipe Balbi
     [not found] ` <1262131932.1888.202.camel@Joe-Laptop.home>
2009-12-30  0:16   ` Felipe Balbi [this message]
2009-12-30  1:04     ` Ben Nizette
2009-12-30  1:08       ` Ben Nizette
2009-12-30  1:11         ` Felipe Balbi

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=1262132171.28789.136.camel@gandalf \
    --to=me@felipebalbi.com \
    --cc=joe@perches.com \
    --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

all inboxes | Powered by JetHome®