From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: Tejun Heo <htejun@gmail.com>
Cc: jgarzik@pobox.com, gregkh@suse.de, alan@lxorguk.ukuu.org.uk,
linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org,
linuxppc-dev@ozlabs.org
Subject: Re: [PATCH 6/13] devres: implement managed iomap interface
Date: Mon, 07 Apr 2008 20:46:10 +0400 [thread overview]
Message-ID: <47FA4FD2.8060808@ru.mvista.com> (raw)
In-Reply-To: <11684073371547-git-send-email-htejun@gmail.com>
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
WARNING: multiple messages have this Message-ID (diff)
From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: Tejun Heo <htejun@gmail.com>
Cc: linuxppc-dev@ozlabs.org, gregkh@suse.de,
linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org,
jgarzik@pobox.com, alan@lxorguk.ukuu.org.uk
Subject: Re: [PATCH 6/13] devres: implement managed iomap interface
Date: Mon, 07 Apr 2008 20:46:10 +0400 [thread overview]
Message-ID: <47FA4FD2.8060808@ru.mvista.com> (raw)
In-Reply-To: <11684073371547-git-send-email-htejun@gmail.com>
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
next prev parent reply other threads:[~2008-04-07 16:46 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-10 5:35 [PATCHSET] Managed device resources, take #2 Tejun Heo
2007-01-10 5:35 ` [PATCH 1/13] devres: device resource management core Tejun Heo
2007-01-10 5:35 ` Tejun Heo
2007-01-10 5:35 ` [PATCH 3/13] devres: implement managed IRQ interface Tejun Heo
2007-01-10 5:35 ` Tejun Heo
2007-01-10 5:35 ` [PATCH 2/13] devres: implement managed IO region interface Tejun Heo
2007-01-10 5:35 ` Tejun Heo
2007-01-10 5:35 ` [PATCH 4/13] devres: implement managed DMA interface Tejun Heo
2007-01-10 5:35 ` Tejun Heo
2007-01-10 5:35 ` [PATCH 7/13] devres: add Documentation/driver-model/devres.txt Tejun Heo
2007-01-10 5:35 ` Tejun Heo
2007-01-10 5:35 ` [PATCH 6/13] devres: implement managed iomap interface Tejun Heo
2007-01-10 5:35 ` Tejun Heo
2008-04-07 16:46 ` Sergei Shtylyov [this message]
2008-04-07 16:46 ` Sergei Shtylyov
2008-04-08 14:48 ` Tejun Heo
2008-04-08 14:48 ` Tejun Heo
2008-04-08 14:55 ` Sergei Shtylyov
2008-04-08 14:55 ` Sergei Shtylyov
2008-04-08 15:03 ` Tejun Heo
2008-04-08 15:03 ` Tejun Heo
2008-04-10 16:56 ` Sergei Shtylyov
2008-04-10 16:56 ` Sergei Shtylyov
2008-04-10 17:44 ` Kumar Gala
2008-04-10 18:24 ` Sergei Shtylyov
2008-04-10 19:40 ` Kumar Gala
2008-04-11 2:08 ` Tejun Heo
2008-04-11 2:08 ` Tejun Heo
2007-01-10 5:35 ` [PATCH 9/13] libata: update libata core layer to use devres Tejun Heo
2007-01-10 5:35 ` Tejun Heo
2007-01-10 5:35 ` [PATCH 5/13] devres: implement managed PCI interface Tejun Heo
2007-01-10 5:35 ` Tejun Heo
2007-01-10 5:35 ` [PATCH 8/13] libata: implement ata_host_detach() Tejun Heo
2007-01-10 5:35 ` Tejun Heo
2007-01-10 5:35 ` [PATCH 11/13] libata: remove unused functions Tejun Heo
2007-01-10 5:35 ` Tejun Heo
2007-01-10 5:35 ` [PATCH 12/13] devres: implement pcim_iomap_regions() Tejun Heo
2007-01-10 5:35 ` Tejun Heo
2007-01-20 0:31 ` [PATCHSET] Managed device resources, take #2 Jeff Garzik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47FA4FD2.8060808@ru.mvista.com \
--to=sshtylyov@ru.mvista.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=gregkh@suse.de \
--cc=htejun@gmail.com \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.