All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH 1/2] cdev: pass master cdev to cdev ops
Date: Mon, 2 Jun 2025 12:12:25 +0200	[thread overview]
Message-ID: <aD15Cc9vcj73bvW_@pengutronix.de> (raw)
In-Reply-To: <52114d62-823e-4fef-8fa1-d4f55c35f371@pengutronix.de>

On Mon, Jun 02, 2025 at 11:03:56AM +0200, Ahmad Fatoum wrote:
> Hello Sascha,
> 
> On 6/2/25 10:51, Sascha Hauer wrote:
> > cdev partitions are cdevs themselves, but they are handled internally in
> > the devfs-core. cdev partitions should not be passed as context pointers
> > to the cdev ops though, because the drivers might do a container_of() on
> > them to retrieve their driver data. Pass the original cdev the driver
> > has registered as context to the ops. With this we can drop some quirks
> > in the nvmem core in the next step.
> 
> Given that read/write and so on take absolute offsets, I agree that this
> is a sensible change.
> 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> 
> With below nit addressed:
> 
> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> 
> > ---
> >  fs/devfs-core.c | 53 +++++++++++++++++++++++++++++++++++++++++------------
> >  1 file changed, 41 insertions(+), 12 deletions(-)
> > 
> > diff --git a/fs/devfs-core.c b/fs/devfs-core.c
> > index 5fafcaecc70d63287e0b716cc0133198c28e79e9..73a13be7336df1eb4e24e8a936986b6069f3783c 100644
> > --- a/fs/devfs-core.c
> > +++ b/fs/devfs-core.c
> > @@ -224,12 +224,21 @@ int cdev_find_free_index(const char *basename)
> >  	return -EBUSY;	/* all indexes are used */
> >  }
> >  
> > +static struct cdev *cdev_get_master(struct cdev *cdev)
> > +{
> > +	while (cdev && cdev_is_partition(cdev))
> > +		cdev = cdev->master;
> 
> This can be made into a simple if condition as we do not support links
> to links, see cdev_readlink.

This patch is not about links, it's about partitions and we can indeed
partitiion a partition.

You can try with

addpart /dev/imx-ocotp 128@0x10(foo)
addpart /dev/imx-ocotp.foo 64@0x10(foo1)

reading from the latter fails with a core dump without this patch.

As far as I can tell links are not affected by this problem as we always
resolve links by doing a cdev = cdev_readlink(cdev), so the link cdevs
are never passed down to drivers.

Sascha

-- 
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-06-02 10:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-02  8:51 [PATCH 0/2] cdev partition fix Sascha Hauer
2025-06-02  8:51 ` [PATCH 1/2] cdev: pass master cdev to cdev ops Sascha Hauer
2025-06-02  9:03   ` Ahmad Fatoum
2025-06-02 10:12     ` Sascha Hauer [this message]
2025-06-02 10:20       ` Ahmad Fatoum
2025-06-02  8:51 ` [PATCH 2/2] nvmem: Drop now unnecessary partition quirk Sascha Hauer
2025-06-02 12:30 ` [PATCH 0/2] cdev partition fix 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=aD15Cc9vcj73bvW_@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.