From: Malcolm Priestley <tvboxspy@gmail.com>
To: Oscar Carter <oscar.carter@gmx.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Forest Bond <forest@alittletooquiet.net>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
Gabriela Bittencourt <gabrielabittencourt00@gmail.com>,
Colin Ian King <colin.king@canonical.com>
Subject: Re: [PATCH] staging: vt6656: Use BIT_ULL() macro instead of bit shift operation
Date: Sun, 8 Mar 2020 19:22:07 +0000 [thread overview]
Message-ID: <561bc968-f88c-40e3-f53c-5c03f74f75ea@gmail.com> (raw)
In-Reply-To: <20200308161047.GA3285@ubuntu>
>>> */
>>> #undef __NO_VERSION__
>>>
>>> +#include <linux/bits.h>
>>> #include <linux/etherdevice.h>
>>> #include <linux/file.h>
>>> #include "device.h"
>>> @@ -802,8 +803,7 @@ static u64 vnt_prepare_multicast(struct ieee80211_hw *hw,
>>>
>>> netdev_hw_addr_list_for_each(ha, mc_list) {
>>> bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
>>> -
>>> - mc_filter |= 1ULL << (bit_nr & 0x3f);
>>> + mc_filter |= BIT_ULL(bit_nr);
>>
>> Are you sure this does the same thing? You are not masking off bit_nr
>> anymore, why not?
>
> My reasons are exposed below:
>
> The ether_crc function returns an u32 type (unsigned of 32 bits). Then the right
> shift operand discards the 26 lsb bits (the bits shifted off the right side are
> discarded). The 6 msb bits of the u32 returned by the ether_crc function are
> positioned in bit 5 to bit 0 of the variable bit_nr. Due to the right shift
> happens over an unsigned type, the 26 new bits added on the left side will be 0.
>
> In summary, after the right bit shift operation we obtain in the variable bit_nr
> (unsigned of 32 bits) the value represented by the 6 msb bits of the value
> returned by the ether_crc function. So, only the 6 lsb bits of the variable
> bit_nr are important. The 26 msb bits of this variable are 0.
>
> In this situation, the "and" operation with the mask 0x3f (mask of 6 lsb bits)
> is unnecessary due to its purpose is to reset (set to 0 value) the 26 msb bits
> that are yet 0.
The mask is only there out of legacy originally it was 31(0x1f) and the
bit_nr spread across two mc_filter u32 arrays.
The mask is not needed now it is u64.
The patch is fine.
Regards
Malcolm
next prev parent reply other threads:[~2020-03-08 19:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-07 10:49 Oscar Carter
2020-03-08 6:55 ` Greg Kroah-Hartman
2020-03-08 16:13 ` Oscar Carter
2020-03-08 19:22 ` Malcolm Priestley [this message]
2020-03-10 9:50 ` Greg Kroah-Hartman
2020-03-14 15:06 ` Oscar Carter
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=561bc968-f88c-40e3-f53c-5c03f74f75ea@gmail.com \
--to=tvboxspy@gmail.com \
--cc=colin.king@canonical.com \
--cc=devel@driverdev.osuosl.org \
--cc=forest@alittletooquiet.net \
--cc=gabrielabittencourt00@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oscar.carter@gmx.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
all inboxes | Powered by JetHome®