mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH] block: fix block device detection
Date: Thu, 24 Jul 2025 13:26:39 +0200	[thread overview]
Message-ID: <4dc6dcc4-da54-4fde-88f8-ce2c62203407@pengutronix.de> (raw)
In-Reply-To: <20250724091339.1091147-1-m.felsch@pengutronix.de>

On 7/24/25 11:13, Marco Felsch wrote:
> Before commit a6410cfa9aff ("block: mark underlying cdev with
> DEVFS_IS_BLOCK_DEV") the block device decision was made based on the
> block_ops. Since each parition-cdev inherits the parent (master)
> cdev-ops the parition-cdevs were detected as block device.
> 
> Commit a6410cfa9aff the detection mechanism to be based on cdev flag but
> commit a6410cfa9aff forgot to pass the flag to the partition (child)
> cdev.
> 
> Fix this by passing the DEVFS_IS_BLOCK_DEV to the partition (child) cdev
> as well. Add a small helper function to query the inheritable devfs
> flags instead of open coding it within __devfs_add_partition().
> 
> Fixes: a6410cfa9aff ("block: mark underlying cdev with DEVFS_IS_BLOCK_DEV")

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  fs/devfs-core.c  |  4 ++--
>  include/driver.h | 10 ++++++++++
>  2 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/devfs-core.c b/fs/devfs-core.c
> index 73a13be7336d..f80281aaf91c 100644
> --- a/fs/devfs-core.c
> +++ b/fs/devfs-core.c
> @@ -584,7 +584,7 @@ static struct cdev *__devfs_add_partition(struct cdev *cdev,
>  	loff_t _end = end ? *end : 0;
>  	static struct cdev *new;
>  	struct cdev *overlap;
> -	unsigned inherited_flags = 0;
> +	unsigned inherited_flags;
>  
>  	if (cdev_by_name(partinfo->name))
>  		return ERR_PTR(-EEXIST);
> @@ -628,7 +628,7 @@ static struct cdev *__devfs_add_partition(struct cdev *cdev,
>  	}
>  
>  	/* Filter flags that we want to pass along to children */
> -	inherited_flags |= cdev->flags & DEVFS_WRITE_AUTOERASE;
> +	inherited_flags = get_inheritable_devfs_flags(cdev);
>  
>  	if (IS_ENABLED(CONFIG_MTD) && cdev->mtd) {
>  		struct mtd_info *mtd;
> diff --git a/include/driver.h b/include/driver.h
> index dd50a7aa3cce..01e04578540b 100644
> --- a/include/driver.h
> +++ b/include/driver.h
> @@ -627,6 +627,16 @@ static inline bool cdev_is_gpt_partitioned(const struct cdev *master)
>  	return master && (master->flags & DEVFS_IS_GPT_PARTITIONED);
>  }
>  
> +#define DEVFS_INHERITABLE_FLAGS (DEVFS_WRITE_AUTOERASE | DEVFS_IS_BLOCK_DEV)
> +
> +static inline unsigned int
> +get_inheritable_devfs_flags(const struct cdev *parent_cdev)
> +{
> +	if (!parent_cdev)
> +		return 0;
> +	return parent_cdev->flags & DEVFS_INHERITABLE_FLAGS;
> +}
> +
>  struct cdev *
>  cdev_find_child_by_gpt_typeuuid(struct cdev *cdev, const guid_t *typeuuid);
>  

-- 
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:[~2025-07-24 13:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-24  9:13 Marco Felsch
2025-07-24 11:26 ` Ahmad Fatoum [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=4dc6dcc4-da54-4fde-88f8-ce2c62203407@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    /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