[1/2,v2] mtd: maps: Leave assigned complex mappings

Message ID 20181112210729.23580-1-linus.walleij@linaro.org
State New
Headers show
Series
  • [1/2,v2] mtd: maps: Leave assigned complex mappings
Related show

Commit Message

Linus Walleij Nov. 12, 2018, 9:07 p.m.
The simple_map_init() may need to be called with some
function pointers already assigned for complex mappings,
just bail out if complex handlers have already been
assigned.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
ChangeLog v1->v2:
- Rebase on latest MTD development branch
- Use a new approach as the code changed under me
---
 drivers/mtd/maps/map_funcs.c | 4 ++++
 1 file changed, 4 insertions(+)

-- 
2.19.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

Comments

Boris Brezillon Nov. 20, 2018, 1:43 p.m. | #1
Hi Linus,

On Mon, 12 Nov 2018 22:07:28 +0100
Linus Walleij <linus.walleij@linaro.org> wrote:

> The simple_map_init() may need to be called with some

> function pointers already assigned for complex mappings,

> just bail out if complex handlers have already been

> assigned.

> 

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

> ---

> ChangeLog v1->v2:

> - Rebase on latest MTD development branch

> - Use a new approach as the code changed under me

> ---

>  drivers/mtd/maps/map_funcs.c | 4 ++++

>  1 file changed, 4 insertions(+)

> 

> diff --git a/drivers/mtd/maps/map_funcs.c b/drivers/mtd/maps/map_funcs.c

> index 3f268370eeca..60e132293e1c 100644

> --- a/drivers/mtd/maps/map_funcs.c

> +++ b/drivers/mtd/maps/map_funcs.c

> @@ -31,6 +31,10 @@ static void __xipram simple_map_copy_to(struct map_info *map, unsigned long to,

>  

>  void simple_map_init(struct map_info *map)

>  {

> +	/* Complex map functions already assigned */

> +	if (map->read)

> +		return;

> +

>  	BUG_ON(!map_bankwidth_supported(map->bankwidth));

>  

>  	map->read = simple_map_read;


Can we move that to the physmap driver?

--->8---
diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c
index e8c3b250d842..043c7de39757 100644
--- a/drivers/mtd/maps/physmap-core.c
+++ b/drivers/mtd/maps/physmap-core.c
@@ -514,10 +514,16 @@ static int physmap_flash_probe(struct platform_device *dev)
                        err = physmap_addr_gpios_map_init(&info->maps[i]);
                        if (err)
                                goto err_out;
-               } else {
-                       simple_map_init(&info->maps[i]);
                }
 
+               /*
+                * Only use the simple_map implementation if map hooks are not
+                * implemented. Since map->read() is mandatory checking for its
+                * presence is enough.
+                */
+               if (map->read)
+                       simple_map_init(&info->maps[i]);
+
                if (info->probe_type) {
                        info->mtds[i] = do_map_probe(info->probe_type,
                                                     &info->maps[i]);

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

Patch

diff --git a/drivers/mtd/maps/map_funcs.c b/drivers/mtd/maps/map_funcs.c
index 3f268370eeca..60e132293e1c 100644
--- a/drivers/mtd/maps/map_funcs.c
+++ b/drivers/mtd/maps/map_funcs.c
@@ -31,6 +31,10 @@  static void __xipram simple_map_copy_to(struct map_info *map, unsigned long to,
 
 void simple_map_init(struct map_info *map)
 {
+	/* Complex map functions already assigned */
+	if (map->read)
+		return;
+
 	BUG_ON(!map_bankwidth_supported(map->bankwidth));
 
 	map->read = simple_map_read;