linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/1] phy: intel: Fix compilation error on FIELD_PREP usage
@ 2020-05-27 10:56 Dilip Kota
  2020-05-27 16:18 ` Randy Dunlap
  2020-06-24 12:10 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Dilip Kota @ 2020-05-27 10:56 UTC (permalink / raw)
  To: linux-kernel, kishon, vkoul, rdunlap
  Cc: andriy.shevchenko, cheol.yong.kim, qi-ming.wu, Dilip Kota

FIELD_PREP expects constant arguments. Istead of doing FIELD_PREP
operation on the arguments of combo_phy_w32_off_mask(), pass the
final FIELD_PREP value as an argument.

Error reported as:
In file included from include/linux/build_bug.h:5,
from include/linux/bitfield.h:10,
from drivers/phy/intel/phy-intel-combo.c:8:
drivers/phy/intel/phy-intel-combo.c: In function 'combo_phy_w32_off_mask':
include/linux/bitfield.h:52:28: warning: comparison is always false due to limited range of data type [-Wtype-limits]

include/linux/compiler.h:350:38: error: call to '__compiletime_assert_37' declared with attribute error: FIELD_PREP: mask is not constant
94 |   __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: ");          |   ^~~~~~~~~~~~~~~~
drivers/phy/intel/phy-intel-combo.c:137:13: note: in expansion of macro 'FIELD_PREP'
137 |  reg_val |= FIELD_PREP(mask, val);
|             ^~~~~~~~~~

../include/linux/compiler.h:392:38: error: call to__compiletime_assert_137
 declared with attribute error:
BUILD_BUG_ON failed: (((mask) + (1ULL << (__builtin_ffsll(mask) - 1))) & (((mask) + (1ULL << (__builtin_ffsll(mask) - 1))) - 1)) != 0
  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)

../include/linux/bitfield.h:94:3: note: in expansion of macro __BF_FIELD_CHECK
   __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
   ^~~~~~~~~~~~~~~~
../drivers/phy/intel/phy-intel-combo.c:137:13: note: in expansion of macro FIELD_PREP
  reg_val |= FIELD_PREP(mask, val);
             ^~~~~~~~~~

Fixes: ac0a95a3ea78 ("phy: intel: Add driver support for ComboPhy")
Signed-off-by: Dilip Kota <eswara.kota@linux.intel.com>
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Randy Dunlap <rdunlap@infradead.org>
---
 drivers/phy/intel/phy-intel-combo.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/phy/intel/phy-intel-combo.c b/drivers/phy/intel/phy-intel-combo.c
index c2a35be4cdfb..254ea7cba7ca 100644
--- a/drivers/phy/intel/phy-intel-combo.c
+++ b/drivers/phy/intel/phy-intel-combo.c
@@ -134,7 +134,7 @@ static inline void combo_phy_w32_off_mask(void __iomem *base, unsigned int reg,
 
 	reg_val = readl(base + reg);
 	reg_val &= ~mask;
-	reg_val |= FIELD_PREP(mask, val);
+	reg_val |= val;
 	writel(reg_val, base + reg);
 }
 
@@ -169,7 +169,7 @@ static int intel_cbphy_pcie_en_pad_refclk(struct intel_cbphy_iphy *iphy)
 		return 0;
 
 	combo_phy_w32_off_mask(cbphy->app_base, PCIE_PHY_GEN_CTRL,
-			       PCIE_PHY_CLK_PAD, 0);
+			       PCIE_PHY_CLK_PAD, FIELD_PREP(PCIE_PHY_CLK_PAD, 0));
 
 	/* Delay for stable clock PLL */
 	usleep_range(50, 100);
@@ -192,7 +192,7 @@ static int intel_cbphy_pcie_dis_pad_refclk(struct intel_cbphy_iphy *iphy)
 		return 0;
 
 	combo_phy_w32_off_mask(cbphy->app_base, PCIE_PHY_GEN_CTRL,
-			       PCIE_PHY_CLK_PAD, 1);
+			       PCIE_PHY_CLK_PAD, FIELD_PREP(PCIE_PHY_CLK_PAD, 1));
 
 	return 0;
 }
@@ -385,7 +385,7 @@ static int intel_cbphy_calibrate(struct phy *phy)
 
 	/* trigger auto RX adaptation */
 	combo_phy_w32_off_mask(cr_base, CR_ADDR(PCS_XF_ATE_OVRD_IN_2, id),
-			       ADAPT_REQ_MSK, 3);
+			       ADAPT_REQ_MSK, FIELD_PREP(ADAPT_REQ_MSK, 3));
 	/* Wait RX adaptation to finish */
 	ret = readl_poll_timeout(cr_base + CR_ADDR(PCS_XF_RX_ADAPT_ACK, id),
 				 val, val & RX_ADAPT_ACK_BIT, 10, 5000);
@@ -396,7 +396,7 @@ static int intel_cbphy_calibrate(struct phy *phy)
 
 	/* Stop RX adaptation */
 	combo_phy_w32_off_mask(cr_base, CR_ADDR(PCS_XF_ATE_OVRD_IN_2, id),
-			       ADAPT_REQ_MSK, 0);
+			       ADAPT_REQ_MSK, FIELD_PREP(ADAPT_REQ_MSK, 0));
 
 	return ret;
 }
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/1] phy: intel: Fix compilation error on FIELD_PREP usage
  2020-05-27 10:56 [PATCH v2 1/1] phy: intel: Fix compilation error on FIELD_PREP usage Dilip Kota
@ 2020-05-27 16:18 ` Randy Dunlap
  2020-06-24 12:10 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2020-05-27 16:18 UTC (permalink / raw)
  To: Dilip Kota, linux-kernel, kishon, vkoul
  Cc: andriy.shevchenko, cheol.yong.kim, qi-ming.wu

