Message ID | 1384529257-7590-1-git-send-email-julien.grall@linaro.org |
---|---|
State | Superseded, archived |
Headers | show |
On 15/11/13 15:27, Julien Grall wrote: > Most of ioremap_* caller check if ioremap returns NULL. Actually, if the > physical address is non-aligned, Xen will return the pointer given by > __vmap plus the offset in the page. So if ioremap_* fails, the caller > will retrieve an non-NULL address and continue as if there was no error. > > Signed-off-by: Julien Grall <julien.grall@linaro.org> > --- > xen/arch/arm/mm.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c > index 26c6768..5137668 100644 > --- a/xen/arch/arm/mm.c > +++ b/xen/arch/arm/mm.c > @@ -742,8 +742,13 @@ void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes) > unsigned long pfn = PFN_DOWN(pa); > unsigned int offs = pa & (PAGE_SIZE - 1); > unsigned int nr = PFN_UP(offs + len); > + void *ptr; > > - return (__vmap(&pfn, nr, 1, 1, attributes) + offs); > + ptr = __vmap(&pfn, nr, 1, 1, attributes); No need to split the declaration of void *ptr and its initialisation. ~Andrew > + if ( ptr == NULL ) > + return NULL; > + > + return (ptr + offs); > } > > void *ioremap(paddr_t pa, size_t len)
On Fri, 15 Nov 2013, Julien Grall wrote: > Most of ioremap_* caller check if ioremap returns NULL. Actually, if the > physical address is non-aligned, Xen will return the pointer given by > __vmap plus the offset in the page. So if ioremap_* fails, the caller > will retrieve an non-NULL address and continue as if there was no error. > > Signed-off-by: Julien Grall <julien.grall@linaro.org> > --- > xen/arch/arm/mm.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c > index 26c6768..5137668 100644 > --- a/xen/arch/arm/mm.c > +++ b/xen/arch/arm/mm.c > @@ -742,8 +742,13 @@ void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes) > unsigned long pfn = PFN_DOWN(pa); > unsigned int offs = pa & (PAGE_SIZE - 1); > unsigned int nr = PFN_UP(offs + len); > + void *ptr; > > - return (__vmap(&pfn, nr, 1, 1, attributes) + offs); > + ptr = __vmap(&pfn, nr, 1, 1, attributes); > + if ( ptr == NULL ) > + return NULL; > + > + return (ptr + offs); No need for brackets here. In any case Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 26c6768..5137668 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -742,8 +742,13 @@ void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes) unsigned long pfn = PFN_DOWN(pa); unsigned int offs = pa & (PAGE_SIZE - 1); unsigned int nr = PFN_UP(offs + len); + void *ptr; - return (__vmap(&pfn, nr, 1, 1, attributes) + offs); + ptr = __vmap(&pfn, nr, 1, 1, attributes); + if ( ptr == NULL ) + return NULL; + + return (ptr + offs); } void *ioremap(paddr_t pa, size_t len)
Most of ioremap_* caller check if ioremap returns NULL. Actually, if the physical address is non-aligned, Xen will return the pointer given by __vmap plus the offset in the page. So if ioremap_* fails, the caller will retrieve an non-NULL address and continue as if there was no error. Signed-off-by: Julien Grall <julien.grall@linaro.org> --- xen/arch/arm/mm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)