]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
phy: marvell: mmp3-hsic: Avoid re-casting __iomem
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Mon, 16 Feb 2026 11:04:15 +0000 (12:04 +0100)
committerVinod Koul <vkoul@kernel.org>
Fri, 27 Feb 2026 14:33:38 +0000 (20:03 +0530)
__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>
drivers/phy/marvell/phy-mmp3-hsic.c

index 271f1a2258efb007252afb9e222afe01454b80ba..72ab6da0ebc3ddaed1cd340ba7e77e754662f984 100644 (file)
 #define HSIC_ENABLE    BIT(7)
 #define PLL_BYPASS     BIT(4)
 
+struct mmp3_hsic_data {
+       void __iomem *base;
+};
+
 static int mmp3_hsic_phy_init(struct phy *phy)
 {
-       void __iomem *base = (void __iomem *)phy_get_drvdata(phy);
+       struct mmp3_hsic_data *mmp3 = phy_get_drvdata(phy);
        u32 hsic_ctrl;
 
-       hsic_ctrl = readl_relaxed(base + HSIC_CTRL);
+       hsic_ctrl = readl_relaxed(mmp3->base + HSIC_CTRL);
        hsic_ctrl |= HSIC_ENABLE;
        hsic_ctrl |= PLL_BYPASS;
-       writel_relaxed(hsic_ctrl, base + HSIC_CTRL);
+       writel_relaxed(hsic_ctrl, mmp3->base + HSIC_CTRL);
 
        return 0;
 }
@@ -41,13 +45,17 @@ MODULE_DEVICE_TABLE(of, mmp3_hsic_phy_of_match);
 static int mmp3_hsic_phy_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
+       struct mmp3_hsic_data *mmp3;
        struct phy_provider *provider;
-       void __iomem *base;
        struct phy *phy;
 
-       base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
-       if (IS_ERR(base))
-               return PTR_ERR(base);
+       mmp3 = devm_kzalloc(dev, sizeof(*mmp3), GFP_KERNEL);
+       if (!mmp3)
+               return -ENOMEM;
+
+       mmp3->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
+       if (IS_ERR(mmp3->base))
+               return PTR_ERR(mmp3->base);
 
        phy = devm_phy_create(dev, NULL, &mmp3_hsic_phy_ops);
        if (IS_ERR(phy)) {
@@ -55,7 +63,7 @@ static int mmp3_hsic_phy_probe(struct platform_device *pdev)
                return PTR_ERR(phy);
        }
 
-       phy_set_drvdata(phy, (void *)base);
+       phy_set_drvdata(phy, mmp3);
        provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
        if (IS_ERR(provider)) {
                dev_err(dev, "failed to register PHY provider\n");