lkml.org 
[lkml]   [2009]   [Dec]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Question of resource_size() implementation
From
Date
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



\
 
 \ /
  Last update: 2009-12-30 01:21    [from the cache]
©2003-2011 Jasper Spaans