* [PATCH] mtd: physmap: Convert to devm_ioremap_resource()
@ 2013-01-25 14:50 Ezequiel Garcia
2013-01-25 14:50 ` [PATCH 1/2] mtd: physmap_of: Convert device allocation to managed devm_kzalloc() Ezequiel Garcia
2013-01-25 14:50 ` [PATCH 2/2] mtd: physmap_of: Convert to devm_ioremap_resource() Ezequiel Garcia
0 siblings, 2 replies; 5+ messages in thread
From: Ezequiel Garcia @ 2013-01-25 14:50 UTC (permalink / raw)
To: linux-mtd; +Cc: thierry.reding, dwmw2, Ezequiel Garcia, Artem Bityutskiy
devm_ioremap_resource() provides its own error messages so all explicit
error messages can be removed from the failure code paths.
Tested by compilation only.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
I can't test this patch for the moment.
If anyone can give it a try and add its Tested-by, it'll be appreciated.
Depends on: https://patchwork.kernel.org/patch/2010191/
drivers/mtd/maps/physmap.c | 21 +++++++--------------
1 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 21b0b71..7ca1ae9 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -20,6 +20,7 @@
#include <linux/mtd/physmap.h>
#include <linux/mtd/concat.h>
#include <linux/io.h>
+#include <linux/err.h>
#define MAX_RESOURCES 4
@@ -126,19 +127,19 @@ static int physmap_flash_probe(struct platform_device *dev)
platform_set_drvdata(dev, info);
for (i = 0; i < dev->num_resources; i++) {
+ void __iomem *virt;
+
printk(KERN_NOTICE "physmap platform flash device: %.8llx at %.8llx\n",
(unsigned long long)resource_size(&dev->resource[i]),
(unsigned long long)dev->resource[i].start);
- if (!devm_request_mem_region(&dev->dev,
- dev->resource[i].start,
- resource_size(&dev->resource[i]),
- dev_name(&dev->dev))) {
- dev_err(&dev->dev, "Could not reserve memory region\n");
- err = -ENOMEM;
+ virt = devm_ioremap_resource(&dev->dev, &dev->resource[i]);
+ if (IS_ERR(virt)) {
+ err = PTR_ERR(virt);
goto err_out;
}
+ info->map[i].virt = virt;
info->map[i].name = dev_name(&dev->dev);
info->map[i].phys = dev->resource[i].start;
info->map[i].size = resource_size(&dev->resource[i]);
@@ -147,14 +148,6 @@ static int physmap_flash_probe(struct platform_device *dev)
info->map[i].pfow_base = physmap_data->pfow_base;
info->map[i].map_priv_1 = (unsigned long)dev;
- info->map[i].virt = devm_ioremap(&dev->dev, info->map[i].phys,
- info->map[i].size);
- if (info->map[i].virt == NULL) {
- dev_err(&dev->dev, "Failed to ioremap flash region\n");
- err = -EIO;
- goto err_out;
- }
-
simple_map_init(&info->map[i]);
probe_type = rom_probe_types;
--
1.7.8.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 1/2] mtd: physmap_of: Convert device allocation to managed devm_kzalloc()
2013-01-25 14:50 [PATCH] mtd: physmap: Convert to devm_ioremap_resource() Ezequiel Garcia
@ 2013-01-25 14:50 ` Ezequiel Garcia
2013-02-04 12:36 ` Ezequiel Garcia
2013-02-12 16:10 ` Artem Bityutskiy
2013-01-25 14:50 ` [PATCH 2/2] mtd: physmap_of: Convert to devm_ioremap_resource() Ezequiel Garcia
1 sibling, 2 replies; 5+ messages in thread
From: Ezequiel Garcia @ 2013-01-25 14:50 UTC (permalink / raw)
To: linux-mtd; +Cc: thierry.reding, dwmw2, Ezequiel Garcia, Artem Bityutskiy
Tested by compilation only.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
drivers/mtd/maps/physmap_of.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index 67cc73c..c69e5c4 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -68,9 +68,6 @@ static int of_flash_remove(struct platform_device *dev)
kfree(info->list[i].res);
}
}
-
- kfree(info);
-
return 0;
}
@@ -199,8 +196,9 @@ static int of_flash_probe(struct platform_device *dev)
map_indirect = of_property_read_bool(dp, "no-unaligned-direct-access");
err = -ENOMEM;
- info = kzalloc(sizeof(struct of_flash) +
- sizeof(struct of_flash_list) * count, GFP_KERNEL);
+ info = devm_kzalloc(&dev->dev,
+ sizeof(struct of_flash) +
+ sizeof(struct of_flash_list) * count, GFP_KERNEL);
if (!info)
goto err_flash_remove;
--
1.7.8.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] mtd: physmap_of: Convert to devm_ioremap_resource()
2013-01-25 14:50 [PATCH] mtd: physmap: Convert to devm_ioremap_resource() Ezequiel Garcia
2013-01-25 14:50 ` [PATCH 1/2] mtd: physmap_of: Convert device allocation to managed devm_kzalloc() Ezequiel Garcia
@ 2013-01-25 14:50 ` Ezequiel Garcia
1 sibling, 0 replies; 5+ messages in thread
From: Ezequiel Garcia @ 2013-01-25 14:50 UTC (permalink / raw)
To: linux-mtd; +Cc: thierry.reding, dwmw2, Ezequiel Garcia, Artem Bityutskiy
Convert non managed request_mem_region() and ioremap()
to its managed counterpart, using devm_ioremap_resource()
to perform both request and ioremap actions.
Tested by compilation only.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
Instead of converting to devm_request_mem_region() and devm_ioremap(),
I just converted to the newest devm_ioremap_resource().
I can't test this patch for the moment.
If anyone can give it a shot and add its Tested-by, it'll be appreciated.
Depends on: https://patchwork.kernel.org/patch/2010191/
drivers/mtd/maps/physmap_of.c | 36 +++++++++---------------------------
1 files changed, 9 insertions(+), 27 deletions(-)
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index c69e5c4..76cbfb5 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -17,6 +17,7 @@
#include <linux/types.h>
#include <linux/init.h>
#include <linux/device.h>
+#include <linux/err.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>
@@ -29,7 +30,6 @@
struct of_flash_list {
struct mtd_info *mtd;
struct map_info map;
- struct resource *res;
};
struct of_flash {
@@ -56,18 +56,9 @@ static int of_flash_remove(struct platform_device *dev)
if (info->cmtd)
mtd_device_unregister(info->cmtd);
- for (i = 0; i < info->list_size; i++) {
+ for (i = 0; i < info->list_size; i++)
if (info->list[i].mtd)
map_destroy(info->list[i].mtd);
-
- if (info->list[i].map.virt)
- iounmap(info->list[i].map.virt);
-
- if (info->list[i].res) {
- release_resource(info->list[i].res);
- kfree(info->list[i].res);
- }
- }
return 0;
}
@@ -164,7 +155,6 @@ static int of_flash_probe(struct platform_device *dev)
const __be32 *p;
int reg_tuple_size;
struct mtd_info **mtd_list = NULL;
- resource_size_t res_size;
struct mtd_part_parser_data ppdata;
bool map_indirect;
const char *mtd_name;
@@ -209,6 +199,7 @@ static int of_flash_probe(struct platform_device *dev)
goto err_flash_remove;
for (i = 0; i < count; i++) {
+ void __iomem *virt;
err = -ENXIO;
if (of_address_to_resource(dp, i, &res)) {
/*
@@ -220,12 +211,11 @@ static int of_flash_probe(struct platform_device *dev)
dev_dbg(&dev->dev, "of_flash device: %pR\n", &res);
- err = -EBUSY;
- res_size = resource_size(&res);
- info->list[i].res = request_mem_region(res.start, res_size,
- dev_name(&dev->dev));
- if (!info->list[i].res)
+ virt = devm_ioremap_resource(&dev->dev, &res);
+ if (IS_ERR(virt)) {
+ err = PTR_ERR(virt);
goto err_out;
+ }
err = -ENXIO;
width = of_get_property(dp, "bank-width", NULL);
@@ -237,17 +227,9 @@ static int of_flash_probe(struct platform_device *dev)
info->list[i].map.name = mtd_name ?: dev_name(&dev->dev);
info->list[i].map.phys = res.start;
- info->list[i].map.size = res_size;
+ info->list[i].map.size = resource_size(&res);
info->list[i].map.bankwidth = be32_to_cpup(width);
-
- err = -ENOMEM;
- info->list[i].map.virt = ioremap(info->list[i].map.phys,
- info->list[i].map.size);
- if (!info->list[i].map.virt) {
- dev_err(&dev->dev, "Failed to ioremap() flash"
- " region\n");
- goto err_out;
- }
+ info->list[i].map.virt = virt;
simple_map_init(&info->list[i].map);
--
1.7.8.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mtd: physmap_of: Convert device allocation to managed devm_kzalloc()
2013-01-25 14:50 ` [PATCH 1/2] mtd: physmap_of: Convert device allocation to managed devm_kzalloc() Ezequiel Garcia
@ 2013-02-04 12:36 ` Ezequiel Garcia
2013-02-12 16:10 ` Artem Bityutskiy
1 sibling, 0 replies; 5+ messages in thread
From: Ezequiel Garcia @ 2013-02-04 12:36 UTC (permalink / raw)
To: Artem Bityutskiy; +Cc: dwmw2, thierry.reding, linux-mtd, Ezequiel Garcia
Artem,
On Fri, Jan 25, 2013 at 11:50 AM, Ezequiel Garcia
<ezequiel.garcia@free-electrons.com> wrote:
> Tested by compilation only.
>
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
> drivers/mtd/maps/physmap_of.c | 8 +++-----
> 1 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
> index 67cc73c..c69e5c4 100644
> --- a/drivers/mtd/maps/physmap_of.c
> +++ b/drivers/mtd/maps/physmap_of.c
> @@ -68,9 +68,6 @@ static int of_flash_remove(struct platform_device *dev)
> kfree(info->list[i].res);
> }
> }
> -
> - kfree(info);
> -
> return 0;
> }
>
> @@ -199,8 +196,9 @@ static int of_flash_probe(struct platform_device *dev)
> map_indirect = of_property_read_bool(dp, "no-unaligned-direct-access");
>
> err = -ENOMEM;
> - info = kzalloc(sizeof(struct of_flash) +
> - sizeof(struct of_flash_list) * count, GFP_KERNEL);
> + info = devm_kzalloc(&dev->dev,
> + sizeof(struct of_flash) +
> + sizeof(struct of_flash_list) * count, GFP_KERNEL);
> if (!info)
> goto err_flash_remove;
>
> --
> 1.7.8.6
>
I've just tested this physmap series.
Can you pick only this one?
The other two depend on the devm_ioremap_resource() patch,
so I'll re-submit them when that patch hits your tree.
Thanks,
--
Ezequiel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mtd: physmap_of: Convert device allocation to managed devm_kzalloc()
2013-01-25 14:50 ` [PATCH 1/2] mtd: physmap_of: Convert device allocation to managed devm_kzalloc() Ezequiel Garcia
2013-02-04 12:36 ` Ezequiel Garcia
@ 2013-02-12 16:10 ` Artem Bityutskiy
1 sibling, 0 replies; 5+ messages in thread
From: Artem Bityutskiy @ 2013-02-12 16:10 UTC (permalink / raw)
To: Ezequiel Garcia; +Cc: dwmw2, thierry.reding, linux-mtd
On Fri, 2013-01-25 at 11:50 -0300, Ezequiel Garcia wrote:
> Tested by compilation only.
>
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Pushed this one to l2-mtd.git, thanks!
--
Best Regards,
Artem Bityutskiy
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-02-12 16:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-25 14:50 [PATCH] mtd: physmap: Convert to devm_ioremap_resource() Ezequiel Garcia
2013-01-25 14:50 ` [PATCH 1/2] mtd: physmap_of: Convert device allocation to managed devm_kzalloc() Ezequiel Garcia
2013-02-04 12:36 ` Ezequiel Garcia
2013-02-12 16:10 ` Artem Bityutskiy
2013-01-25 14:50 ` [PATCH 2/2] mtd: physmap_of: Convert to devm_ioremap_resource() Ezequiel Garcia
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.