Skip to contentSkip to conversation

phy: miphy28lp: Convert to devm_kcalloc and fix wrong sizof

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

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 phy: miphy28lp: Convert to devm_kcalloc and fix wrong sizof

Prefer devm_kcalloc over devm_kzalloc with multiply. In additional, use sizeof(phy) is incorrect, fix it.

---
This patch is on top of below patch:
[PATCH 1/2] phy: miphy28lp: Avoid calling of_get_child_count() multiple times

 drivers/phy/phy-miphy28lp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/phy/phy-miphy28lp.c +2 -3
index 4fe1755..9334352 100644
@@ -1209,9 +1209,8 @@ static int miphy28lp_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	miphy_dev->nphys = of_get_child_count(np);
-	miphy_dev->phys = devm_kzalloc(&pdev->dev,
-				       sizeof(phy) * miphy_dev->nphys,
-				       GFP_KERNEL);
+	miphy_dev->phys = devm_kcalloc(&pdev->dev, miphy_dev->nphys,
+				       sizeof(*miphy_dev->phys), GFP_KERNEL);
 	if (!miphy_dev->phys)
 		return -ENOMEM;
 
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 2/2 phy: miphy28lp: Use PTR_ERR_OR_ZERO

PTR_ERR_OR_ZERO simplifies the code.

---
 drivers/phy/phy-miphy28lp.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/phy/phy-miphy28lp.c +1 -4
index 9334352..c4cc11d 100644
@@ -1259,10 +1259,7 @@ static int miphy28lp_probe(struct platform_device *pdev)
 	}
 
 	provider = devm_of_phy_provider_register(&pdev->dev, miphy28lp_xlate);
-	if (IS_ERR(provider))
-		return PTR_ERR(provider);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(provider);
 }
 
 static const struct of_device_id miphy28lp_of_match[] = {
Signature · 1 line
1.9.1
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] phy: miphy28lp: Use PTR_ERR_OR_ZERO

Quoted 23 lines · Axel Lin

PTR_ERR_OR_ZERO simplifies the code.

---
  drivers/phy/phy-miphy28lp.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/phy/phy-miphy28lp.c +1 -4
index 9334352..c4cc11d 100644
@@ -1259,10 +1259,7 @@ static int miphy28lp_probe(struct platform_device *pdev)
  	}
 
  	provider = devm_of_phy_provider_register(&pdev->dev, miphy28lp_xlate);
-	if (IS_ERR(provider))
-		return PTR_ERR(provider);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(provider);
  }
 
  static const struct of_device_id miphy28lp_of_match[] = {
Acked-by on v1 1/2
#3 lore raw
In reply to Axel Lin
Quoted 27 lines · Axel Lin

Prefer devm_kcalloc over devm_kzalloc with multiply. In additional, use sizeof(phy) is incorrect, fix it.

---
This patch is on top of below patch:
[PATCH 1/2] phy: miphy28lp: Avoid calling of_get_child_count() multiple times

  drivers/phy/phy-miphy28lp.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/phy/phy-miphy28lp.c +2 -3
index 4fe1755..9334352 100644
@@ -1209,9 +1209,8 @@ static int miphy28lp_probe(struct platform_device *pdev)
  		return -ENOMEM;
 
  	miphy_dev->nphys = of_get_child_count(np);
-	miphy_dev->phys = devm_kzalloc(&pdev->dev,
-				       sizeof(phy) * miphy_dev->nphys,
-				       GFP_KERNEL);
+	miphy_dev->phys = devm_kcalloc(&pdev->dev, miphy_dev->nphys,
+				       sizeof(*miphy_dev->phys), GFP_KERNEL);
  	if (!miphy_dev->phys)
  		return -ENOMEM;