Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.duyck@gmail.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [next-queue 1/8] e1000: clean up the useless 'continue' statement
Date: Wed, 16 Sep 2015 14:09:02 -0700	[thread overview]
Message-ID: <55F9DA6E.8090300@gmail.com> (raw)
In-Reply-To: <F274D7F1-7F0F-4C42-95BB-47E22E9DB386@intel.com>

On 09/16/2015 11:27 AM, Rustad, Mark D wrote:
>> On Sep 16, 2015, at 9:38 AM, Alexander Duyck <alexander.duyck@gmail.com> wrote:
>>
>> I kind of like Mark's idea better, though I would make one change.  I would make it so that you pull the check for i outside the loop so you have something like:
>> 		for (i = 0; i < 32; i++) {
>> 			hw->phy_addr = i;
>> 			e1000_read_phy_reg(hw, PHY_ID2, &tmp);
>>
>> 			if (tmp != 0 && tmp != 0xFF)
>> 				break;
>> 		}
>>
>> 		if (i >= 32)
>> 			goto no_err;
> Shouldn't that goto target be err_eeprom?

You're right.  My goof there.

>> This way you should only have to ever do a comparison of i once per loop, and hopefully the compiler is smart enough to realize that i >= 32 is the exit condition for the loop and will place the jump to that label accordingly.
> Yes, obviously I prefer the above form, with the corrected goto target, since that is what I described. The only difference being >= vs = and thought shouldn't matter. With >= being the logical opposite of the loop end test, it is probably the better choice.

I originally wrote it as == but the >= is the more explicit. Normally 
the loop would probably do a cmp followed by a jb to repeat the loop.

>> As a side note I am curious if this code is even correct.  I see tmp is a u16, the declaration for which could be moved down into the if statement if I am not mistaken, and I am curious as to why we are comparing it to 0xFF instead of 0xFFFF.  I suspect that the 0xFF check might not be adding any value, but I could be wrong.
> Yow! That is a really good question that I don't have an immediate answer to, having no experience with the internals of the e1000 driver and the devices it supports. Some research is required to answer that question.

I have a very strong suspicion that the 0xFF value is an error, but I 
don't see the documentation for the ce4100 anywhere to be had on where 
they came up with that value.  If it is supposed to be the result of a 
register read failure I believe the result would already be 0 since 
there is a flag in the register that indicates a read status failue and 
if it is set the value isn't stored.

- Alex

  reply	other threads:[~2015-09-16 21:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-14  6:27 [Intel-wired-lan] [next-queue 0/8] Trivial fix-ups for Intel wired LAN drivers 09/10/2015 =?unknown-8bit?q?J=CE=B5an?= Sacren
2015-09-14  6:27 ` [Intel-wired-lan] [next-queue 1/8] e1000: clean up the useless 'continue' statement =?unknown-8bit?q?J=CE=B5an?= Sacren
2015-09-14 16:48   ` Rustad, Mark D
2015-09-15  5:35     ` =?unknown-8bit?q?J=CE=B5an?= Sacren
2015-09-15 18:24       ` Rustad, Mark D
2015-09-16 15:34         ` =?unknown-8bit?q?J=CE=B5an?= Sacren
2015-09-16 16:38           ` Alexander Duyck
2015-09-16 18:27             ` Rustad, Mark D
2015-09-16 21:09               ` Alexander Duyck [this message]
2015-09-16 23:36                 ` Rustad, Mark D
2015-09-14  6:27 ` [Intel-wired-lan] [next-queue 2/8] e1000: fix a typo in the comment =?unknown-8bit?q?J=CE=B5an?= Sacren
2015-09-14  6:27 ` [Intel-wired-lan] [next-queue 3/8] e1000e: clean up the local variable =?unknown-8bit?q?J=CE=B5an?= Sacren
2015-09-14  6:27 ` [Intel-wired-lan] [next-queue 4/8] i40e: fix kernel-doc argument name =?unknown-8bit?q?J=CE=B5an?= Sacren
2015-09-22 21:27   ` Bowers, AndrewX
2015-09-14  6:27 ` [Intel-wired-lan] [next-queue 5/8] ixgbe: fix multiple kernel-doc errors =?unknown-8bit?q?J=CE=B5an?= Sacren
2015-09-14  6:27 ` [Intel-wired-lan] [next-queue 6/8] i40e: declare rather than initialize int object =?unknown-8bit?q?J=CE=B5an?= Sacren
2015-09-14  6:27 ` [Intel-wired-lan] [next-queue 7/8] e1000: fix kernel-doc argument being missing =?unknown-8bit?q?J=CE=B5an?= Sacren
2015-09-14  6:27 ` [Intel-wired-lan] [next-queue 8/8] e1000: get rid of duplicate exit path =?unknown-8bit?q?J=CE=B5an?= Sacren

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=55F9DA6E.8090300@gmail.com \
    --to=alexander.duyck@gmail.com \
    --cc=intel-wired-lan@osuosl.org \
    /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