lkml.org 
[lkml]   [2008]   [Apr]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [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


    \
     
     \ /
      Last update: 2008-04-07 18:49    [W:0.024 / U:67.400 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site