linux/drivers/phy/st
Arnd Bergmann 2de679ecd7 phy: stm32: work around constant-value overflow assertion
FIELD_PREP() checks that a constant fits into the available bitfield,
but if one of the two lookup tables in stm32_impedance_tune() does
not find a matching entry, the index is out of range, which gcc
correctly complains about:

In file included from <command-line>:
In function 'stm32_impedance_tune',
    inlined from 'stm32_combophy_pll_init' at drivers/phy/st/phy-stm32-combophy.c:247:9:
include/linux/compiler_types.h:517:38: error: call to '__compiletime_assert_447' declared with attribute error: FIELD_PREP: value too large for the field
  517 |  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
      |                                      ^
include/linux/bitfield.h:68:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
   68 |   BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?  \
  115 |   __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
      |   ^~~~~~~~~~~~~~~~
drivers/phy/st/phy-stm32-combophy.c:162:8: note: in expansion of macro 'FIELD_PREP'
  162 |        FIELD_PREP(STM32MP25_PCIEPRG_IMPCTRL_VSWING, vswing_of));
      |        ^~~~~~~~~~

Rework this so the field value gets set inside of the loop and otherwise
set to zero.

Fixes: 47e1bb6b4b ("phy: stm32: Add support for STM32MP25 COMBOPHY.")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20241111103712.3520611-1-arnd@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2024-12-04 20:04:22 +05:30
..
Kconfig phy: stm32: Add support for STM32MP25 COMBOPHY. 2024-10-07 12:17:07 +05:30
Makefile phy: stm32: Add support for STM32MP25 COMBOPHY. 2024-10-07 12:17:07 +05:30
phy-miphy28lp.c phy: miphy28lp: remove unused struct 'miphy_initval' 2024-06-03 19:29:44 +05:30
phy-spear1310-miphy.c phy: constify of_phandle_args in xlate 2024-02-23 17:43:14 +05:30
phy-spear1340-miphy.c phy: constify of_phandle_args in xlate 2024-02-23 17:43:14 +05:30
phy-stih407-usb.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
phy-stm32-combophy.c phy: stm32: work around constant-value overflow assertion 2024-12-04 20:04:22 +05:30
phy-stm32-usbphyc.c phy: Switch back to struct platform_driver::remove() 2024-10-17 20:33:03 +05:30