From: Felipe Balbi <felipe.balbi@linux.intel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [u-boot PATCH v4 04/10] ti: common: board_detect: commodify ethaddr environment setting code
Date: Mon, 13 Mar 2017 15:15:30 +0200 [thread overview]
Message-ID: <87a88pwc5p.fsf@linux.intel.com> (raw)
In-Reply-To: <1489410273-10159-5-git-send-email-rogerq@ti.com>
Hi,
Roger Quadros <rogerq@ti.com> writes:
> +void board_ti_set_ethaddr(int index)
> +{
> + uint8_t mac_addr[6];
> + int i;
> + u64 mac1, mac2;
> + u8 mac_addr1[6], mac_addr2[6];
> + int num_macs;
> + /*
> + * Export any Ethernet MAC addresses from EEPROM.
> + * The 2 MAC addresses in EEPROM define the address range.
> + */
> + board_ti_get_eth_mac_addr(0, mac_addr1);
> + board_ti_get_eth_mac_addr(1, mac_addr2);
> +
> + if (is_valid_ethaddr(mac_addr1) && is_valid_ethaddr(mac_addr2)) {
> + mac1 = mac_to_u64(mac_addr1);
> + mac2 = mac_to_u64(mac_addr2);
> +
> + /* must contain an address range */
> + num_macs = mac2 - mac1 + 1;
> + /* <= 50 to protect against user programming error */
> + if (num_macs > 0 && num_macs <= 50) {
if user programs a range > 50, then you do nothing. How about allowing
up to 50 addresses?
Something like:
if (num_macs < 0)
bail_out();
if (num_macs > 50) {
printf("Too many addresses. %d > 50\n", num_macs);
num_macs = 50;
}
this also mean you can reduce indentation level for the for loop.
--
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170313/72ee0d0d/attachment.sig>
next prev parent reply other threads:[~2017-03-13 13:15 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-13 13:04 [U-Boot] [u-boot PATCH v4 00/10] am57xx-idk LCD and am571x-idk 6 port ethernet pinmux Roger Quadros
2017-03-13 13:04 ` [U-Boot] [u-boot PATCH v4 01/10] ARM: OMAP5+: GPIO: Add GPIO_TO_PIN() macro Roger Quadros
2017-03-21 18:08 ` [U-Boot] [U-Boot, u-boot, v4, " Tom Rini
2017-03-13 13:04 ` [U-Boot] [u-boot PATCH v4 02/10] ti: common: board_detect: Rename EEPROM scratch start macro Roger Quadros
2017-03-21 18:08 ` [U-Boot] [U-Boot, u-boot, v4, " Tom Rini
2017-03-13 13:04 ` [U-Boot] [u-boot PATCH v4 03/10] ti_armv7_keystone2: Define scratch space in SRAM Roger Quadros
2017-03-17 14:08 ` Tom Rini
2017-03-21 18:08 ` [U-Boot] [U-Boot, u-boot, v4, " Tom Rini
2017-03-13 13:04 ` [U-Boot] [u-boot PATCH v4 04/10] ti: common: board_detect: commodify ethaddr environment setting code Roger Quadros
2017-03-13 13:15 ` Felipe Balbi [this message]
2017-03-14 10:52 ` Roger Quadros
2017-03-14 13:04 ` [U-Boot] [u-boot PATCH v5 " Roger Quadros
2017-03-14 15:54 ` Felipe Balbi
2017-03-15 13:53 ` Roger Quadros
2017-03-15 14:46 ` Felipe Balbi
2017-03-15 15:04 ` Roger Quadros
2017-03-21 18:08 ` [U-Boot] [U-Boot, u-boot, v5, " Tom Rini
2017-03-13 13:04 ` [U-Boot] [u-boot PATCH v4 05/10] board: ti: am571x-idk: Support 6 port Ethernet or 4 port Ethernet with LCD Roger Quadros
2017-03-21 18:08 ` [U-Boot] [U-Boot, u-boot, v4, " Tom Rini
2017-03-13 13:04 ` [U-Boot] [u-boot PATCH v4 06/10] board: ti: am571x-idk: Update pinmux for ICSS2 Ethernet Roger Quadros
2017-03-21 18:08 ` [U-Boot] [U-Boot, u-boot, v4, " Tom Rini
2017-03-13 13:04 ` [U-Boot] [u-boot PATCH v4 07/10] board: ti: am57xx-idk: Auto detect LCD Panel Roger Quadros
2017-03-21 18:08 ` [U-Boot] [U-Boot, u-boot, v4, " Tom Rini
2017-03-13 13:04 ` [U-Boot] [u-boot PATCH v4 08/10] ARM: Use Kconfig for board EEPROM's I2C bus and chip address Roger Quadros
2017-03-21 18:09 ` [U-Boot] [U-Boot, u-boot, v4, " Tom Rini
2017-03-13 13:04 ` [U-Boot] [u-boot PATCH v4 09/10] ARM: k2g: setup PRU ethernet MAC addresses Roger Quadros
2017-03-21 18:09 ` [U-Boot] [U-Boot, u-boot, v4, " Tom Rini
2017-03-13 13:04 ` [U-Boot] [u-boot PATCH v4 10/10] net: don't override ethernet address environment Roger Quadros
2017-03-17 14:08 ` Tom Rini
2017-03-21 18:09 ` [U-Boot] [U-Boot, u-boot, v4, " Tom Rini
2017-03-17 14:08 ` [U-Boot] [u-boot PATCH v4 00/10] am57xx-idk LCD and am571x-idk 6 port ethernet pinmux Tom Rini
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=87a88pwc5p.fsf@linux.intel.com \
--to=felipe.balbi@linux.intel.com \
--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