mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Oleksij Rempel <o.rempel@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH v1 5/5] ARM: boards: protonic-imx6: add HW revision specific machine compatible
Date: Wed, 27 Apr 2022 10:00:48 +0200	[thread overview]
Message-ID: <0f90ecf7-75a3-4a6a-5188-90817c595bc0@pengutronix.de> (raw)
In-Reply-To: <20220427073724.3126601-5-o.rempel@pengutronix.de>

On 27.04.22 09:37, Oleksij Rempel wrote:
> Currently we use generic/pinned machine compatible for different HW
> revisions. With this patch we extend this compatible string with HW
> revision specific.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  arch/arm/boards/protonic-imx6/board.c | 25 +++++++++++++++++++++----
>  1 file changed, 21 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/boards/protonic-imx6/board.c b/arch/arm/boards/protonic-imx6/board.c
> index 0fadd148b4..1a1e5540ee 100644
> --- a/arch/arm/boards/protonic-imx6/board.c
> +++ b/arch/arm/boards/protonic-imx6/board.c
> @@ -85,6 +85,7 @@ struct prt_imx6_priv {
>  	const struct prt_machine_data *dcfg;
>  	unsigned int hw_id;
>  	unsigned int hw_rev;
> +	const char *compatible;
>  	const char *name;
>  	unsigned int usb_delay;
>  	unsigned int no_usb_check;
> @@ -126,6 +127,20 @@ static const struct gpio prt_imx6_kvg_gpios[] = {
>  	},
>  };
>  
> +static int prt_of_fixup_hwrev(struct device_node *dstroot, void *arg)
> +{
> +	struct prt_imx6_priv *priv = prt_priv;
> +	char *buf;
> +
> +	buf = xasprintf("%s,model:%u,rev:%u", priv->compatible, priv->hw_id,
> +			priv->hw_rev);

: is not a valid character for device tree property names.
(https://github.com/devicetree-org/devicetree-specification/releases/download/v0.4-rc1/devicetree-specification-v0.4-rc1.pdf
 Table 2.2)

While barebox might not mind, it's better you stick to the standard
character set.

> +	of_fixup_machine_compatible(dstroot, buf);
> +
> +	free(buf);
> +
> +	return 0;
> +}
> +
>  static int prt_imx6_read_rfid(struct prt_imx6_priv *priv, void *buf,
>  			      size_t size)
>  {
> @@ -797,7 +812,7 @@ exit_get_dcfg:
>  static int prt_imx6_probe(struct device_d *dev)
>  {
>  	struct prt_imx6_priv *priv;
> -	const char *name, *ptr;
> +	const char *ptr;
>  	struct param_d *p;
>  	int ret;
>  
> @@ -806,9 +821,9 @@ static int prt_imx6_probe(struct device_d *dev)
>  		return -ENOMEM;
>  
>  	priv->dev = dev;
> -	name = of_device_get_match_compatible(priv->dev);
> -	ptr = strchr(name, ',');
> -	priv->name =  ptr ? ptr + 1 : name;
> +	priv->compatible = of_device_get_match_compatible(priv->dev);
> +	ptr = strchr(priv->compatible, ',');
> +	priv->name =  ptr ? ptr + 1 : priv->compatible;

Could you reuse of_get_machine_compatible() here?

>  
>  	pr_info("Detected machine type: %s\n", priv->name);
>  
> @@ -841,6 +856,8 @@ static int prt_imx6_probe(struct device_d *dev)
>  
>  	prt_priv = priv;
>  
> +	of_register_fixup(prt_of_fixup_hwrev, NULL);
> +
>  	return 0;
>  free_priv:
>  	kfree(priv);


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

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


      reply	other threads:[~2022-04-27  8:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-27  7:37 [PATCH v1 1/5] common: add $global.serial_number with device tree fixup Oleksij Rempel
2022-04-27  7:37 ` [PATCH v1 2/5] ARM: boards: protonic-imx6: make use of barebox_set_serial_number() Oleksij Rempel
2022-04-27  7:37 ` [PATCH v1 3/5] of: add generic of_fixup_machine_compatible() Oleksij Rempel
2022-04-27  7:53   ` Ahmad Fatoum
2022-04-27  7:37 ` [PATCH v1 4/5] ARM: boards: skov-imx6: make use of of_fixup_machine_compatible() Oleksij Rempel
2022-04-27  7:37 ` [PATCH v1 5/5] ARM: boards: protonic-imx6: add HW revision specific machine compatible Oleksij Rempel
2022-04-27  8:00   ` Ahmad Fatoum [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=0f90ecf7-75a3-4a6a-5188-90817c595bc0@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=o.rempel@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