From: Andreas Mohr <andi@lisas.de>
To: Ondrej Zary <linux@rainbow-software.org>
Cc: Andreas Mohr <andi@lisas.de>,
Greg KH <gregkh@linuxfoundation.org>,
davem@davemloft.net, Michael Leun <lkml20120218@newton.leun.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mcs7830: Fix link state detection
Date: Thu, 11 Oct 2012 20:37:04 +0200 [thread overview]
Message-ID: <20121011183704.GA8636@rhlx01.hs-esslingen.de> (raw)
In-Reply-To: <201210111233.28652.linux@rainbow-software.org>
Hi,
On Thu, Oct 11, 2012 at 12:33:28PM +0200, Ondrej Zary wrote:
> u8 *buf = urb->transfer_buffer;
> bool link;
> + struct mcs7830_data *data = mcs7830_get_data(dev);
>
> if (urb->actual_length < 16)
> return;
Alternatively could do *data = NULL; and then actually assign after the conditional.
But since the conditional most likely is coldpath
I think your chosen implementation is best.
>
> link = !(buf[1] & 0x20);
> if (netif_carrier_ok(dev->net) != link) {
I usually like to introduce helper bools to clearly express the intention
behind things (source code should be readable like a book, yet it all
too often is everything but...).
I.e.
bool link_state_change_detected = (netif_carrier_ok......);
if (bool)
Might be an idea here, too.
The logic behind your counter implementation seems solid to me
(short explanatory comment "track link state several times, to guard against
transient erroneous link state of (some versions of?) this chip"
might have been useful though).
Thank you very much for your patch!
Andreas Mohr
next prev parent reply other threads:[~2012-10-11 18:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-11 10:33 Ondrej Zary
2012-10-11 18:37 ` Andreas Mohr [this message]
2012-10-11 19:20 ` David Miller
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=20121011183704.GA8636@rhlx01.hs-esslingen.de \
--to=andi@lisas.de \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rainbow-software.org \
--cc=lkml20120218@newton.leun.net \
--cc=netdev@vger.kernel.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
all inboxes | Powered by JetHome®