public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/5] Add Ethernet hardware MAC address framework to usbnet
Date: Tue, 12 Apr 2011 18:30:49 -0400	[thread overview]
Message-ID: <201104121830.50386.vapier@gentoo.org> (raw)
In-Reply-To: <1302642840-6958-2-git-send-email-sjg@chromium.org>

On Tuesday, April 12, 2011 17:13:57 Simon Glass wrote:
> Built-in Ethernet adapters support setting the mac address by means of a
> ethaddr environment variable for each interface (ethaddr, eth1addr,
> eth2addr).
> 
> This adds similar support to the USB network side, using the names
> usbethaddr, usbeth1addr, etc. They are kept separate since we don't want
> a USB device taking the MAC address of a built-in device or vice versa.

i dont know about that part.  it isnt like built-in devices generally "come 
and go" like USB.  maybe Wolfgang will have an opinion.

> --- a/include/net.h
> +++ b/include/net.h
> +/*
> + * Get the hardware address for an ethernet interface .
> + * Args:
> + *	base_name - base name for device (NULL for "eth")
> + *	index - device index number (0 for first)
> + *	enetaddr - returns 6 byte hardware address
> + * Returns:
> + *	1 = ok, 0 = invalid MAC address
> + */
> +extern int eth_getenv_enetaddr_by_index(char *base_name, int index,
> +					uchar *enetaddr);

the base_name must be const

might be better to document the return value the same way we document the 
ultimate func it calls: "Return true if the address is valid".

> +/*
> + * Set the hardware address for an ethernet interface based on 'eth%daddr'
> + * environment variable (or just 'ethaddr' if eth_number is 0).
> + * Args:
> + *	base_name - base name for device (NULL for "eth")
> + *	eth_number - value of %d (0 for first device of this type)
> + * Returns:
> + *	0 = ok, -1 = driver reported error trying to set address
> + */
> +int eth_set_hwaddr(struct eth_device *dev, char *base_name, int
> eth_number);

the base_name must be const.

i'd document return as "0 is success, non-zero is error status from driver".

also, the naming is a bit confusing.  better to stick with the "write" aspect 
which this ultimately calls into: eth_write_hwaddr().

> --- a/net/eth.c
> +++ b/net/eth.c
> +int eth_set_hwaddr(struct eth_device *dev, char *base_name, int
> ...
> +	if (strchr(dev->name, ' '))
> +		puts("\nWarning: eth device name has a space!\n");

this should not be relocated here.  it belongs in the registration step only.

> +		memcpy(dev->enetaddr, env_enetaddr, 6);
> +	}
> +	if (dev->write_hwaddr &&
> +		!eth_mac_skip(eth_number) &&
> +		is_valid_ether_addr(dev->enetaddr)) {
> +		ret = dev->write_hwaddr(dev);
> +	}
> +	return ret;

but new lines before/after that write_addr if block please
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110412/cf22e6cc/attachment.pgp 

  reply	other threads:[~2011-04-12 22:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-12 21:13 [U-Boot] [PATCH 1/5] Add support for SMSC95XX USB 2.0 10/100MBit Ethernet Adapter Simon Glass
2011-04-12 21:13 ` [U-Boot] [PATCH 2/5] Add Ethernet hardware MAC address framework to usbnet Simon Glass
2011-04-12 22:30   ` Mike Frysinger [this message]
2011-04-12 21:13 ` [U-Boot] [PATCH 3/5] Add documentation for USB Host Networking Simon Glass
2011-04-30 19:23   ` Wolfgang Denk
2011-04-12 21:13 ` [U-Boot] [PATCH 4/5] Put common autoload code into AutoLoad() function Simon Glass
2011-04-12 21:58   ` Wolfgang Denk
2011-04-13  0:41     ` Simon Glass
2011-04-12 21:14 ` [U-Boot] [PATCH 5/5] Allow tftp server to be different from bootp/dhcp server Simon Glass
2011-04-12 21:56   ` Wolfgang Denk
2011-04-13  0:28     ` Simon Glass
2011-04-13  5:26       ` Wolfgang Denk
2011-04-13 18:42         ` Simon Glass
2011-04-13 19:42           ` Wolfgang Denk
2011-04-12 21:50 ` [U-Boot] [PATCH 1/5] Add support for SMSC95XX USB 2.0 10/100MBit Ethernet Adapter Wolfgang Denk
2011-04-13  0:53   ` Simon Glass
2011-04-12 22:32 ` Mike Frysinger

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=201104121830.50386.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --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