On 5/27/20 3:56 AM, Dilip Kota wrote:
> FIELD_PREP expects constant arguments. Istead of doing FIELD_PREP
> operation on the arguments of combo_phy_w32_off_mask(), pass the
> final FIELD_PREP value as an argument.
> 
> Error reported as:
> In file included from include/linux/build_bug.h:5,
> from include/linux/bitfield.h:10,
> from drivers/phy/intel/phy-intel-combo.c:8:
> drivers/phy/intel/phy-intel-combo.c: In function 'combo_phy_w32_off_mask':
> include/linux/bitfield.h:52:28: warning: comparison is always false due to limited range of data type [-Wtype-limits]
> 
> include/linux/compiler.h:350:38: error: call to '__compiletime_assert_37' declared with attribute error: FIELD_PREP: mask is not constant
> 94 |   __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: ");          |   ^~~~~~~~~~~~~~~~
> drivers/phy/intel/phy-intel-combo.c:137:13: note: in expansion of macro 'FIELD_PREP'
> 137 |  reg_val |= FIELD_PREP(mask, val);
> |             ^~~~~~~~~~
> 
> ../include/linux/compiler.h:392:38: error: call to__compiletime_assert_137
>  declared with attribute error:
> BUILD_BUG_ON failed: (((mask) + (1ULL << (__builtin_ffsll(mask) - 1))) & (((mask) + (1ULL << (__builtin_ffsll(mask) - 1))) - 1)) != 0
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
> 
> ../include/linux/bitfield.h:94:3: note: in expansion of macro __BF_FIELD_CHECK
>    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>    ^~~~~~~~~~~~~~~~
> ../drivers/phy/intel/phy-intel-combo.c:137:13: note: in expansion of macro FIELD_PREP
>   reg_val |= FIELD_PREP(mask, val);
>              ^~~~~~~~~~
> 
> Fixes: ac0a95a3ea78 ("phy: intel: Add driver support for ComboPhy")
> Signed-off-by: Dilip Kota <eswara.kota@linux.intel.com>
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>

Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested

Thanks.

