[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <47FA4FD2.8060808@ru.mvista.com>
Date: Mon, 07 Apr 2008 20:46:10 +0400
From: Sergei Shtylyov <sshtylyov@...mvista.com>
To: Tejun Heo <htejun@...il.com>
Cc: jgarzik@...ox.com, gregkh@...e.de, alan@...rguk.ukuu.org.uk,
linux-kernel@...r.kernel.org, linux-ide@...r.kernel.org,
linuxppc-dev@...abs.org
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists