Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

phy: marvell: mmp3-hsic: Avoid re-casting __iomem

__iomem annotated memory must be accessed via dedicated accessors, even
if actual code is correct (accessing the driver data in
mmp3_hsic_phy_init() brings back the __iomem cast), but dropping its
cast (with or without __force) when storing as driver data seems like
less readable code for any future changes. Instead, add a dedicated
wrapping structure just to hold the pointer without changing the __iomem
cast. This makes the code explicit, obvious and solves the sparse
warning:

phy-mmp3-hsic.c:58:31: warning: cast removes address space '__iomem' of expression

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260216110413.159994-5-krzysztof.kozlowski@oss.qualcomm.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Vinod Koul
c77eee5b b3fddddf

+16 -8
+16 -8
drivers/phy/marvell/phy-mmp3-hsic.c
··· 14 14 #define HSIC_ENABLE BIT(7) 15 15 #define PLL_BYPASS BIT(4) 16 16 17 + struct mmp3_hsic_data { 18 + void __iomem *base; 19 + }; 20 + 17 21 static int mmp3_hsic_phy_init(struct phy *phy) 18 22 { 19 - void __iomem *base = (void __iomem *)phy_get_drvdata(phy); 23 + struct mmp3_hsic_data *mmp3 = phy_get_drvdata(phy); 20 24 u32 hsic_ctrl; 21 25 22 - hsic_ctrl = readl_relaxed(base + HSIC_CTRL); 26 + hsic_ctrl = readl_relaxed(mmp3->base + HSIC_CTRL); 23 27 hsic_ctrl |= HSIC_ENABLE; 24 28 hsic_ctrl |= PLL_BYPASS; 25 - writel_relaxed(hsic_ctrl, base + HSIC_CTRL); 29 + writel_relaxed(hsic_ctrl, mmp3->base + HSIC_CTRL); 26 30 27 31 return 0; 28 32 } ··· 45 41 static int mmp3_hsic_phy_probe(struct platform_device *pdev) 46 42 { 47 43 struct device *dev = &pdev->dev; 44 + struct mmp3_hsic_data *mmp3; 48 45 struct phy_provider *provider; 49 - void __iomem *base; 50 46 struct phy *phy; 51 47 52 - base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); 53 - if (IS_ERR(base)) 54 - return PTR_ERR(base); 48 + mmp3 = devm_kzalloc(dev, sizeof(*mmp3), GFP_KERNEL); 49 + if (!mmp3) 50 + return -ENOMEM; 51 + 52 + mmp3->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); 53 + if (IS_ERR(mmp3->base)) 54 + return PTR_ERR(mmp3->base); 55 55 56 56 phy = devm_phy_create(dev, NULL, &mmp3_hsic_phy_ops); 57 57 if (IS_ERR(phy)) { ··· 63 55 return PTR_ERR(phy); 64 56 } 65 57 66 - phy_set_drvdata(phy, (void *)base); 58 + phy_set_drvdata(phy, mmp3); 67 59 provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 68 60 if (IS_ERR(provider)) { 69 61 dev_err(dev, "failed to register PHY provider\n");