staging: vt6656: Use BIT_ULL() macro instead of bit shift operation
PATCH 1/1 staging: vt6656: Use BIT_ULL() macro instead of bit shift operation
Replace the bit left shift operation with the BIT_ULL() macro and remove the unnecessary "and" operation against the bit_nr variable.
--- drivers/staging/vt6656/main_usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vt6656/main_usb.c +2 -2
@@ -21,6 +21,7 @@*/ #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); } priv->mc_list_count = mc_list->count;
--
2.20.1
Greg Kroah-Hartman
maintainerQuoted 21 lines · Oscar Carter
Replace the bit left shift operation with the
BIT_ULL()macro and remove the unnecessary "and" operation against thebit_nrvariable.Signed-off-by Oscar Carter <[email protected]>--- drivers/staging/vt6656/main_usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/vt6656/main_usb.c +1
-0@@ -21,6 +21,7 @@*/ #undef __NO_VERSION__ +#include <linux/bits.h> #include <linux/etherdevice.h> #include <linux/file.h> #include "device.h"
drivers/staging/vt6656/main_usb.c static u64 vnt_prepare_multicast(struct ieee80211_hw *hw, · line 806
Quoted 6 lines
drivers/staging/vt6656/main_usb.c +1
-2@@ -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?
thanks,
greg k-h
Quoted 23 lines · Greg Kroah-Hartman
Quoted 22 lines · Oscar Carter
Replace the bit left shift operation with the
BIT_ULL()macro and remove the unnecessary "and" operation against thebit_nrvariable.Signed-off-by Oscar Carter <[email protected]>--- drivers/staging/vt6656/main_usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/vt6656/main_usb.c +1
-0@@ -21,6 +21,7 @@*/ #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,
Quoted 8 lines
drivers/staging/vt6656/main_usb.c static u64 vnt_prepare_multicast(struct ieee80211_hw *hw, · line 806
Quoted 5 lines
drivers/staging/vt6656/main_usb.c +1
-2netdev_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_nranymore, 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.
Quoted 4 lines
thanks,
greg k-h
thanks,
Oscar
Quoted 26 lines
Quoted 9 lines
Quoted 9 lines
*/
#undef__NO_VERSION__drivers/staging/vt6656/main_usb.c +1
-0+#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,Quoted 8 lines
drivers/staging/vt6656/main_usb.c static u64 vnt_prepare_multicast(struct ieee80211_hw *hw, · line 806
Quoted 5 lines
drivers/staging/vt6656/main_usb.c +1
-2netdev_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_nranymore, why not?My reasons are exposed below:
The
ether_crcfunction 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 theether_crcfunction are positioned in bit 5 to bit 0 of the variablebit_nr. Due to the right shift happens over an unsigned type, the 26 new bits added on the left side will be 0.
Quoted 8 lines
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 theether_crcfunction. So, only the 6 lsb bits of the variablebit_nrare 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
Greg Kroah-Hartman
maintainerQuoted 35 lines · Malcolm Priestley
Quoted 26 lines
Quoted 9 lines
Quoted 9 lines
*/
#undef__NO_VERSION__drivers/staging/vt6656/main_usb.c +1
-0+#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,Quoted 8 lines
drivers/staging/vt6656/main_usb.c static u64 vnt_prepare_multicast(struct ieee80211_hw *hw, · line 806
Quoted 5 lines
drivers/staging/vt6656/main_usb.c +1
-2netdev_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_nranymore, why not?My reasons are exposed below:
The
ether_crcfunction 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 theether_crcfunction are positioned in bit 5 to bit 0 of the variablebit_nr. Due to the right shift happens over an unsigned type, the 26 new bits added on the left side will be 0.Quoted 8 lines
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 theether_crcfunction. So, only the 6 lsb bits of the variablebit_nrare 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.
Quoted 6 lines
The mask is only there out of legacy originally it was 31(0x1f) and the
bit_nrspread across twomc_filteru32 arrays.The mask is not needed now it is u64.
The patch is fine.
Ok, then the changelog needs to be fixed up to explain all of this and resent.
thanks,
greg k-h
Quoted 39 lines · Greg Kroah-Hartman
Quoted 38 lines · Malcolm Priestley
Quoted 26 lines
Quoted 9 lines
Quoted 9 lines
*/
#undef__NO_VERSION__drivers/staging/vt6656/main_usb.c +1
-0+#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,Quoted 8 lines
drivers/staging/vt6656/main_usb.c static u64 vnt_prepare_multicast(struct ieee80211_hw *hw, · line 806
Quoted 5 lines
drivers/staging/vt6656/main_usb.c +1
-2netdev_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_nranymore, why not?My reasons are exposed below:
The
ether_crcfunction 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 theether_crcfunction are positioned in bit 5 to bit 0 of the variablebit_nr. Due to the right shift happens over an unsigned type, the 26 new bits added on the left side will be 0.Quoted 8 lines
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 theether_crcfunction. So, only the 6 lsb bits of the variablebit_nrare 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_nrspread across twomc_filteru32 arrays.
Quoted 6 lines
Quoted 3 lines
The mask is not needed now it is u64.
The patch is fine.
Ok, then the changelog needs to be fixed up to explain all of this and resent.
Ok, I will create a new version patch with all of this information and I will resend it.
Quoted 4 lines
thanks,
greg k-h
thanks,
Oscar