[RFC PATCH 4/7] mtd: add of_match_mtd_parser() and of_mtd_match_mtd_parser() helpers
Rob Herring
robh+dt at kernel.org
Sun Dec 6 18:45:40 PST 2015
On Fri, Dec 4, 2015 at 11:19 PM, Brian Norris
<computersforpeace at gmail.com> wrote:
> Like the corresponding OF-based device/driver matching infrascture,
typo.
> let's begin to support a mtd/partition-parser matching infrastructure.
>
> Signed-off-by: Brian Norris <computersforpeace at gmail.com>
> ---
> drivers/of/of_mtd.c | 33 +++++++++++++++++++++++++++++++++
BTW, this file should be moved to drivers/mtd/ at some point.
> include/linux/mtd/partitions.h | 2 ++
> include/linux/of_mtd.h | 13 +++++++++++++
> 3 files changed, 48 insertions(+)
>
> diff --git a/drivers/of/of_mtd.c b/drivers/of/of_mtd.c
> index b7361ed70537..169d7500af5d 100644
> --- a/drivers/of/of_mtd.c
> +++ b/drivers/of/of_mtd.c
> @@ -9,6 +9,7 @@
> #include <linux/kernel.h>
> #include <linux/of_mtd.h>
> #include <linux/mtd/nand.h>
> +#include <linux/mtd/partitions.h>
> #include <linux/export.h>
>
> /**
> @@ -117,3 +118,35 @@ bool of_get_nand_on_flash_bbt(struct device_node *np)
> return of_property_read_bool(np, "nand-on-flash-bbt");
> }
> EXPORT_SYMBOL_GPL(of_get_nand_on_flash_bbt);
> +
> +static const struct of_device_id *of_match_mtd_parser(
This function name and the only caller's function name are very
similar. Why not just move this function inline.
> + struct mtd_part_parser *parser, struct device_node *np)
> +{
> + if (!parser || !np)
> + return NULL;
> +
> + return of_match_node(parser->of_match_table, np);
> +}
> +
> +static struct device_node *mtd_get_partitions_of_node(struct mtd_info *master)
> +{
> + struct device_node *np = mtd_get_of_node(master);
> +
> + if (!np)
> + return NULL;
> +
> + return of_get_child_by_name(np, "partitions");
> +}
> +
> +bool of_mtd_match_mtd_parser(struct mtd_info *mtd,
> + struct mtd_part_parser *parser)
> +{
> + struct device_node *np = mtd_get_partitions_of_node(mtd);
> + bool ret;
> +
> + ret = of_match_mtd_parser(parser, np) != NULL;
> + of_node_put(np);
> +
> + return ret;
> +}
More information about the linux-mtd
mailing list