Re: [PATCH v4 2/3] net: ethernet: renesas: Add Ethernet Switch driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 24, 2022, at 17:27, Geert Uytterhoeven wrote:
> On Wed, Oct 19, 2022 at 1:17 PM kernel test robot <lkp@xxxxxxxxx> wrote:

>>    drivers/net/ethernet/renesas/rswitch.c: In function 'rswitch_ext_desc_get_dptr':
>> >> drivers/net/ethernet/renesas/rswitch.c:355:71: warning: left shift count >= width of type [-Wshift-count-overflow]
>>      355 |         return __le32_to_cpu(desc->dptrl) | (dma_addr_t)(desc->dptrh) << 32;
>>          |                                                                       ^~
>>    drivers/net/ethernet/renesas/rswitch.c: In function 'rswitch_ext_ts_desc_get_dptr':
>>    drivers/net/ethernet/renesas/rswitch.c:367:71: warning: left shift count >= width of type [-Wshift-count-overflow]
>>      367 |         return __le32_to_cpu(desc->dptrl) | (dma_addr_t)(desc->dptrh) << 32;
>>          |                                                                       ^~
>>
>>
>> vim +355 drivers/net/ethernet/renesas/rswitch.c
>>
>>    352
>>    353  static dma_addr_t rswitch_ext_desc_get_dptr(struct rswitch_ext_desc *desc)
>>    354  {
>>  > 355          return __le32_to_cpu(desc->dptrl) | (dma_addr_t)(desc->dptrh) << 32;
>
> A simple fix would be to replace the cast to "dma_addr_t" by a cast to "u64".
> A more convoluted fix would be:
>
>     dma_addr_t dma;
>
>     dma = __le32_to_cpu(desc->dptrl);
>     if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
>             dma |= (u64)desc->dptrh << 32;
>     return dma;
>
> Looking at the gcc compiler output, the both cases are optimized to the
> exact same code, for both arm32 and arm64, so I'd go for the simple fix.
>
> BTW, if struct rswitch_ext_desc would just extend struct rswitch_desc,
> you could use rswitch_ext_desc_get_dptr() for both.
>

Regardless of which way this is expressed, it looked like there is
a missing __le32_to_cpu() around the high word.

     Arnd



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux