Skip to content

Commit c77eee5

Browse files
krzkvinodkoul
authored andcommitted
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>
1 parent b3fdddd commit c77eee5

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

drivers/phy/marvell/phy-mmp3-hsic.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@
1414
#define HSIC_ENABLE BIT(7)
1515
#define PLL_BYPASS BIT(4)
1616

17+
struct mmp3_hsic_data {
18+
void __iomem *base;
19+
};
20+
1721
static int mmp3_hsic_phy_init(struct phy *phy)
1822
{
19-
void __iomem *base = (void __iomem *)phy_get_drvdata(phy);
23+
struct mmp3_hsic_data *mmp3 = phy_get_drvdata(phy);
2024
u32 hsic_ctrl;
2125

22-
hsic_ctrl = readl_relaxed(base + HSIC_CTRL);
26+
hsic_ctrl = readl_relaxed(mmp3->base + HSIC_CTRL);
2327
hsic_ctrl |= HSIC_ENABLE;
2428
hsic_ctrl |= PLL_BYPASS;
25-
writel_relaxed(hsic_ctrl, base + HSIC_CTRL);
29+
writel_relaxed(hsic_ctrl, mmp3->base + HSIC_CTRL);
2630

2731
return 0;
2832
}
@@ -41,21 +45,25 @@ MODULE_DEVICE_TABLE(of, mmp3_hsic_phy_of_match);
4145
static int mmp3_hsic_phy_probe(struct platform_device *pdev)
4246
{
4347
struct device *dev = &pdev->dev;
48+
struct mmp3_hsic_data *mmp3;
4449
struct phy_provider *provider;
45-
void __iomem *base;
4650
struct phy *phy;
4751

48-
base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
49-
if (IS_ERR(base))
50-
return PTR_ERR(base);
52+
mmp3 = devm_kzalloc(dev, sizeof(*mmp3), GFP_KERNEL);
53+
if (!mmp3)
54+
return -ENOMEM;
55+
56+
mmp3->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
57+
if (IS_ERR(mmp3->base))
58+
return PTR_ERR(mmp3->base);
5159

5260
phy = devm_phy_create(dev, NULL, &mmp3_hsic_phy_ops);
5361
if (IS_ERR(phy)) {
5462
dev_err(dev, "failed to create PHY\n");
5563
return PTR_ERR(phy);
5664
}
5765

58-
phy_set_drvdata(phy, (void *)base);
66+
phy_set_drvdata(phy, mmp3);
5967
provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
6068
if (IS_ERR(provider)) {
6169
dev_err(dev, "failed to register PHY provider\n");

0 commit comments

Comments
 (0)