mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: "Uwe Kleine-König" <uwe@kleine-koenig.org>, barebox@lists.infradead.org
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: Re: [PATCH 2/2] of: partition: Use mtd partitioning for of_fixup instead of the cdev variant
Date: Fri, 8 Mar 2024 10:27:21 +0100	[thread overview]
Message-ID: <ace334e4-d2ce-4e22-b6ce-e03550b1ad21@pengutronix.de> (raw)
In-Reply-To: <20240308091507.249009-4-uwe@kleine-koenig.org>

Hello Uwe,

On 08.03.24 10:15, Uwe Kleine-König wrote:
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> It was already noticed in commit 9d42c77f126e ("devfs: take into account
> for the partitions check that mtd is different") that the partitioning
> info is stored differently for mtd devices. Instead of only getting the
> partion size from the right spot, use the right data completely.

I read both this commit message and that of the referenced commit and I
don't quite understand what the issue is. Could you add a short sentence
about what particular issue this fix addresses?

Thanks,
Ahmad

> 
> Fixes: 9d42c77f126e ("devfs: take into account for the partitions check that mtd is different")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/of/partition.c | 30 ++++++++++++++++++++++--------
>  1 file changed, 22 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/of/partition.c b/drivers/of/partition.c
> index d11e1d1690f9..598ac5240d79 100644
> --- a/drivers/of/partition.c
> +++ b/drivers/of/partition.c
> @@ -267,18 +267,32 @@ int of_fixup_partitions(struct device_node *np, struct cdev *cdev)
>  	if (ret)
>  		return ret;
>  
> -	list_for_each_entry(partcdev, &cdev->partitions, partition_entry) {
> -		loff_t partoffset;
> +	if (cdev->mtd) {
> +		struct mtd_info *mtdpart;
>  
> +		list_for_each_entry(mtdpart, &cdev->mtd->partitions, partitions_entry) {
> +			const char *name = mtdpart->name;
> +
> +			if (mtdpart->parent) {
> +				const char *parentname = dev_name(&mtdpart->parent->dev);
> +				size_t parentnamelen = strlen(parentname);
> +
> +				if (!strncmp(parentname, name, parentnamelen) && name[parentnamelen] == '.')
> +					name += parentnamelen + 1;
> +			}
> +
> +			ret = of_fixup_one_partition(partnode, mtdpart->master_offset, mtdpart->size, name, partcdev->flags);
> +			if (ret)
> +				return ret;
> +		}
> +		return 0;
> +	}
> +
> +	list_for_each_entry(partcdev, &cdev->partitions, partition_entry) {
>  		if (!(partcdev->flags & DEVFS_PARTITION_FROM_OF))
>  			continue;
>  
> -		if (partcdev->mtd)
> -			partoffset = partcdev->mtd->master_offset;
> -		else
> -			partoffset = partcdev->offset;
> -
> -		ret = of_fixup_one_partition(partnode, partoffset, partcdev->size, partcdev->partname, partcdev->flags);
> +		ret = of_fixup_one_partition(partnode, partcdev->offset, partcdev->size, partcdev->partname, partcdev->flags);
>  		if (ret)
>  			return ret;
>  	}

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




  reply	other threads:[~2024-03-08  9:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-08  9:15 [PATCH 1/2] of: partition: Move some parts of of_fixup_partitions() into separate function Uwe Kleine-König
2024-03-08  9:15 ` [PATCH 2/2] of: partition: Use mtd partitioning for of_fixup instead of the cdev variant Uwe Kleine-König
2024-03-08  9:27   ` Ahmad Fatoum [this message]
2024-03-08 10:14     ` Uwe Kleine-König
2024-03-08 10:51       ` Sascha Hauer

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=ace334e4-d2ce-4e22-b6ce-e03550b1ad21@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=uwe@kleine-koenig.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox