mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2] mtd: consult CONFIG_OFDEVICE in mtd_get_of_node
Date: Wed, 11 Jan 2023 18:35:48 +0100	[thread overview]
Message-ID: <20230111173548.1660598-1-a.fatoum@pengutronix.de> (raw)

Get barebox on non-DT platforms with NAND a tiny bit smaller by
directly returning NULL if CONFIG_OFDEVICE is not enabled, thereby
allowing more code to be discarded at compile-time in absence of
link-time optimization.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - don't dereference parent device without NULL-check (Sascha)
---
 include/linux/mtd/mtd.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 6b539a9eceb5..54cb2ec64ce2 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -293,6 +293,8 @@ static inline void mtd_set_of_node(struct mtd_info *mtd,
 
 static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
 {
+	if (!IS_ENABLED(CONFIG_OFDEVICE))
+		return NULL;
 	if (mtd->dev.of_node)
 		return mtd->dev.of_node;
 	if (mtd->dev.parent)
-- 
2.30.2




             reply	other threads:[~2023-01-11 17:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 17:35 Ahmad Fatoum [this message]
2023-01-12 14:50 ` Sascha Hauer

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=20230111173548.1660598-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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