devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: "Richard Weinberger" <richard@nod.at>,
	"Vignesh Raghavendra" <vigneshr@ti.com>,
	"Vivek Unune" <npcomplete13@gmail.com>,
	linux-mtd@lists.infradead.org, "Rob Herring" <robh+dt@kernel.org>,
	devicetree@vger.kernel.org, "Rafał Miłecki" <rafal@milecki.pl>
Subject: Re: [PATCH] mtd: parsers: trx: parse "firmware" MTD partitions only
Date: Fri, 16 Apr 2021 17:03:30 +0200	[thread overview]
Message-ID: <20210416170330.65c267f4@xps13> (raw)
In-Reply-To: <20210413163700.12215-1-zajec5@gmail.com>

Hi Rafał,

Rafał Miłecki <zajec5@gmail.com> wrote on Tue, 13 Apr 2021 18:37:00
+0200:

> From: Rafał Miłecki <rafal@milecki.pl>
> 
> Parsing every partition with "compatible" set to "brcm,trx" results in
> parsing both: firmware partition and failsafe partition on devices that
> implement failsafe booting. This affects e.g. Linksys EA9500 which has:
> 
> partition@200000 {
> 	reg = <0x0200000 0x01d00000>;
> 	compatible = "linksys,ns-firmware", "brcm,trx";
> };
> 
> partition@1f00000 {
> 	reg = <0x01f00000 0x01d00000>;
> 	compatible = "linksys,ns-firmware", "brcm,trx";
> };
> 
> Check for MTD partition name "firmware" before parsing. Recently added
> ofpart_linksys_ns.c creates "firmware" and "failsafe" depending on
> bootloader setup.

I don't like very much the matching against a partition name, this is
and should probably remain free text. Why not matching against the
entire linksys,ns-firmware compatible instead?

> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
> Vivek has recently reported this problem to me and this is soltuion I
> came up with.
> 
> One alternative I thought of could be marking "failsafe" MTD partition
> node as disabled (using of_update_property() + "status" + "disabled") and
> then using of_device_is_available() in the parser_trx.c.
> 
> Let me know if you prefer the other (or any other) solution over this
> patch.
> ---
>  drivers/mtd/parsers/parser_trx.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/mtd/parsers/parser_trx.c b/drivers/mtd/parsers/parser_trx.c
> index 8541182134d4..0063791e164d 100644
> --- a/drivers/mtd/parsers/parser_trx.c
> +++ b/drivers/mtd/parsers/parser_trx.c
> @@ -58,6 +58,10 @@ static int parser_trx_parse(struct mtd_info *mtd,
>  	uint8_t curr_part = 0, i = 0;
>  	int err;
>  
> +	/* Don't parse any failsafe / backup partitions */
> +	if (strcmp(mtd->name, "firmware"))
> +		return -EINVAL;
> +
>  	parts = kcalloc(TRX_PARSER_MAX_PARTS, sizeof(struct mtd_partition),
>  			GFP_KERNEL);
>  	if (!parts)




Thanks,
Miquèl

      reply	other threads:[~2021-04-16 15:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13 16:37 [PATCH] mtd: parsers: trx: parse "firmware" MTD partitions only Rafał Miłecki
2021-04-16 15:03 ` Miquel Raynal [this message]

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=20210416170330.65c267f4@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=npcomplete13@gmail.com \
    --cc=rafal@milecki.pl \
    --cc=richard@nod.at \
    --cc=robh+dt@kernel.org \
    --cc=vigneshr@ti.com \
    --cc=zajec5@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).