[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFLxGvwRnBtscaJDQ4qYGpQt87+amKYb4vBJvtt-3BmsOorL_g@mail.gmail.com>
Date: Wed, 22 May 2019 23:26:48 +0200
From: Richard Weinberger <richard.weinberger@...il.com>
To: Chris Packham <Chris.Packham@...iedtelesis.co.nz>
Cc: David Woodhouse <dwmw2@...radead.org>,
Brian Norris <computersforpeace@...il.com>,
Marek Vasut <marek.vasut@...il.com>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>,
"linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] mtd: concat: implement _is_locked mtd operation
On Wed, May 22, 2019 at 11:06 PM Chris Packham
<Chris.Packham@...iedtelesis.co.nz> wrote:
>
> On 23/05/19 8:44 AM, Richard Weinberger wrote:
> > On Wed, May 22, 2019 at 2:08 AM Chris Packham
> > <chris.packham@...iedtelesis.co.nz> wrote:
> >>
> >> Add an implementation of the _is_locked operation for concatenated mtd
> >> devices. As with concat_lock/concat_unlock this can simply use the
> >> common helper and pass mtd_is_locked as the operation.
> >>
> >> Signed-off-by: Chris Packham <chris.packham@...iedtelesis.co.nz>
> >> ---
> >> drivers/mtd/mtdconcat.c | 6 ++++++
> >> 1 file changed, 6 insertions(+)
> >>
> >> diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
> >> index 9514cd2db63c..0e919f3423af 100644
> >> --- a/drivers/mtd/mtdconcat.c
> >> +++ b/drivers/mtd/mtdconcat.c
> >> @@ -496,6 +496,11 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
> >> return __concat_xxlock(mtd, ofs, len, mtd_unlock);
> >> }
> >>
> >> +static int concat_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
> >> +{
> >> + return __concat_xxlock(mtd, ofs, len, mtd_is_locked);
> >> +}
> >
> > Hmm, here you start abusing your own new API. :(
>
> Abusing because xxlock is a poor choice of name? I initially had a third
> copy of the logic from lock/unlock which is what lead me to do the
> cleanup first. mtd_lock(), mtd_unlock() and mtd_is_locked() all work the
> same way namely given an offset and a length either lock, unlock or
> return the status of the len/erasesz blocks at ofs.
Well, for unlock/lock it is just a loop which applies an operation to
a given range on all submtds.
But as soon an operation returns non-zero, the loop stops and returns
that error.
This makes sense for unlock/lock.
Now you abuse this as "apply a random mtd operation to a given range".
So, giving it a proper name is the first step. Step two is figuring
for what kind
of mtd operations it makes sense and is correct.
> >
> > Did you verify that the unlock/lock-functions deal correctly with all
> > semantics from mtd_is_locked?
> > i.e. mtd_is_locked() with len = 0 returns 1 for spi-nor.
> >
>
> I believe so. I've only got access to a parallel NOR flash system that
> uses concatenation and that seems sane (is mtdconcat able to work with
> spi memories?). The concat_is_locked() should just reflect what the
> underlying mtd device driver returns.
mtdconcat *should* work with any mtd. But I never used it much, I see
it more as legacy
code.
What happens if one submtd is locked and another not?
Does concat_is_locked() return something sane then?
I'd expect it to return true if at least one submtd is locked and 0
of no submtd is locked.
If the loop and return code handling in __concat_xxlock() can take care of that,
awesome. Then all you need is giving it a better name. :-)
--
Thanks,
//richard
Powered by blists - more mailing lists