From: Krzysztof Kozlowski krzysztof.kozlowski@oss.qualcomm.com
[ Upstream commit 57d508b5f718730f74b11e0dc9609ac7976802d1 ]
'version' is an enum, thus cast of pointer on 64-bit compile test with clang W=1 causes:
rockchip_pdm.c:583:17: error: cast to smaller integer type 'enum rk_pdm_version' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
This was already fixed in commit 49a4a8d12612 ("ASoC: rockchip: Fix Wvoid-pointer-to-enum-cast warning") but then got bad in commit 9958d85968ed ("ASoC: Use device_get_match_data()").
Discussion on LKML also pointed out that 'uintptr_t' is not the correct type and either 'kernel_ulong_t' or 'unsigned long' should be used, with several arguments towards the latter [1].
Link: https://lore.kernel.org/r/CAMuHMdX7t=mabqFE5O-Cii3REMuyaePHmqX+j_mqyrn6XXzso... [1] Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@oss.qualcomm.com Link: https://patch.msgid.link/20251203141644.106459-2-krzysztof.kozlowski@oss.qua... Signed-off-by: Mark Brown broonie@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
## Summary Analysis
### What the commit fixes This is a **build fix** that prevents a compilation error when building with clang and W=1: ``` error: cast to smaller integer type 'enum rk_pdm_version' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast] ```
The issue is that on 64-bit systems, casting directly from `const void *` (64 bits) to an enum (typically 32 bits) triggers a truncation warning. Using `(unsigned long)` as an intermediate cast avoids this because `unsigned long` matches the pointer size.
### Classification This falls clearly into the **BUILD FIX** exception category which is explicitly allowed for stable trees. Build fixes that prevent compilation are critical for users who need to build the kernel.
### Scope and Risk - **Change**: Single line - only changing the cast type - **Files touched**: 1 file - **Risk**: Extremely low - the runtime behavior is identical; only the compile-time representation differs - **Functional equivalence**: The value stored in `pdm->version` is the same either way
### Applicability to Stable Trees The regressing commit 9958d85968ed went into v6.7-rc1. Therefore: - Stable trees **v6.6.y and earlier**: NOT affected (don't have the regression) - Stable trees **v6.7.y and later**: Affected and would benefit from this fix
### Stable Criteria Assessment | Criterion | Assessment | |-----------|------------| | Obviously correct | ✓ Yes - standard pattern for void pointer to enum cast | | Fixes real bug | ✓ Yes - compilation failure | | Small scope | ✓ Yes - 1 line change | | No new features | ✓ Correct - pure bug fix | | Tested | ✓ Accepted by maintainer |
### Additional Factors - This is a **regression fix** - the same issue was previously fixed in commit 49a4a8d12612 but regressed - LKML discussion confirms `unsigned long` as the appropriate fix - Signed off by both author and subsystem maintainer (Mark Brown)
### Risk vs Benefit - **Risk**: Near zero - compile-time only change, no runtime behavior modification - **Benefit**: Enables compilation with clang W=1 on 64-bit platforms
This is an excellent stable backport candidate. It's a minimal, low-risk build fix that allows users to compile the kernel in a common configuration. Build fixes are explicitly mentioned as appropriate for stable trees, and this one is as safe as they come - a single-line cast change with no runtime impact.
**YES**
sound/soc/rockchip/rockchip_pdm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/rockchip/rockchip_pdm.c b/sound/soc/rockchip/rockchip_pdm.c index c1ee470ec6079..c69cdd6f24994 100644 --- a/sound/soc/rockchip/rockchip_pdm.c +++ b/sound/soc/rockchip/rockchip_pdm.c @@ -580,7 +580,7 @@ static int rockchip_pdm_probe(struct platform_device *pdev) if (!pdm) return -ENOMEM;
- pdm->version = (enum rk_pdm_version)device_get_match_data(&pdev->dev); + pdm->version = (unsigned long)device_get_match_data(&pdev->dev); if (pdm->version == RK_PDM_RK3308) { pdm->reset = devm_reset_control_get(&pdev->dev, "pdm-m"); if (IS_ERR(pdm->reset))