public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Igor Grinberg <grinberg@compulab.co.il>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/3] compulab: eeprom: add support for obtaining product name
Date: Thu, 3 Sep 2015 11:45:46 +0300	[thread overview]
Message-ID: <55E808BA.4060709@compulab.co.il> (raw)
In-Reply-To: <1441209920-10583-3-git-send-email-nikita@compulab.co.il>

Hi Nikita,

On 09/02/15 19:05, Nikita Kiryanov wrote:
> Introduce cl_eeprom_get_product_name() for obtaining product name
> from the eeprom.
> 
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> ---
>  board/compulab/common/eeprom.c | 19 +++++++++++++++++++
>  board/compulab/common/eeprom.h |  5 +++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/board/compulab/common/eeprom.c b/board/compulab/common/eeprom.c
> index aaacd2e..a48da93 100644
> --- a/board/compulab/common/eeprom.c
> +++ b/board/compulab/common/eeprom.c
> @@ -25,6 +25,8 @@
>  #define BOARD_REV_OFFSET		0
>  #define BOARD_REV_OFFSET_LEGACY		6
>  #define BOARD_REV_SIZE			2
> +#define BOARD_PRODUCT_NAME_OFFSET	128
> +#define BOARD_PRODUCT_NAME_SIZE		16

Please, can we make it shorter like with the MAC_ADDR?
e.g. PRODUCT_NAME_*

>  #define MAC_ADDR_OFFSET			4
>  #define MAC_ADDR_OFFSET_LEGACY		0
>  
> @@ -149,3 +151,20 @@ u32 cl_eeprom_get_board_rev(uint eeprom_bus)
>  
>  	return board_rev;
>  };
> +
> +static char product_name[BOARD_PRODUCT_NAME_SIZE];

That variable does not serve any good purpose...

> +char *cl_eeprom_get_product_name(uint eeprom_bus)
> +{
> +	if (cl_eeprom_setup(eeprom_bus))
> +		return NULL;
> +
> +	if (cl_eeprom_read(BOARD_PRODUCT_NAME_OFFSET,
> +			   (uchar *)product_name, BOARD_PRODUCT_NAME_SIZE)) {
> +		return NULL;
> +	}
> +
> +	/* Protect ourselves from invalid data (unterminated string) */
> +	product_name[BOARD_PRODUCT_NAME_SIZE - 1] = '\0';
> +
> +	return product_name;
> +}

I'd like to see this function implemented as the
cl_eeprom_read_mac_addr() function is.

> diff --git a/board/compulab/common/eeprom.h b/board/compulab/common/eeprom.h
> index e74c379..fceb5df 100644
> --- a/board/compulab/common/eeprom.h
> +++ b/board/compulab/common/eeprom.h
> @@ -13,6 +13,7 @@
>  #ifdef CONFIG_SYS_I2C
>  int cl_eeprom_read_mac_addr(uchar *buf, uint eeprom_bus);
>  u32 cl_eeprom_get_board_rev(uint eeprom_bus);
> +char *cl_eeprom_get_product_name(uint eeprom_bus);
>  #else
>  static inline int cl_eeprom_read_mac_addr(uchar *buf, uint eeprom_bus)
>  {
> @@ -22,6 +23,10 @@ static inline u32 cl_eeprom_get_board_rev(uint eeprom_bus)
>  {
>  	return 0;
>  }
> +static inline char *cl_eeprom_get_product_name(uint eeprom_bus)
> +{
> +	return NULL;
> +}
>  #endif
>  
>  #endif
> 

-- 
Regards,
Igor.

  reply	other threads:[~2015-09-03  8:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02 16:05 [U-Boot] [PATCH 0/3] cm-fx6 updates for Utilite Nikita Kiryanov
2015-09-02 16:05 ` [U-Boot] [PATCH 1/3] compulab: eeprom: select i2c bus when querying for board rev Nikita Kiryanov
2015-09-03  8:35   ` Igor Grinberg
2015-09-02 16:05 ` [U-Boot] [PATCH 2/3] compulab: eeprom: add support for obtaining product name Nikita Kiryanov
2015-09-03  8:45   ` Igor Grinberg [this message]
2015-09-02 16:05 ` [U-Boot] [PATCH 3/3] arm: mx6: cm-fx6: modify device tree for old revisions of utilite Nikita Kiryanov
2015-09-03  8:57   ` Igor Grinberg

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=55E808BA.4060709@compulab.co.il \
    --to=grinberg@compulab.co.il \
    --cc=u-boot@lists.denx.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