public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@kernel.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [u-boot PATCH v5 04/10] ti: common: board_detect: commodify ethaddr environment setting code
Date: Wed, 15 Mar 2017 16:46:36 +0200	[thread overview]
Message-ID: <871stywqb7.fsf@linux.intel.com> (raw)
In-Reply-To: <c810ddef-e57d-7b27-f0f2-e9f722808384@ti.com>


Hi,

Roger Quadros <rogerq@ti.com> writes:
>> On Tue, Mar 14, 2017 at 3:05 PM Roger Quadros <rogerq at ti.com <mailto:rogerq@ti.com>> wrote:
>> 
>>     +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;
>>     +               if (num_macs <= 0)
>>     +                       return;
>> 
>> 
>> seems like there's still one minor improvement here:
>> 
>> If num_macs < 0, then it could be that mac1 and mac2 are swapped.
>> 
>> Perhaps test for that ?
>> 
>> if (num_macs == 0)
>>      bail();
>> 
>> if (num_macs < 0) {
>>         if ((mac1 - mac2 + 1) < 50) {
>>                 num_macs = mac1 - mac2 + 1;
>>                 mac1 ^= mac2;
>>                 mac2 ^= mac1;
>>                 mac1 ^= mac2;
>> [...]
>> 
>> don't know how much this may help, it's a judgment call, I suppose
>
> We don't have any boards with swapped mac1 and mac2. We'd like to

in that case, why would (mac2-mac1+1) ever be < 0?

-- 
balbi

  reply	other threads:[~2017-03-15 14:46 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
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 [this message]
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=871stywqb7.fsf@linux.intel.com \
    --to=balbi@kernel.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