From: Joe Perches <joe@perches.com>
To: Devendra Naga <devendra.aaru@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Justin P. Mattock" <justinmattock@gmail.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2 3/3] staging/rtl8192u: use for loop to assign bit shifted addr
Date: Tue, 19 Jun 2012 12:19:55 -0700 [thread overview]
Message-ID: <1340133595.27131.6.camel@joe2Laptop> (raw)
In-Reply-To: <1340132894-19003-1-git-send-email-devendra.aaru@gmail.com>
On Wed, 2012-06-20 at 00:38 +0530, Devendra Naga wrote:
> this change is a rewrite of that bitshifted addr copying
> logic with for loop, which can easily understandable.
>
> Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
> ---
> drivers/staging/rtl8192u/r8180_93cx6.c | 27 +++++++++------------------
> 1 file changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/staging/rtl8192u/r8180_93cx6.c b/drivers/staging/rtl8192u/r8180_93cx6.c
> index a72bbd4..815b0f3 100644
> --- a/drivers/staging/rtl8192u/r8180_93cx6.c
> +++ b/drivers/staging/rtl8192u/r8180_93cx6.c
> @@ -102,25 +102,16 @@ u32 eprom_read(struct net_device *dev, u32 addr)
> force_pci_posting(dev);
> udelay(EPROM_DELAY);
>
> - if (priv->epromtype==EPROM_93c56){
> - addr_str[7]=addr & 1;
> - addr_str[6]=addr & (1<<1);
> - addr_str[5]=addr & (1<<2);
> - addr_str[4]=addr & (1<<3);
> - addr_str[3]=addr & (1<<4);
> - addr_str[2]=addr & (1<<5);
> - addr_str[1]=addr & (1<<6);
> - addr_str[0]=addr & (1<<7);
> - addr_len=8;
> - }else{
> - addr_str[5]=addr & 1;
> - addr_str[4]=addr & (1<<1);
> - addr_str[3]=addr & (1<<2);
> - addr_str[2]=addr & (1<<3);
> - addr_str[1]=addr & (1<<4);
> - addr_str[0]=addr & (1<<5);
> - addr_len=6;
> + if (priv->epromtype == EPROM_93c56) {
> + addr_len = 8;
> + for (i = 0; i < addr_len; i++)
> + addr_str[i] = addr & (1 << (addr_len - (i + 1)));
> + } else {
> + addr_len = 6;
> + for (i = 0; i < addr_len; i++)
> + addr_str[i] = addr & (1 << (addr_len - (i + 1)));
> }
It's also got a bit of code duplication.
Maybe something like:
if (priv->epromtype == EPROM_93c56) {
addr_len = 8;
else
addr_len = 6;
test_bit = 1 << (addr_len - 1);
for (i = 0; i < addr_len; i++) {
addr_str[i] = addr & test_bit;
test_bit >>= 1;
}
next prev parent reply other threads:[~2012-06-19 19:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-19 19:08 [PATCH V2 3/3] staging/rtl8192u: use for loop to assign bit shifted addr Devendra Naga
2012-06-19 19:19 ` Joe Perches [this message]
2012-06-20 6:31 ` devendra.aaru
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=1340133595.27131.6.camel@joe2Laptop \
--to=joe@perches.com \
--cc=devel@driverdev.osuosl.org \
--cc=devendra.aaru@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=justinmattock@gmail.com \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.