mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Bastian Krause <bst@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 3/3] nvmem: ocotp: set unique id as machine-id hashable
Date: Wed, 17 Jul 2019 11:50:42 +0200	[thread overview]
Message-ID: <20190717095042.4wptlgeprjjxa5ky@pengutronix.de> (raw)
In-Reply-To: <20190716105837.18237-3-bst@pengutronix.de>

On Tue, Jul 16, 2019 at 12:58:37PM +0200, Bastian Krause wrote:
> Pass the OCOTP unique id as hashable information to machine id
> generation.
> 
> Signed-off-by: Bastian Krause <bst@pengutronix.de>
> ---
>  drivers/nvmem/ocotp.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/nvmem/ocotp.c b/drivers/nvmem/ocotp.c
> index 3f9f162860..6f76ad9ac0 100644
> --- a/drivers/nvmem/ocotp.c
> +++ b/drivers/nvmem/ocotp.c
> @@ -29,6 +29,7 @@
>  #include <regmap.h>
>  #include <linux/clk.h>
>  #include <mach/ocotp.h>
> +#include <machine_id.h>
>  #include <linux/nvmem-provider.h>
>  
>  /*
> @@ -77,6 +78,9 @@
>  #define MAC_OFFSET_1			(0x24 * 4)
>  #define MAX_MAC_OFFSETS			2
>  #define MAC_BYTES			8
> +#define UNIQUE_ID_NUM			2
> +/* 0 <= n < UNIQUE_ID_NUM */
> +#define UNIQUE_ID(n)			(OCOTP_WORD(0x410 + 0x10 * (n)) | OCOTP_BIT(0) | OCOTP_WIDTH(32))
>  
>  enum imx_ocotp_format_mac_direction {
>  	OCOTP_HW_TO_MAC,
> @@ -548,6 +552,23 @@ static int imx_ocotp_read(struct device_d *dev, const int offset, void *val,
>  	return regmap_bulk_read(priv->map, offset, val, bytes);
>  }
>  
> +static int imx_ocotp_set_unique_machine_id(void)
> +{
> +	uint32_t unique_id_parts[UNIQUE_ID_NUM];
> +	int ret, i;
> +
> +	for (i = 0; i < UNIQUE_ID_NUM; i++) {
> +		ret = imx_ocotp_read_field(UNIQUE_ID(i), &unique_id_parts[i]);
> +		if (ret < 0)
> +			goto out;
> +	}
> +
> +	machine_id_set_hashable(&unique_id_parts, sizeof(unique_id_parts));

So unique_id_parts is on the stack. As said, better make a copy in
machine_id_set_hashable() ;)

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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:[~2019-07-17  9:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-16 10:58 [PATCH 1/3] digest.h: needs errno definitions Bastian Krause
2019-07-16 10:58 ` [PATCH 2/3] common: machine_id: introduce machine id generation and pass id on Bastian Krause
2019-07-17  9:48   ` Sascha Hauer
2019-07-17  9:58     ` Bastian Krause
2019-07-17 10:31       ` Sascha Hauer
2019-07-17 10:34         ` Bastian Krause
2019-07-17  9:53   ` Ahmad Fatoum
2019-07-17 10:02   ` Roland Hieber
2019-07-17 10:31     ` Ahmad Fatoum
2019-07-17 14:02       ` Bastian Krause
2019-07-17 14:18         ` Sascha Hauer
2019-07-16 10:58 ` [PATCH 3/3] nvmem: ocotp: set unique id as machine-id hashable Bastian Krause
2019-07-17  9:50   ` 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=20190717095042.4wptlgeprjjxa5ky@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=bst@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