Re: [PATCH v4 01/11] mtd: core: always create master device
From: Richard Weinberger
Date: Wed Jan 15 2025 - 17:36:13 EST
Alexander,
----- Ursprüngliche Mail -----
> Von: "Alexander Usyskin" <alexander.usyskin@xxxxxxxxx>
> Create master device without partition when
> CONFIG_MTD_PARTITIONED_MASTER flag is unset.
>
> This streamlines device tree and allows to anchor
> runtime power management on master device in all cases.
Please explain in more detail why this is needed.
If this change makes the overall situation better and breaks
no userspace, I'm happy. :-)
>From skimming over the patch I think the mtd_master device completely
useless for userspace, right?
> int add_mtd_device(struct mtd_info *mtd)
> {
> struct device_node *np = mtd_get_of_node(mtd);
> struct mtd_info *master = mtd_get_master(mtd);
> struct mtd_notifier *not;
> + bool partitioned = true;
> int i, error, ofidx;
>
> /*
> @@ -655,6 +678,11 @@ int add_mtd_device(struct mtd_info *mtd)
> if (WARN_ONCE(mtd->dev.type, "MTD already registered\n"))
> return -EEXIST;
>
> + if ((master == mtd) && !IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER)) {
> + partitioned = false;
> + pr_debug("mtd: unpartitioned master %s\n", mtd->name);
> + }
So, when CONFIG_MTD_PARTITIONED_MASTER is not set and a driver like MTDRAM
does mtd_device_register(mtd, NULL, 0) we end up here with partitioned = false,
and allocate just a master device but no real mtd because with zero
parts the mtd_device_parse_register() function will not call add_mtd_device(). :-(
Thanks,
//richard