> ---
>  drivers/phy/intel/phy-intel-combo.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/phy/intel/phy-intel-combo.c b/drivers/phy/intel/phy-intel-combo.c
> index c2a35be4cdfb..254ea7cba7ca 100644
> --- a/drivers/phy/intel/phy-intel-combo.c
> +++ b/drivers/phy/intel/phy-intel-combo.c
> @@ -134,7 +134,7 @@ static inline void combo_phy_w32_off_mask(void __iomem *base, unsigned int reg,
>  
>  	reg_val = readl(base + reg);
>  	reg_val &= ~mask;
> -	reg_val |= FIELD_PREP(mask, val);
> +	reg_val |= val;
>  	writel(reg_val, base + reg);
>  }
>  
> @@ -169,7 +169,7 @@ static int intel_cbphy_pcie_en_pad_refclk(struct intel_cbphy_iphy *iphy)
>  		return 0;
>  
>  	combo_phy_w32_off_mask(cbphy->app_base, PCIE_PHY_GEN_CTRL,
> -			       PCIE_PHY_CLK_PAD, 0);
> +			       PCIE_PHY_CLK_PAD, FIELD_PREP(PCIE_PHY_CLK_PAD, 0));
>  
>  	/* Delay for stable clock PLL */
>  	usleep_range(50, 100);
> @@ -192,7 +192,7 @@ static int intel_cbphy_pcie_dis_pad_refclk(struct intel_cbphy_iphy *iphy)
>  		return 0;
>  
>  	combo_phy_w32_off_mask(cbphy->app_base, PCIE_PHY_GEN_CTRL,
> -			       PCIE_PHY_CLK_PAD, 1);
> +			       PCIE_PHY_CLK_PAD, FIELD_PREP(PCIE_PHY_CLK_PAD, 1));
>  
>  	return 0;
>  }
> @@ -385,7 +385,7 @@ static int intel_cbphy_calibrate(struct phy *phy)
>  
>  	/* trigger auto RX adaptation */
>  	combo_phy_w32_off_mask(cr_base, CR_ADDR(PCS_XF_ATE_OVRD_IN_2, id),
> -			       ADAPT_REQ_MSK, 3);
> +			       ADAPT_REQ_MSK, FIELD_PREP(ADAPT_REQ_MSK, 3));
>  	/* Wait RX adaptation to finish */
>  	ret = readl_poll_timeout(cr_base + CR_ADDR(PCS_XF_RX_ADAPT_ACK, id),
>  				 val, val & RX_ADAPT_ACK_BIT, 10, 5000);
> @@ -396,7 +396,7 @@ static int intel_cbphy_calibrate(struct phy *phy)
>  
>  	/* Stop RX adaptation */
>  	combo_phy_w32_off_mask(cr_base, CR_ADDR(PCS_XF_ATE_OVRD_IN_2, id),
> -			       ADAPT_REQ_MSK, 0);
> +			       ADAPT_REQ_MSK, FIELD_PREP(ADAPT_REQ_MSK, 0));
>  
>  	return ret;
>  }
> 


-- 
~Randy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/1] phy: intel: Fix compilation error on FIELD_PREP usage
  2020-05-27 10:56 [PATCH v2 1/1] phy: intel: Fix compilation error on FIELD_PREP usage Dilip Kota
  2020-05-27 16:18 ` Randy Dunlap
@ 2020-06-24 12:10 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2020-06-24 12:10 UTC (permalink / raw)
  To: Dilip Kota
  Cc: linux-kernel, kishon, rdunlap, andriy.shevchenko, cheol.yong.kim,
	qi-ming.wu

On 27-05-20, 18:56, Dilip Kota wrote:
> FIELD_PREP expects constant arguments. Istead of doing FIELD_PREP
> operation on the arguments of combo_phy_w32_off_mask(), pass the
> final FIELD_PREP value as an argument.
> 
> Error reported as:
> In file included from include/linux/build_bug.h:5,
> from include/linux/bitfield.h:10,
> from drivers/phy/intel/phy-intel-combo.c:8:
> drivers/phy/intel/phy-intel-combo.c: In function 'combo_phy_w32_off_mask':
> include/linux/bitfield.h:52:28: warning: comparison is always false due to limited range of data type [-Wtype-limits]
> 
> include/linux/compiler.h:350:38: error: call to '__compiletime_assert_37' declared with attribute error: FIELD_PREP: mask is not constant
> 94 |   __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: ");          |   ^~~~~~~~~~~~~~~~
> drivers/phy/intel/phy-intel-combo.c:137:13: note: in expansion of macro 'FIELD_PREP'
> 137 |  reg_val |= FIELD_PREP(mask, val);
> |             ^~~~~~~~~~
> 
> ../include/linux/compiler.h:392:38: error: call to__compiletime_assert_137
>  declared with attribute error:
> BUILD_BUG_ON failed: (((mask) + (1ULL << (__builtin_ffsll(mask) - 1))) & (((mask) + (1ULL << (__builtin_ffsll(mask) - 1))) - 1)) != 0
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
> 
> ../include/linux/bitfield.h:94:3: note: in expansion of macro __BF_FIELD_CHECK
>    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>    ^~~~~~~~~~~~~~~~
> ../drivers/phy/intel/phy-intel-combo.c:137:13: note: in expansion of macro FIELD_PREP
>   reg_val |= FIELD_PREP(mask, val);

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-24 12:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 10:56 [PATCH v2 1/1] phy: intel: Fix compilation error on FIELD_PREP usage Dilip Kota
2020-05-27 16:18 ` Randy Dunlap
2020-06-24 12:10 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).