mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] mtd: consult CONFIG_OFDEVICE in mtd_get_of_node
Date: Tue, 10 Jan 2023 16:02:31 +0100	[thread overview]
Message-ID: <20230110150231.GQ28911@pengutronix.de> (raw)
In-Reply-To: <20230109150813.2051799-1-a.fatoum@pengutronix.de>

On Mon, Jan 09, 2023 at 04:08:13PM +0100, Ahmad Fatoum wrote:
> Get barebox on non-DT platforms with NAND a tiny bit smaller by using
> dev_of_node: The helper will return NULL unconditionally when
> 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>
> ---
>  include/linux/mtd/mtd.h | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 6b539a9eceb5..2824853e2954 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -293,11 +293,7 @@ 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 (mtd->dev.of_node)
> -		return mtd->dev.of_node;
> -	if (mtd->dev.parent)
> -		return mtd->dev.parent->of_node;
> -	return NULL;
> +	return dev_of_node(&mtd->dev) ?: dev_of_node(mtd->dev.parent);

Does every mtd device have a parent device? dev_of_node() doesn't cope
with a NULL pointer passed in.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2023-01-10 15:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09 15:08 Ahmad Fatoum
2023-01-10 15:02 ` Sascha Hauer [this message]

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=20230110150231.GQ28911@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=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