Skip to contentSkip to conversation

phy: hix5hd2-sata: Convert to use devm_ioremap_resource

PATCH In review Axel Lin 2 participants 2 messages Mar 2, 2015 Generic PHY framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 phy: hix5hd2-sata: Convert to use devm_ioremap_resource

devm_ioremap_resource() also has sanity check for the res argument which is missed in current code.

---
 drivers/phy/phy-hix5hd2-sata.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/phy/phy-hix5hd2-sata.c +3 -3
index 34915b4..798adcf 100644
@@ -147,9 +147,9 @@ static int hix5hd2_sata_phy_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->base = devm_ioremap(dev, res->start, resource_size(res));
-	if (!priv->base)
-		return -ENOMEM;
+	priv->base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(priv->base))
+		return PTR_ERR(priv->base);
 
 	priv->peri_ctrl = syscon_regmap_lookup_by_phandle(dev->of_node,
 					"hisilicon,peripheral-syscon");
Signature · 1 line
1.9.1
#1 lore raw
Quoted 2 lines · Axel Lin

devm_ioremap_resource() also has sanity check for the res argument which is missed in current code.

I remember we can not use devm_ioremap_resource here, because the memory region is shared with sata controller. And devm_request_mem_region would fail.
So we directly use devm_ioremap here.

Quoted 24 lines
---
  drivers/phy/phy-hix5hd2-sata.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/phy/phy-hix5hd2-sata.c +3 -3
index 34915b4..798adcf 100644
@@ -147,9 +147,9 @@ static int hix5hd2_sata_phy_probe(struct platform_device *pdev)
  		return -ENOMEM;
 
  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->base = devm_ioremap(dev, res->start, resource_size(res));
-	if (!priv->base)
-		return -ENOMEM;
+	priv->base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(priv->base))
+		return PTR_ERR(priv->base);
 
  	priv->peri_ctrl = syscon_regmap_lookup_by_phandle(dev->of_node,
  					"hisilicon,peripheral-syscon");