Re: [PATCH] mtd: avoid registering reboot notifier twice

From: Brian Norris
Date: Mon Feb 02 2015 - 04:20:28 EST


On Mon, Feb 02, 2015 at 10:01:51AM +0100, Ricard Wanderlof wrote:
>
> > On 02/02/2015 12:07 AM, Brian Norris wrote:
> > >
> > > No driver should be calling mtd_device_parse_register() multiple times
> > > on the same mtd_info. Under what context do you see this? What driver?
> > arch/cris/arch-v32/drivers/axisflashmap.c
>
> Looking at it another way, why should it not be allowed, if the only
> thing stopping it from working is Niklas' fix below?

It severely breaks the way that normal MTD partition parsers work, for
one. cmdlineparts could never be sanely applied here, for instance.

> If there are multiple
> ways a driver can acquire partitioning information, it is handy to be able
> to do mtd_device_parse_register() several times, rather than collecting
> all the partitioning information in one place and doing the call there,
> which I suppose would be the alternative.

It may be handy, but it breaks the abstraction that is established in
most every other case, that partitions are determined by exactly one
source: a single list from platform data, device tree, the kernel
command line, or an on-flash parser (e.g., RedBoot, bcm47xxpart, etc.).

> I've noted that mtd/nand/diskonchip.c does it too:
>
> mtd_device_register(mtd, NULL, 0);
> if (!no_autopart)
> mtd_device_register(mtd, parts, numparts);
>
> but this driver might be essentially deprecated, I don't know.

Yeah, I just noticed that one too.

TBH, I'm not sure the reboot notifier patch places that code in the best
place anyway. There really is no central initialization code for the
'master' mtd_info struct, as this initialization is handled ad-hoc in
every single MTD driver. It just happens that the partition
parsing/registration function fit nicely as the one place that (almost)
all MTD master devices got registered. But this just exposed yet another
instance where my assumptions are challenged.

There's so much legacy crap in MTD that sometimes I wonder why I even
bother...

Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/