phy: miphy28lp: Convert to devm_kcalloc and fix wrong sizof
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.
Signed-off-by Axel Lin <[email protected]>
---
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
@@ -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
PATCH 2/2 phy: miphy28lp: Use PTR_ERR_OR_ZERO
PTR_ERR_OR_ZERO simplifies the code.
Signed-off-by Axel Lin <[email protected]>
--- drivers/phy/phy-miphy28lp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/phy/phy-miphy28lp.c +1 -4
@@ -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
Re: [PATCH 2/2] phy: miphy28lp: Use PTR_ERR_OR_ZERO
Acked-by Gabriel Fernandez<[email protected]>
Quoted 23 lines · Axel Lin
PTR_ERR_OR_ZEROsimplifies the code.Signed-off-by Axel Lin <[email protected]>--- drivers/phy/phy-miphy28lp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/phy/phy-miphy28lp.c +1
-4@@ -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 Gabriel Fernandez<[email protected]>
Quoted 27 lines · Axel Lin
Prefer
devm_kcallocoverdevm_kzallocwith multiply. In additional, use sizeof(phy) is incorrect, fix it.Signed-off-by Axel Lin <[email protected]>---
This patch is on top of below patch:
[PATCH 1/2] phy: miphy28lp: Avoid callingof_get_child_count()multiple timesdrivers/phy/phy-miphy28lp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/phy/phy-miphy28lp.c +2
-3@@ -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 ;