[PATCH v2 5/6] mtd: partitions: pass around 'mtd_partitions' wrapper struct
Boris Brezillon
boris.brezillon at free-electrons.com
Fri Dec 4 16:41:02 PST 2015
On Sat, 5 Dec 2015 01:30:49 +0100
Boris Brezillon <boris.brezillon at free-electrons.com> wrote:
> How about defining a new function to encourage mtd drivers to pass an
> mtd_partitions structure instead of the parts + nr_parts arguments.
> Note that I don't ask to update all call sites, but only to add a new
> function and transform mtd_device_parse_register() into a wrapper.
>
> int mtd_device_parse_and_register_parts(struct mtd_info *mtd,
> const char *const *types,
> const struct mtd_partitions *parts)
> {
> struct mtd_partitions parsed = { };
> int ret;
>
> ret = parse_mtd_partitions(mtd, types, &parsed, parser_data);
> if (!ret)
Should be
if (!ret && parsed.nr_parts > 0)
> parts = &parsed;
>
> if (!parts || !parts->nr_parts) {
> /* Didn't come up with parsed OR fallback partitions */
> pr_info("mtd: failed to find partitions; one or more parsers reports errors (%d)\n",
> ret);
> /* Don't abort on errors; we can still use unpartitioned MTD */
> }
>
> ret = mtd_add_device_partitions(mtd, &parsed);
> if (ret)
> goto out;
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
More information about the linux-mtd
mailing list