From: Marcel Holtmann <holtmann@linux.intel.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: John Linville <linville@tuxdriver.com>,
Tomas Winkler <tomasw@gmail.com>,
linux-wireless <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH v2] iwlwifi: get rid of IWL_{GET,SET}_BITS crap
Date: Mon, 06 Oct 2008 20:18:52 +0200 [thread overview]
Message-ID: <1223317132.11272.219.camel@violet.holtmann.net> (raw)
In-Reply-To: <1223315348.3778.13.camel@johannes.berg>
Hi Johannes,
> This makes the code surrounding the last few things using
> IWL_SET_BITS16 actually readable and removes the macros
> so nobody will ever consider using them again.
>
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> ---
> Tested on 5000 hw.
>
> v2: don't BUG_ON an invalid index because it actually happens!
>
> drivers/net/wireless/iwlwifi/iwl-4965-hw.h | 85 +++++++++---------------
> drivers/net/wireless/iwlwifi/iwl-4965.c | 15 ++--
> drivers/net/wireless/iwlwifi/iwl-5000-hw.h | 61 +++++++++--------
> drivers/net/wireless/iwlwifi/iwl-5000.c | 41 ++++++-----
> drivers/net/wireless/iwlwifi/iwl-helpers.h | 102 -----------------------------
> drivers/net/wireless/iwlwifi/iwl-tx.c | 6 -
> 6 files changed, 99 insertions(+), 211 deletions(-)
>
> --- wireless-testing.orig/drivers/net/wireless/iwlwifi/iwl-4965-hw.h 2008-10-06 18:01:57.207234025 +0200
> +++ wireless-testing/drivers/net/wireless/iwlwifi/iwl-4965-hw.h 2008-10-06 19:35:09.488701911 +0200
> @@ -857,18 +857,24 @@ struct iwl_tfd_addr_desc {
> * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx.
> */
> struct iwl_tfd_frame {
> - __le32 val0;
> - /* __le32 rsvd1:24; */
> - /* __le32 num_tbs:5; */
> -#define IWL_num_tbs_POS 24
> -#define IWL_num_tbs_LEN 5
> -#define IWL_num_tbs_SYM val0
> - /* __le32 rsvd2:1; */
> - /* __le32 padding:2; */
> + u8 reserved1[3];
> + u8 num_tbs; /* 5 bits, rest reserved/padding */
> struct iwl_tfd_addr_desc addrs[20];
> __le32 reserved;
> } __attribute__ ((packed));
>
> +static inline u8 iwl_get_num_tbs(struct iwl_tfd_frame *frame)
> +{
> + return frame->num_tbs & 0x1f;
> +}
> +
> +static inline void iwl_set_num_tbs(struct iwl_tfd_frame *frame, u8 num_tbs)
> +{
> + BUG_ON(num_tbs >= 20);
> +
> + frame->num_tbs &= ~0x1f;
> + frame->num_tbs |= num_tbs;
> +}
what is this magic doing and what is wrong with
frame->num_tbs = num_tbs & 0x1f
Or do you expect to do something with the upper 3 bits?
Personally I think it is important that we always zero any data
structure and especially the reserved bits of it. Otherwise stuff just
magically seems to work, but it is pure luck if the right bits are set.
The overall patch looks good to me and I think it is the way to go. Less
home grown bit magic the better.
Regards
Marcel
next prev parent reply other threads:[~2008-10-06 18:18 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-06 16:50 [PATCH] iwlwifi: get rid of IWL_{GET,SET}_BITS crap Johannes Berg
2008-10-06 17:45 ` Johannes Berg
2008-10-06 17:49 ` [PATCH v2] " Johannes Berg
2008-10-06 18:18 ` Marcel Holtmann [this message]
2008-10-06 18:24 ` Johannes Berg
2008-10-06 18:35 ` [PATCH] " Tomas Winkler
2008-10-06 19:12 ` Marcel Holtmann
2008-10-06 20:24 ` drago01
2008-10-06 21:32 ` Christoph Hellwig
2008-10-07 6:21 ` Holger Schurig
2008-10-07 7:15 ` Christoph Hellwig
2008-10-07 13:16 ` John W. Linville
2008-10-07 14:03 ` Tomas Winkler
2008-10-07 16:58 ` Johannes Berg
2008-10-07 19:28 ` Tomas Winkler
2008-10-07 19:34 ` Johannes Berg
2008-10-07 19:39 ` Johannes Berg
2008-10-07 20:06 ` Tomas Winkler
2008-10-07 20:10 ` Johannes Berg
2008-10-07 20:46 ` Tomas Winkler
2008-10-08 8:02 ` Johannes Berg
2008-10-08 12:38 ` Tomas Winkler
2008-10-09 9:52 ` Johannes Berg
2008-10-09 16:35 ` Tomas Winkler
2008-10-07 20:01 ` Tomas Winkler
2008-10-07 20:06 ` Johannes Berg
2008-10-07 20:08 ` Tomas Winkler
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=1223317132.11272.219.camel@violet.holtmann.net \
--to=holtmann@linux.intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=tomasw@gmail.com \
/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).