The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: James Hilliard <james.hilliard1@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
	 Vignesh Raghavendra <vigneshr@ti.com>,
	 linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	 stable@vger.kernel.org
Subject: Re: [PATCH] mtd: take a reference when opening an unpartitioned master
Date: Fri, 20 Nov 2026 15:54:41 +0100	[thread overview]
Message-ID: <87pkvza6z2.fsf@bootlin.com> (raw)
In-Reply-To: <20261108-submit-mtd-master-open-reference-v1-v1-1-871aac8c6e05@gmail.com> (James Hilliard's message of "Sun, 08 Nov 2026 14:12:39 -0700")

On 08/11/2026 at 14:12:39 -07, James Hilliard <james.hilliard1@gmail.com> wrote:

> CONFIG_MTD_PARTITIONED_MASTER controls whether a master is registered
> alongside its partitions. Without that option, an unpartitioned device
> is still registered as a master and can be opened directly.

"can be opened directly"

> __get_mtd_device() skips the master while walking the parent chain and
> only takes its reference when CONFIG_MTD_PARTITIONED_MASTER is enabled.
> A direct open therefore leaves the registration reference as the sole
> reference. Unregistering the device releases its device-model and
> NVMEM

"releases its device-model"

> state while the handle remains open.
>
> Take and release the master reference for direct opens as well. Retain
 > the existing behavior for partition handles whose master is not
> registered.

Is this really what you do? The code does not test whether the
master is registered. The condition is:

	mtd == master || IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER)

As a result:

- A handle on the master takes a master reference.
- A handle on a partition takes a master reference only when
  CONFIG_MTD_PARTITIONED_MASTER is enabled.

No? I believe the code is correct, but that's again one of those very
imprecise commit logs where words taken independently are fine but put
alltogether don't build any meaningful message in my brain. Maybe:

  A handle on the master now takes a master reference. A handle on a
  partition takes a master reference only when CONFIG_MTD_PARTITIONED_MASTER
  is enabled.

In general I think this commit log must be reworded.

Thanks,
Miquèl

      reply	other threads:[~2026-11-20 14:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-08 21:12 [PATCH] mtd: take a reference when opening an unpartitioned master James Hilliard
2026-11-20 14:54 ` 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=87pkvza6z2.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=james.hilliard1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    --cc=vigneshr@ti.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