linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Enrico Weigelt, metux IT consult" <info@metux.net>
To: linux-kernel@vger.kernel.org
Cc: vireshk@kernel.org, b.zolnierkie@samsung.com, axboe@kernel.dk,
	herbert@gondor.apana.org.au, davem@davemloft.net,
	linux-ide@vger.kernel.org, linux-block@vger.kernel.org,
	linux-crypto@vger.kernel.org
Subject: [PATCH 1/4] mod_devicetable: helper macro for declaring oftree module device table
Date: Sat,  1 Jun 2019 15:52:56 +0200	[thread overview]
Message-ID: <1559397179-5833-2-git-send-email-info@metux.net> (raw)
In-Reply-To: <1559397179-5833-1-git-send-email-info@metux.net>

Little helper macros that declares an oftree module device table,
if CONFIG_OF is enabled. Otherwise it's just noop. Helpful for
reducing the number of #ifdef's.

Instead of:
    MODULE_DEVICE_TABLE(of, foo);
now use:
    MODULE_OF_TABLE(foo);

Or declare the whole table via:
    MODULE_DECLARE_OF_TABLE(foo,
        { .compatible = "foo" },
        { .compatible = "bar" });

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
 include/linux/mod_devicetable.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 448621c..5f4f2dc8 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -245,6 +245,19 @@ struct of_device_id {
 	const void *data;
 };
 
+/*
+ * macro for adding the of module device table only if CONFIG_OF enabled
+ */
+#ifdef CONFIG_OF
+#define MODULE_OF_TABLE(name)	MODULE_DEVICE_TABLE(of,name)
+#define MODULE_DECLARE_OF_TABLE(name,entries...) \
+static const struct of_device_id name[] = { entries, {} };
+#else
+#define MODULE_OF_TABLE(name)
+#define MODULE_DECLARE_OF_TABLE(name,entries...) \
+static const struct of_device_id *name = NULL;
+#endif /* CONFIG_OF */
+
 /* VIO */
 struct vio_device_id {
 	char type[32];
-- 
1.9.1


  reply	other threads:[~2019-06-01 13:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-01 13:52 RFC: declaring DT match tables (2nd take) Enrico Weigelt, metux IT consult
2019-06-01 13:52 ` Enrico Weigelt, metux IT consult [this message]
2019-06-01 13:52 ` [PATCH 2/4] drivers: block: xsysace: use MODULE_DECLARE_OF_TABLE() and of_match_ptr() Enrico Weigelt, metux IT consult
2019-06-01 13:52 ` [PATCH 3/4] drivers: crypto: picoxcell_crypto: use MODULE_DECLARE_OF_TABLE() Enrico Weigelt, metux IT consult
2019-06-01 13:52 ` [PATCH 4/4] drivers: ata: " Enrico Weigelt, metux IT consult
  -- strict thread matches above, loose matches on Subject: below --
2019-04-16 19:57 gpio-keys-polled improvements Enrico Weigelt, metux IT consult
2019-04-16 19:57 ` [PATCH 1/4] mod_devicetable: helper macro for declaring oftree module device table Enrico Weigelt, metux IT consult
2019-04-19  7:40   ` Dmitry Torokhov
2019-04-24 10:48     ` Enrico Weigelt, metux IT consult
2019-04-29 19:48       ` Frank Rowand

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=1559397179-5833-2-git-send-email-info@metux.net \
    --to=info@metux.net \
    --cc=axboe@kernel.dk \
    --cc=b.zolnierkie@samsung.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vireshk@kernel.org \
    /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).