From: Brian Norris <computersforpeace@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.kernel.org,
"Boris Brezillon" <boris.brezillon@free-electrons.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Simon Arlott" <simon@fire.lp0.eu>,
"Jason Gunthorpe" <jgunthorpe@obsidianresearch.com>,
"Jonas Gorski" <jogo@openwrt.org>,
"Brian Norris" <computersforpeace@gmail.com>,
devicetree@vger.kernel.org, devicetree-spec@vger.kernel.org,
"Rob Herring" <robh+dt@kernel.org>,
"Rafał Miłecki" <zajec5@gmail.com>,
"Hauke Mehrtens" <hauke@hauke-m.de>,
"Arnd Bergmann" <arnd@arndb.de>
Subject: [RFC PATCH 4/7] mtd: add of_match_mtd_parser() and of_mtd_match_mtd_parser() helpers
Date: Fri, 4 Dec 2015 21:19:20 -0800 [thread overview]
Message-ID: <1449292763-129421-5-git-send-email-computersforpeace@gmail.com> (raw)
In-Reply-To: <1449292763-129421-1-git-send-email-computersforpeace@gmail.com>
Like the corresponding OF-based device/driver matching infrascture,
let's begin to support a mtd/partition-parser matching infrastructure.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/of/of_mtd.c | 33 +++++++++++++++++++++++++++++++++
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(
+ 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;
+}
+EXPORT_SYMBOL_GPL(of_mtd_match_mtd_parser);
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 70736e1e6c8f..2e68ef561a40 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -51,6 +51,7 @@ struct mtd_partition {
struct mtd_info;
struct device_node;
+struct of_device_id;
/**
* struct mtd_part_parser_data - used to pass data to MTD partition parsers.
@@ -69,6 +70,7 @@ struct mtd_part_parser {
struct list_head list;
struct module *owner;
const char *name;
+ const struct of_device_id *of_match_table;
int (*parse_fn)(struct mtd_info *, const struct mtd_partition **,
struct mtd_part_parser_data *);
void (*cleanup)(const struct mtd_partition *pparts, int nr_parts);
diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h
index e266caa36402..781362d0be0c 100644
--- a/include/linux/of_mtd.h
+++ b/include/linux/of_mtd.h
@@ -9,6 +9,10 @@
#ifndef __LINUX_OF_MTD_H
#define __LINUX_OF_MTD_H
+#include <linux/mtd/mtd.h>
+
+struct mtd_part_parser;
+
#ifdef CONFIG_OF_MTD
#include <linux/of.h>
@@ -18,6 +22,9 @@ int of_get_nand_ecc_strength(struct device_node *np);
int of_get_nand_bus_width(struct device_node *np);
bool of_get_nand_on_flash_bbt(struct device_node *np);
+bool of_mtd_match_mtd_parser(struct mtd_info *mtd,
+ struct mtd_part_parser *parser);
+
#else /* CONFIG_OF_MTD */
static inline int of_get_nand_ecc_mode(struct device_node *np)
@@ -45,6 +52,12 @@ static inline bool of_get_nand_on_flash_bbt(struct device_node *np)
return false;
}
+static inline bool of_mtd_match_mtd_parser(struct mtd_info *mtd,
+ struct mtd_part_parser *parser)
+{
+ return false;
+}
+
#endif /* CONFIG_OF_MTD */
#endif /* __LINUX_OF_MTD_H */
--
2.6.0.rc2.230.g3dd15c0
next prev parent reply other threads:[~2015-12-05 5:19 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-05 5:19 [RFC PATCH 0/7] mtd: partitions: add of_match_table support Brian Norris
2015-12-05 5:19 ` [RFC PATCH 1/7] mtd: move partition parsers to drivers/mtd/partitions/ Brian Norris
2015-12-05 5:19 ` [RFC PATCH 2/7] mtd: move partition parsers' Kconfig under a sub-menu Brian Norris
2015-12-05 5:19 ` Brian Norris [this message]
[not found] ` <1449292763-129421-5-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-07 2:45 ` [RFC PATCH 4/7] mtd: add of_match_mtd_parser() and of_mtd_match_mtd_parser() helpers Rob Herring
[not found] ` <CAL_JsqLV1mDpW9tD0XjWRxZSSsYuDiqHbuADQmBUtACgYiHJ+w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-07 18:13 ` Brian Norris
[not found] ` <20151207181308.GN120110-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2015-12-07 19:00 ` Rob Herring
2015-12-05 5:19 ` [RFC PATCH 6/7] RFC: mtd: partitions: enable of_match_table matching Brian Norris
2015-12-05 5:19 ` [RFC PATCH 7/7] mtd: partitions: add Google's FMAP partition parser Brian Norris
[not found] ` <1449292763-129421-1-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-05 5:19 ` [RFC PATCH 3/7] doc: dt: mtd: partition: add on-flash format binding Brian Norris
[not found] ` <1449292763-129421-4-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-05 11:39 ` Jonas Gorski
[not found] ` <CAOiHx=nz2bdA_R610ozsQHhccdcrHVVCamTtne5ReHrA-FcaaQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-05 21:33 ` Michal Suchanek
[not found] ` <CAOMqctTbUNd0GtY07YJuxem9HkU1WZ-NtO556=Yg2QrsF49Xjw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-07 1:36 ` David Gibson
[not found] ` <20151207013628.GC20139-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2015-12-10 20:43 ` Brian Norris
[not found] ` <20151210204324.GK144338-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2015-12-11 15:58 ` Michal Suchanek
2015-12-12 5:51 ` David Gibson
[not found] ` <20151212055105.GA17011-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2015-12-14 10:22 ` Geert Uytterhoeven
[not found] ` <CAMuHMdXA4-BZpvtCM8_9fYWLzoVsuCXDqvF3G4cVd50Cqsfv0g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-14 12:28 ` Michal Suchanek
2015-12-15 6:00 ` David Gibson
[not found] ` <20151215060056.GB3011-1s0os16eZneny3qCrzbmXA@public.gmane.org>
2015-12-15 10:03 ` Geert Uytterhoeven
2015-12-17 1:05 ` David Gibson
2015-12-07 3:07 ` Rob Herring
2015-12-05 5:19 ` [RFC PATCH 5/7] mtd: partitions: factor out "match by name" handling Brian Norris
2015-12-05 10:15 ` [RFC PATCH 0/7] mtd: partitions: add of_match_table support Geert Uytterhoeven
[not found] ` <CAMuHMdUJXHs_OhT0da+kzc=D4MOFUT9BB3eJ+7a_p6DYx-PKBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-05 18:06 ` Michal Suchanek
2015-12-10 20:54 ` Brian Norris
[not found] ` <20151210205449.GL144338-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2015-12-11 8:44 ` Geert Uytterhoeven
[not found] ` <CAMuHMdV-uethsChWVZGSx1JNcAofODmg14ppGYJP2ewfwhEv1Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-11 15:34 ` Michal Suchanek
[not found] ` <CAOMqctQVMCEa_k4xMW1qooEpe8X1-NhUOjD6pp0qJpDP_H+8hw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-11 16:00 ` Geert Uytterhoeven
[not found] ` <CAMuHMdV2feXKWkJzRkMUBiAUCxp4LwaRgg+aPYwm0sUnKzm0Rg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-11 16:18 ` Michal Suchanek
2015-12-12 1:33 ` Brian Norris
[not found] ` <20151212013349.GA86087-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2015-12-14 10:15 ` Geert Uytterhoeven
2015-12-05 11:35 ` Jonas Gorski
[not found] ` <CAOiHx==8TFK9t4h2C0Q+j==nuRP3EbyVa+nuYuSEj_LCDa820Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-10 21:06 ` Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1449292763-129421-5-git-send-email-computersforpeace@gmail.com \
--to=computersforpeace@gmail.com \
--cc=arnd@arndb.de \
--cc=boris.brezillon@free-electrons.com \
--cc=devicetree-spec@vger.kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=hauke@hauke-m.de \
--cc=jgunthorpe@obsidianresearch.com \
--cc=jogo@openwrt.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=robh+dt@kernel.org \
--cc=simon@fire.lp0.eu \
--cc=zajec5@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).