mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/2] ARM: i.MX8M: convert the machine init to the soc driver
Date: Thu, 11 Jan 2024 16:30:58 +0100	[thread overview]
Message-ID: <20240111153058.GB2711697@pengutronix.de> (raw)
In-Reply-To: <20240111115120.2678876-2-m.felsch@pengutronix.de>

On Thu, Jan 11, 2024 at 12:51:20PM +0100, Marco Felsch wrote:
> Convert the i.MX8M machine init code to the previously introduced soc
> framework. The soc driver was mostly copied from Linux with slightly
> adaptions for barebox. To the soc driver is called during the
> postcore_initcall to keep the level aligned with the previous imx_init().
> 
> +static int __init imx8_soc_init(void)
> +{
> +	struct device_node *of_root = of_get_root_node();
> +	struct soc_device_attribute *soc_dev_attr;
> +	struct soc_device *soc_dev;
> +	const struct of_device_id *id;
> +	u32 soc_rev = 0;
> +	const struct imx8_soc_data *data;
> +	int ret;
> +
> +	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
> +	if (!soc_dev_attr)
> +		return -ENOMEM;
> +
> +	soc_dev_attr->family = "Freescale i.MX";
> +
> +	ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
> +	if (ret)
> +		goto free_soc;
> +
> +	id = of_match_node(imx8_soc_match, of_root);
> +	if (!id) {
> +		ret = -ENODEV;
> +		goto free_soc;
> +	}

This is executed as an initcall and as such shouldn't assume it's
running on an i.MX8. Please check for foreign SoCs early and return
without an error in that case.

> +
> +	soc_dev_attr->serial_number = basprintf("%016llX", soc_uid);

xasprintf should be fine here.

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:[~2024-01-11 15:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-11 11:51 [PATCH 1/2] Port SoC framework from Linux Marco Felsch
2024-01-11 11:51 ` [PATCH 2/2] ARM: i.MX8M: convert the machine init to the soc driver Marco Felsch
2024-01-11 15:30   ` Sascha Hauer [this message]
2024-01-11 16:30     ` Marco Felsch

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=20240111153058.GB2711697@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    /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