gpu: ipu-v3: Removal of of_node_put with __free for auto cleanup
Subsystems (2)
PATCH 1/1 gpu: ipu-v3: Removal of of_node_put with __free for auto cleanup
Remove of_node_put for device node prg_node.
--- drivers/gpu/ipu-v3/ipu-prg.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/ipu-v3/ipu-prg.c +2 -5
@@ -84,8 +84,8 @@ static LIST_HEAD(ipu_prg_list);struct ipu_prg *ipu_prg_lookup_by_phandle (struct device *dev,const char *name,int ipu_id) { -struct device_node *prg_node =of_parse_phandle (dev->of_node, - name,0 ); + struct device_node *prg_node __free(device_node) = +of_parse_phandle (dev->of_node, name,0 );struct ipu_prg *prg;mutex_lock (&ipu_prg_list_mutex);
@@ -95,14 +95,11 @@ ipu_prg_lookup_by_phandle(struct device *dev, const char *name, int ipu_id)device_link_add (dev, prg->dev,DL_FLAG_AUTOREMOVE_CONSUMER ); prg->id = ipu_id; -of_node_put (prg_node);return prg; } }mutex_unlock (&ipu_prg_list_mutex); -of_node_put (prg_node); -return NULL ; }
Signature · 1 line
2.34.1
Quoted 28 lines · Abhinav Jain
Remove
of_node_putfor device nodeprg_node.Suggested-by Julia Lawall <[email protected]>Signed-off-by Abhinav Jain <[email protected]>--- drivers/gpu/ipu-v3/ipu-prg.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/gpu/ipu-v3/ipu-prg.c +2
-3@@ -84,8 +84,8 @@ static LIST_HEAD(ipu_prg_list);struct ipu_prg *ipu_prg_lookup_by_phandle (struct device *dev,const char *name,int ipu_id) { -struct device_node *prg_node =of_parse_phandle (dev->of_node, - name,0 ); + struct device_node *prg_node __free(device_node) = +of_parse_phandle (dev->of_node, name,0 );struct ipu_prg *prg;mutex_lock (&ipu_prg_list_mutex);@@ -95,14 +95,11 @@ ipu_prg_lookup_by_phandle(struct device *dev, const char *name, int ipu_id)device_link_add (dev, prg->dev,DL_FLAG_AUTOREMOVE_CONSUMER ); prg->id = ipu_id; -of_node_put (prg_node);
drivers/gpu/ipu-v3/ipu-prg.c ipu_prg_lookup_by_phandle(struct device *dev, const char *name, int ipu_id) · line 105
Quoted 10 lines
drivers/gpu/ipu-v3/ipu-prg.c +0
-2return prg; } }mutex_unlock (&ipu_prg_list_mutex); -of_node_put (prg_node); -return NULL ; }
Hi Abhinav,
Apart form having sent two different patches with the same title (hence the confusion), this cleanup is right from a functional point of view.
On the other hand, the description should address why you are doing this cleanup (e.g. to remove the need for explicit of_node_put() when the variable goes out of scope). The need for of_node_put() does no vanish, it is only automated and no longer visible at first glance by means of the cleanup attribute.
Best regards,
Javier Carrasco
Quoted 5 lines · Javier Carrasco
Hi Abhinav,
Apart form having sent two different patches with the same title (hence the confusion), this cleanup is right from a functional point of view.
Quoted 8 lines
On the other hand, the description should address why you are doing this cleanup (e.g. to remove the need for explicit
of_node_put()when the variable goes out of scope). The need forof_node_put()does no vanish, it is only automated and no longer visible at first glance by means of the cleanup attribute.Best regards,
Javier Carrasco
Hi Javier,
Thank you for the detailed feedback. I have modified the patch subject as well as the commit description to better fit the cleanup task being done.
PATCH v2:
https://lore.kernel.org/all/[email protected]/
Best Regards,
Abhinav Jain