mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <ahmad@a3f.at>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH master 1/3] driver: have dev_name(unregistered device) behave as expected
Date: Mon, 9 Jan 2023 10:12:17 +0100	[thread overview]
Message-ID: <20230109091217.GC28911@pengutronix.de> (raw)
In-Reply-To: <20230109083600.1820078-1-ahmad@a3f.at>

On Mon, Jan 09, 2023 at 09:35:58AM +0100, Ahmad Fatoum wrote:
> For drivers that create new virtual child devices, error paths often
> tend to use dev_name() on the uninitialized device via the dev_ family
> of logging functions. Many such uninitialized devices have a name set
> already though, but just lacks registration, which leads to dev_id
> returning dev->unique_name, which may be NULL. Change dev_name to
> return dev->name if dev->unique_name is NULL.
> 
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
>  include/driver.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/include/driver.h b/include/driver.h
> index 693d5cb3e580..4d500ed21e34 100644
> --- a/include/driver.h
> +++ b/include/driver.h
> @@ -191,7 +191,9 @@ static inline const char *dev_id(const struct device *dev)
>  
>  static inline const char *dev_name(const struct device *dev)
>  {
> -	return dev_id(dev);
> +	if (!dev)
> +		return NULL;
> +	return dev_id(dev) ?: dev->name;
>  }
>  
>  int dev_set_name(struct device *dev, const char *fmt, ...);
> -- 
> 2.38.1
> 
> 
> 

-- 
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 |



      parent reply	other threads:[~2023-01-09  9:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09  8:35 Ahmad Fatoum
2023-01-09  8:35 ` [PATCH master 2/3] efi: acpi: add SDT resource before registering device Ahmad Fatoum
2023-01-09  8:36 ` [PATCH master 3/3] reset: core: support deep probe with resets registered in CLK_OF_DECLARE Ahmad Fatoum
2023-01-09  9:12 ` 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=20230109091217.GC28911@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=ahmad@a3f.at \
    --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