1 From 01f9c7240a900d5676a8496496f2974dd36996b1 Mon Sep 17 00:00:00 2001
2 From: Brian Norris <computersforpeace@gmail.com>
3 Date: Tue, 23 May 2017 07:30:20 +0200
4 Subject: [PATCH] mtd: partitions: factor out code calling parser
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 This code is going to be reused for parsers matched using OF so let's
10 factor it out to make this easier.
12 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
13 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
14 Acked-by: Brian Norris <computersforpeace@gmail.com>
16 drivers/mtd/mtdpart.c | 33 ++++++++++++++++++++++++---------
17 1 file changed, 24 insertions(+), 9 deletions(-)
19 --- a/drivers/mtd/mtdpart.c
20 +++ b/drivers/mtd/mtdpart.c
21 @@ -832,6 +832,27 @@ static const char * const default_mtd_pa
25 +static int mtd_part_do_parse(struct mtd_part_parser *parser,
26 + struct mtd_info *master,
27 + struct mtd_partitions *pparts,
28 + struct mtd_part_parser_data *data)
32 + ret = (*parser->parse_fn)(master, &pparts->parts, data);
33 + pr_debug("%s: parser %s: %i\n", master->name, parser->name, ret);
37 + pr_notice("%d %s partitions found on MTD device %s\n", ret,
38 + parser->name, master->name);
40 + pparts->nr_parts = ret;
41 + pparts->parser = parser;
47 * parse_mtd_partitions - parse MTD partitions
48 * @master: the master partition (describes whole MTD device)
49 @@ -872,16 +893,10 @@ int parse_mtd_partitions(struct mtd_info
50 parser ? parser->name : NULL);
53 - ret = (*parser->parse_fn)(master, &pparts->parts, data);
54 - pr_debug("%s: parser %s: %i\n",
55 - master->name, parser->name, ret);
57 - printk(KERN_NOTICE "%d %s partitions found on MTD device %s\n",
58 - ret, parser->name, master->name);
59 - pparts->nr_parts = ret;
60 - pparts->parser = parser;
61 + ret = mtd_part_do_parse(parser, master, pparts, data);
62 + /* Found partitions! */
66 mtd_part_parser_put(parser);
68 * Stash the first error we see; only report it if no parser