diff mbox series

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

Message ID 20181127205358.32502-1-linus.walleij@linaro.org
State New
Headers show
Series [1/2,v3] mtd: maps: Leave assigned complex mappings | expand

Commit Message

Linus Walleij Nov. 27, 2018, 8:53 p.m. UTC
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 v2->v3:
- Move check for pre-initialized simple map into
  physmap-core.c
ChangeLog v1->v2:
- Rebase on latest MTD development branch
- Use a new approach as the code changed under me
---
 drivers/mtd/maps/physmap-core.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

-- 
2.19.1


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

Comments

Boris Brezillon Dec. 2, 2018, 8:47 a.m. UTC | #1
On Tue, 27 Nov 2018 21:53:57 +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.


The commit message no longer matches what the patch does.

How about:

"
mtd: maps: physmap: Leave assigned complex mappings

SoC-specific drivers might provide their own map->xxx() implementation,
and calling simple_map_init() unconditionally will override those
implementations.

Make sure map->read is NULL before calling simple_map_init().
"

If you're okay with this new commit message, I can fix it when applying.

Regards,

Boris

> 

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

> ---

> ChangeLog v2->v3:

> - Move check for pre-initialized simple map into

>   physmap-core.c

> ChangeLog v1->v2:

> - Rebase on latest MTD development branch

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

> ---

>  drivers/mtd/maps/physmap-core.c | 10 ++++++++--

>  1 file changed, 8 insertions(+), 2 deletions(-)

> 

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

> index e8c3b250d842..ecca7784de06 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 (!info->maps[i].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/
Linus Walleij Dec. 4, 2018, 1:09 p.m. UTC | #2
On Sun, Dec 2, 2018 at 9:48 AM Boris Brezillon
<boris.brezillon@bootlin.com> wrote:
> On Tue, 27 Nov 2018 21:53:57 +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.

>

> The commit message no longer matches what the patch does.

>

> How about:

>

> "

> mtd: maps: physmap: Leave assigned complex mappings

>

> SoC-specific drivers might provide their own map->xxx() implementation,

> and calling simple_map_init() unconditionally will override those

> implementations.

>

> Make sure map->read is NULL before calling simple_map_init().

> "

>

> If you're okay with this new commit message, I can fix it when applying.


Sure, go ahead Boris, thanks!

Yours,
Linus Walleij

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Boris Brezillon Dec. 7, 2018, 9:10 a.m. UTC | #3
On Tue, 2018-11-27 at 20:53:57 UTC, Linus Walleij 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>


Applied to http://git.infradead.org/linux-mtd.git mtd/next, thanks.

Boris

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

Patch

diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c
index e8c3b250d842..ecca7784de06 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 (!info->maps[i].read)
+			simple_map_init(&info->maps[i]);
+
 		if (info->probe_type) {
 			info->mtds[i] = do_map_probe(info->probe_type,
 						     &info->maps[i]);