public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] base: soc: set machine name in soc_device_register if empty
Date: Fri, 17 Mar 2023 06:08:51 +0100	[thread overview]
Message-ID: <ZBP14wghbJPCnAFJ@kroah.com> (raw)
In-Reply-To: <d667b435-bf4c-ee7d-2da8-559354124578@gmail.com>

On Thu, Mar 16, 2023 at 09:35:59PM +0100, Heiner Kallweit wrote:
> Several SoC drivers use the same of-based mechanism to populate the machine
> name. Therefore move this to the core and try to populate the machine name
> in soc_device_register if it's not set yet.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/base/soc.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/base/soc.c b/drivers/base/soc.c
> index 0fb1d4ab9..8dec5228f 100644
> --- a/drivers/base/soc.c
> +++ b/drivers/base/soc.c
> @@ -7,6 +7,7 @@
>  
>  #include <linux/sysfs.h>
>  #include <linux/init.h>
> +#include <linux/of.h>
>  #include <linux/stat.h>
>  #include <linux/slab.h>
>  #include <linux/idr.h>
> @@ -110,6 +111,18 @@ static void soc_release(struct device *dev)
>  	kfree(soc_dev);
>  }
>  
> +static void soc_device_set_machine(struct soc_device_attribute *soc_dev_attr)
> +{
> +	struct device_node *np;
> +
> +	if (soc_dev_attr->machine)
> +		return;
> +
> +	np = of_find_node_by_path("/");
> +	of_property_read_string(np, "model", &soc_dev_attr->machine);
> +	of_node_put(np);
> +}
> +
>  static struct soc_device_attribute *early_soc_dev_attr;
>  
>  struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr)
> @@ -118,6 +131,8 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr
>  	const struct attribute_group **soc_attr_groups;
>  	int ret;
>  
> +	soc_device_set_machine(soc_dev_attr);
> +

Does this mean some SoC drivers should also be changed at the same time
if they are trying to do this?

And is "model" the correct of property for this?  I thought that devices
also had "model" as a valid entry, is this documented somewhere in the
DTS schema that I couldn't find?

thanks,

greg k-h

  reply	other threads:[~2023-03-17  5:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 20:35 [PATCH] base: soc: set machine name in soc_device_register if empty Heiner Kallweit
2023-03-17  5:08 ` Greg Kroah-Hartman [this message]
2023-03-17  9:25   ` Heiner Kallweit
2023-03-17 11:41     ` Greg Kroah-Hartman
2023-03-17 11:59       ` Heiner Kallweit

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=ZBP14wghbJPCnAFJ@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=hkallweit1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@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