mbox series

[net-next,v1,0/2] ethtool: use bits.h defines

Message ID 20221207231728.2331166-1-jesse.brandeburg@intel.com (mailing list archive)
Headers show
Series ethtool: use bits.h defines | expand

Message

Jesse Brandeburg Dec. 7, 2022, 11:17 p.m. UTC
Change the ethtool files in the kernel, including uapi header files, to
use the kernel style BIT() and BIT_ULL() functions instead of
open-coding bit shift operations.

Making this change results in a more consistent presentation of bit-
shift operations as well as reduces the further likelihood of mistaken
(1 << 31) usage which omits the 1UL that is necessary to get an unsigned
result of the shift.

Jesse Brandeburg (2):
  ethtool/uapi: use BIT for bit-shifts
  ethtool: refactor bit-shifts

 include/linux/ethtool.h              |   2 +-
 include/uapi/linux/ethtool.h         | 112 ++++++++++++++++-----------
 include/uapi/linux/ethtool_netlink.h |   6 +-
 net/ethtool/bitset.c                 |  14 ++--
 net/ethtool/ioctl.c                  |   4 +-
 net/ethtool/strset.c                 |   6 +-
 6 files changed, 84 insertions(+), 60 deletions(-)


base-commit: 01d0e110f2365151d8e69ca4978128112637642d

Comments

Jakub Kicinski Dec. 8, 2022, 2:40 a.m. UTC | #1
On Wed,  7 Dec 2022 15:17:26 -0800 Jesse Brandeburg wrote:
> Change the ethtool files in the kernel, including uapi header files, to
> use the kernel style BIT() and BIT_ULL() functions instead of
> open-coding bit shift operations.
> 
> Making this change results in a more consistent presentation of bit-
> shift operations as well as reduces the further likelihood of mistaken
> (1 << 31) usage which omits the 1UL that is necessary to get an unsigned
> result of the shift.

Let's hear some opinions but the BIT / GENMASK macros are not
universally loved so conversion == cleanup may not obvious.
Jesse Brandeburg Dec. 9, 2022, 10:18 p.m. UTC | #2
On 12/7/2022 6:40 PM, Jakub Kicinski wrote:
> On Wed,  7 Dec 2022 15:17:26 -0800 Jesse Brandeburg wrote:
>> Change the ethtool files in the kernel, including uapi header files, to
>> use the kernel style BIT() and BIT_ULL() functions instead of
>> open-coding bit shift operations.
>>
>> Making this change results in a more consistent presentation of bit-
>> shift operations as well as reduces the further likelihood of mistaken
>> (1 << 31) usage which omits the 1UL that is necessary to get an unsigned
>> result of the shift.
> 
> Let's hear some opinions but the BIT / GENMASK macros are not
> universally loved so conversion == cleanup may not obvious.

Fair enough, I'm open to feedback but haven't seen any so far.

I'm planning to wait past the merge window now and submit the next 
version of this series in a couple of weeks.