Messages in this thread |  | | Date | Mon, 07 Apr 2008 20:46:10 +0400 | From | Sergei Shtylyov <> | Subject | Re: [PATCH 6/13] devres: implement managed iomap interface |
| |
Tejun Heo wrote:
> +/** > + * devm_ioremap - Managed ioremap() > + * @dev: Generic device to remap IO address for > + * @offset: BUS offset to map > + * @size: Size of map > + * > + * Managed ioremap(). Map is automatically unmapped on driver detach. > + */ > +void __iomem *devm_ioremap(struct device *dev, unsigned long offset, > + unsigned long size) > +{ > + void __iomem **ptr, *addr; > + > + ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL); > + if (!ptr) > + return NULL; > + > + addr = ioremap(offset, size); > + if (addr) { > + *ptr = addr; > + devres_add(dev, ptr); > + } else > + devres_free(ptr); > + > + return addr; > +} > +EXPORT_SYMBOL(devm_ioremap); > + > +/** > + * devm_ioremap_nocache - Managed ioremap_nocache() > + * @dev: Generic device to remap IO address for > + * @offset: BUS offset to map > + * @size: Size of map > + * > + * Managed ioremap_nocache(). Map is automatically unmapped on driver > + * detach. > + */ > +void __iomem *devm_ioremap_nocache(struct device *dev, unsigned long offset, > + unsigned long size) > +{ > + void __iomem **ptr, *addr; > + > + ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL); > + if (!ptr) > + return NULL; > + > + addr = ioremap_nocache(offset, size); > + if (addr) { > + *ptr = addr; > + devres_add(dev, ptr); > + } else > + devres_free(ptr); > + > + return addr; > +} > +EXPORT_SYMBOL(devm_ioremap_nocache);
A very late comment but nevertheless... :-) Those functions are going to break on 32-bit platforms with extended physical address (well, that's starting with Pentiums which had 36-bit PAE :-) AND devices mapped beyond 4 GB (e.g. PowerPC 44x). You should have used resource_size_t for the 'offset' parameter. As this most probably means that libata is broken on such platforms, I'm going to submit a patch...
WBR, Sergei
|  |