From: Ingo Oeser <netdev@axxeo.de>
To: "Kok, Auke" <auke-jan.h.kok@intel.com>
Cc: Jeff Garzik <jeff@garzik.org>,
Arjan van de Ven <arjan@linux.intel.com>,
Ayyappan Veeraiyan <ayyappan.veeraiyan@intel.com>,
netdev@vger.kernel.org, akpm@linux-foundation.org
Subject: Re: [PATCH] ixgbe: Introduce new 10GbE driver for Intel 82598 based PCI Express adapters...
Date: Fri, 6 Jul 2007 10:46:35 +0200 [thread overview]
Message-ID: <200707061046.37035.netdev@axxeo.de> (raw)
In-Reply-To: <46891FC9.9060307@intel.com>
Hi Auke,
Kok, Auke schrieb:
> tg3.c:
>
> if ((tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) ||
> (tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND))
>
> is obviously _not_ easier to read than
>
> if (tp->tg3_flags.pcix_target_hwbug || tp->tg3_flags.ich_workaround)
>
Yes, but what about:
static bool tg3_has_pcix_target_hwdebug(const struct tg3 *tp)
{
return (tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) != 0;
}
static bool tg3_has_ich_workaround(const struct tg3 *tp)
{
return (tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND) != 0;
}
if (tg3_has_pcix_target_hwdebug(tp) || tg3_has_ich_workaround(tp)) {
/* do foo */
}
That is just as nice as bitfields and makes that stuff more readable.
This is also a migration path while going from bitfields to flags incrementally.
If you find out that two of these tests are always done together you could even
test two of them in one.
> I would say that this method is definately worse for readability.
Yes, open coding this bit masking mess IS making code hardly readable!
> I would much rather then stick with 'bool' instead.
If you can afford the space, that is just as good. If you are undecided,
try the accessors. You can even write code, which generates them once.
Maybe we could get such nice script for generating
a set of bitmasks and accessors in the kernel :-)
Source would than be a struct definition with bitfields.
All points raised be the people here are actually valid and I consider
bitfields nice and clear for specification and example code,
but avoid them while doing real coding.
Best Regards
Ingo Oeser
next prev parent reply other threads:[~2007-07-06 9:06 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-12 23:44 [ANNOUNCE] new driver ixgbe for Intel(R) 10GbE PCI Express adapters Ayyappan.Veeraiyan
2007-06-12 23:44 ` [PATCH] ixgbe: Introduce new 10GbE driver for Intel 82598 based " Ayyappan Veeraiyan
2007-07-02 12:52 ` Jeff Garzik
2007-07-02 14:05 ` Arjan van de Ven
2007-07-02 14:25 ` Jeff Garzik
2007-07-02 14:27 ` Arjan van de Ven
2007-07-02 14:41 ` Jeff Garzik
2007-07-02 14:41 ` Arjan van de Ven
2007-07-02 15:26 ` Kok, Auke
2007-07-02 15:32 ` Jeff Garzik
2007-07-02 15:52 ` Andrew Morton
2007-07-02 16:09 ` Jeff Garzik
2007-07-02 15:54 ` Kok, Auke
2007-07-06 8:46 ` Ingo Oeser [this message]
2007-07-02 14:31 ` Arjan van de Ven
2007-07-02 19:00 ` Veeraiyan, Ayyappan
2007-07-02 19:04 ` Ayyappan Veeraiyan
2007-07-02 20:16 ` Christoph Hellwig
2007-07-02 21:09 ` Stephen Hemminger
2007-07-02 21:42 ` Christoph Hellwig
2007-07-02 22:02 ` Kok, Auke
2007-07-02 22:08 ` Jeff Garzik
2007-07-02 22:10 ` Michael Buesch
2007-07-02 22:16 ` Jeff Garzik
2007-07-02 23:57 ` Kok, Auke
2007-07-03 0:11 ` Jeff Garzik
2007-07-03 0:16 ` Inaky Perez-Gonzalez
2007-07-03 13:19 ` Jeff Garzik
2007-07-03 18:24 ` Inaky Perez-Gonzalez
2007-07-05 23:29 ` Jeff Garzik
2007-07-03 0:08 ` Veeraiyan, Ayyappan
2007-07-03 22:01 ` Ayyappan Veeraiyan
2007-07-02 22:56 ` Veeraiyan, Ayyappan
2007-07-03 12:53 ` Neil Horman
2007-07-05 12:37 ` Neil Horman
2007-07-09 14:21 ` Veeraiyan, Ayyappan
2007-07-10 0:57 ` Neil Horman
2007-06-13 23:05 ` [ANNOUNCE] new driver ixgbe for Intel(R) 10GbE " Francois Romieu
2007-06-13 23:18 ` Kok, Auke
2007-06-14 0:06 ` Ayyappan Veeraiyan
2007-06-14 20:36 ` Francois Romieu
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=200707061046.37035.netdev@axxeo.de \
--to=netdev@axxeo.de \
--cc=akpm@linux-foundation.org \
--cc=arjan@linux.intel.com \
--cc=auke-jan.h.kok@intel.com \
--cc=ayyappan.veeraiyan@intel.com \
--cc=jeff@garzik.org \
--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;
as well as URLs for NNTP newsgroup(s).