[U-Boot] [U-Boot, v2, 5/6] da850: add support to read mac address from spi flash

Tom Rini trini at ti.com
Mon Dec 5 23:38:45 CET 2011


On 01/-10/-28163 12:59 PM, Hadli wrote:

> From: Manjunath Hadli <manjunath.hadli at ti.com>
> 
> add support to read mac address from spi flash if env variable
> is not set. This is supported only on L138 boards based on da850
> SOC. Introduced a macro CONFIG_MAC_ADDR_IN_SPIFLASH indicating
> where to look mac address for.
> 
> Signed-off-by: Manjunathappa, Prakash <prakash.pm at ti.com>
> Signed-off-by: Manjunath Hadli <manjunath.hadli at ti.com>

Sorry for the very late reply. gmail ate this email on me it seems.

[snip]
> +static int get_mac_addr(u8 *addr)
> +{
> +	struct spi_flash *flash;
> +	int ret;
> +
> +
> +	flash = spi_flash_probe(CFG_MAC_ADDR_SPI_BUS, CFG_MAC_ADDR_SPI_CS,
> +			CFG_MAC_ADDR_SPI_MAX_HZ, CFG_MAC_ADDR_SPI_MODE);
> +	if (!flash) {
> +		printf(" Error - unable to probe SPI flash.\n");

Leading space in the printf.

> +		ret = -1;
> +		goto err_probe;
> +	}
> +
> +	ret = spi_flash_read(flash, CFG_MAC_ADDR_OFFSET, 6, addr);
> +	if (ret) {
> +		printf("Error - unable to read MAC address from SPI flash.\n");
> +		goto err_read;
> +	}
> +
> +err_read:
> +	/* cannot call free currently since the free function calls free() for
> +	 * spi_flash structure though it is not directly allocated through
> +	 * malloc()
> +	 */
> +err_probe:
> +	return ret;
> +}

We never called malloc() so it doesn't make sense to comment about not
being able to call free() here.  In fact, we should just do a 'return
-1'  after the printf here.

> +#endif
> +
>  void dsp_lpsc_on(unsigned domain, unsigned int id)
>  {
>  	dv_reg_p mdstat, mdctl, ptstat, ptcmd;
> @@ -220,7 +261,25 @@ static void dspwake(void)
>  
>  int misc_init_r(void)
>  {
> +	uchar buff[8];
> +	int ret;

Potential unused variable warnings here.

-- 
Tom


More information about the U-Boot mailing list