fsl/fman: Fix some error handling code in mac_probe
cover fsl/fman: Fix some error handling code in mac_probe
Commit c6e26ea8c893 ("dpaa_eth: change device used") generated some conflicts in my patches waiting for submission. So I took a closer look at it.
So here is a serie of 4 patches.
The 1st one is just about a spurious call to 'dev_set_drvdata()', which is done in only 1 error handling path in the function.
The 2nd one removes some devm_iounmap/release/kfree functions which look useless to me.
The 3rd one fixes a missing of_node_put.
The 4th one is just cosmetic and removes a useless message.
Christophe JAILLET (4):
fsl/fman: Remove a useless call to 'dev_set_drvdata()' fsl/fman: Remove some useless code
fsl/fman: Add a missing 'of_node_put()' call in an error handling path fsl/fman: Remove a useless 'dev_err()' call
drivers/net/ethernet/freescale/fman/mac.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
Signature · 1 line
2.14.1
PATCH 1/4 fsl/fman: Remove a useless call to 'dev_set_drvdata()'
Commit c6e26ea8c893 ("dpaa_eth: change device used") has removed usage of 'dev_set_drvdata()' in the 'mac_probe() function.
This call should also be axed.
--- drivers/net/ethernet/freescale/fman/mac.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/freescale/fman/mac.c +0 -1
@@ -713,7 +713,6 @@ static int mac_probe(struct platform_device *_of_dev)__devm_release_region (dev,fman_get_mem_region (priv->fman), res.start, res.end +1 - res.start);devm_kfree (dev, mac_dev); -dev_set_drvdata (dev,NULL );return -ENODEV ; }
Signature · 1 line
2.14.1
PATCH 2/4 fsl/fman: Remove some useless code
In reply to Christophe JAILLETThere is no need to release explicitly some devm_ allocated resources. If the 'mac_probe()' probe function fails, they will be released automatically, as already done in the other error handling paths of this function.
Also goto '_return_of_get_parent' as in the other error handling paths. This is useless (priv->fixed_link is NULL at this point), but at least it is consistent.
--- drivers/net/ethernet/freescale/fman/mac.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/freescale/fman/mac.c +2 -5
@@ -709,11 +709,8 @@ static int mac_probe(struct platform_device *_of_dev) }if (!of_device_is_available (mac_node)) { -devm_iounmap (dev, priv->vaddr); -__devm_release_region (dev,fman_get_mem_region (priv->fman), - res.start, res.end +1 - res.start); -devm_kfree (dev, mac_dev); -return -ENODEV ; + err = -ENODEV ; + goto _return_of_get_parent; }/* Get the cell-index */
Signature · 1 line
2.14.1
Re: [PATCH 2/4] fsl/fman: Remove some useless code
Le 06/11/2017 à 22:53, Christophe JAILLET a écrit :
Quoted 22 lines
There is no need to release explicitly some
devm_allocated resources. If the 'mac_probe()' probe function fails, they will be released automatically, as already done in the other error handling paths of this function.Also goto '
_return_of_get_parent' as in the other error handling paths. This is useless (priv->fixed_linkis NULL at this point), but at least it is consistent.Signed-off-by Christophe JAILLET <[email protected]>--- drivers/net/ethernet/freescale/fman/mac.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/net/ethernet/freescale/fman/mac.c +0
-0@@ -709,11 +709,8 @@ static int mac_probe(struct platform_device *_of_dev) }if (!of_device_is_available (mac_node)) {
drivers/net/ethernet/freescale/fman/mac.c static int mac_probe(struct platform_device *_of_dev) · line 716
Quoted 10 lines
drivers/net/ethernet/freescale/fman/mac.c +2
-5-devm_iounmap (dev, priv->vaddr); -__devm_release_region (dev,fman_get_mem_region (priv->fman), - res.start, res.end +1 - res.start); -devm_kfree (dev, mac_dev); -return -ENODEV ; + err = -ENODEV ; + goto _return_of_get_parent; }/* Get the cell-index */
Or maybe 'return -EPROBE_DEFER' was expected?
CJ
PATCH 3/4 fsl/fman: Add a missing 'of_node_put()' call in an error handling path
In reply to Christophe JAILLETIf 'of_phy_find_device()' fails, we must undo the previous 'of_node_get()' call, as done the the following error handling code.
--- drivers/net/ethernet/freescale/fman/mac.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/freescale/fman/mac.c +1 -0
@@ -821,6 +821,7 @@ static int mac_probe(struct platform_device *_of_dev) phy =of_phy_find_device (mac_dev->phy_node);if (!phy) { err = -EINVAL ; +of_node_put (mac_dev->phy_node); goto _return_of_get_parent; }
Signature · 1 line
2.14.1
PATCH 4/4 fsl/fman: Remove a useless 'dev_err()' call
In reply to Christophe JAILLETMemory allocation functions already display some informaton in case of memory allocation failure. There is no need to add an extra 'dev_err' here.
--- drivers/net/ethernet/freescale/fman/mac.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/freescale/fman/mac.c +0 -1
@@ -615,7 +615,6 @@ static int mac_probe(struct platform_device *_of_dev) mac_dev =devm_kzalloc (dev,sizeof (*mac_dev),GFP_KERNEL );if (!mac_dev) { err = -ENOMEM ; -dev_err (dev,"devm_kzalloc() = %d\n" , err); goto _return; } priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );
Signature · 1 line
2.14.1
Madalin-cristian Bucur
maintainerHi Christophe,
I'll review and test your fixes.
Thank you!
Madalin
Quoted 38 lines
-----Original Message-----
From: Christophe JAILLET [mailto:[email protected]]
Sent: Monday, November 06, 2017 11:53 PM
To: Madalin-cristian Bucur <[email protected]>
Cc: [email protected]; [email protected]; kernel- [email protected]; Christophe JAILLET <[email protected]>
Subject: [PATCH 0/4] fsl/fman: Fix some error handling code inmac_probeCommit
c6e26ea8c893("dpaa_eth: change device used") generated some conflicts in my patches waiting for submission. So I took a closer look at it.So here is a serie of 4 patches.
The 1st one is just about a spurious call to '
dev_set_drvdata()', which is done in only 1 error handling path in the function.The 2nd one removes some devm_iounmap/release/kfree functions which look useless to me.
The 3rd one fixes a missing
of_node_put.The 4th one is just cosmetic and removes a useless message.
Christophe JAILLET (4):
fsl/fman: Remove a useless call to 'dev_set_drvdata()' fsl/fman: Remove some useless code
fsl/fman: Add a missing 'of_node_put()' call in an error handling path fsl/fman: Remove a useless 'dev_err()' calldrivers/net/ethernet/freescale/fman/mac.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)--
2.14.1
David Miller
maintainerFrom: Christophe JAILLET <[email protected]>
Date: Mon, 6 Nov 2017 22:53:28 +0100
Quoted 10 lines
Commit
c6e26ea8c893("dpaa_eth: change device used") generated some conflicts in my patches waiting for submission. So I took a closer look at it.So here is a serie of 4 patches.
The 1st one is just about a spurious call to '
dev_set_drvdata()', which is done in only 1 error handling path in the function.
Quoted 6 lines
The 2nd one removes some devm_iounmap/release/kfree functions which look useless to me.
The 3rd one fixes a missing
of_node_put.The 4th one is just cosmetic and removes a useless message.
Series applied to net-next, thank you.