thermal/core: Remove pointless variable when registering a cooling device
Daniel Lezcano
maintainerPATCH 1/1 thermal/core: Remove pointless variable when registering a cooling device
From: Daniel Lezcano <[email protected]>
The 'id' variable is set to store the ida_alloc() value which is already stored into cdev->id. It is pointless to use it because cdev->id can be used instead.
--- drivers/thermal/thermal_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/thermal/thermal_core.c +2 -3
@@ -1061,7 +1061,7 @@ __thermal_cooling_device_register(struct device_node *np, {struct thermal_cooling_device *cdev;unsigned long current_state; -int id, ret; +int ret;if (!ops || !ops->get_max_state || !ops->get_cur_state || !ops->set_cur_state)
@@ -1078,7 +1078,6 @@ __thermal_cooling_device_register(struct device_node *np,if (ret <0 ) goto out_kfree_cdev; cdev->id = ret; - id = ret; cdev->type =kstrdup_const (type ? type :"" ,GFP_KERNEL );if (!cdev->type) {
@@ -1135,7 +1134,7 @@ __thermal_cooling_device_register(struct device_node *np, out_cdev_type:kfree_const (cdev->type); out_ida_remove: -ida_free (&thermal_cdev_ida, id); +ida_free (&thermal_cdev_ida, cdev->id); out_kfree_cdev:kfree (cdev);return ERR_PTR (ret);
Signature · 1 line
2.43.0
Quoted 34 lines · Daniel Lezcano
From: Daniel Lezcano <[email protected]>
The 'id' variable is set to store the
ida_alloc()value which is already stored intocdev->id. It is pointless to use it becausecdev->idcan be used instead.Signed-off-by Daniel Lezcano <[email protected]>Signed-off-by Daniel Lezcano <[email protected]>--- drivers/thermal/thermal_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/thermal/thermal_core.c +1
-2@@ -1061,7 +1061,7 @@ __thermal_cooling_device_register(struct device_node *np, {struct thermal_cooling_device *cdev;unsigned long current_state; -int id, ret; +int ret;if (!ops || !ops->get_max_state || !ops->get_cur_state || !ops->set_cur_state)@@ -1078,7 +1078,6 @@ __thermal_cooling_device_register(struct device_node *np,if (ret <0 ) goto out_kfree_cdev; cdev->id = ret; - id = ret; cdev->type =kstrdup_const (type ? type :"" ,GFP_KERNEL );if (!cdev->type) {
drivers/thermal/thermal_core.c __thermal_cooling_device_register(struct device_node *np, · line 1140
Quoted 8 lines
drivers/thermal/thermal_core.c +1
-1@@ -1135,7 +1134,7 @@ __thermal_cooling_device_register(struct device_node *np, out_cdev_type:kfree_const (cdev->type); out_ida_remove: -ida_free (&thermal_cdev_ida, id); +ida_free (&thermal_cdev_ida, cdev->id); out_kfree_cdev:kfree (cdev);return ERR_PTR (ret);
Quoted 35 lines · Lukasz Luba
Quoted 31 lines · Daniel Lezcano
From: Daniel Lezcano <[email protected]>
The 'id' variable is set to store the
ida_alloc()value which is already stored intocdev->id. It is pointless to use it becausecdev->idcan be used instead.Signed-off-by Daniel Lezcano <[email protected]>Signed-off-by Daniel Lezcano <[email protected]>--- drivers/thermal/thermal_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/thermal/thermal_core.c +1
-2@@ -1061,7 +1061,7 @@ __thermal_cooling_device_register(struct device_node *np, {struct thermal_cooling_device *cdev;unsigned long current_state; -int id, ret; +int ret;if (!ops || !ops->get_max_state || !ops->get_cur_state || !ops->set_cur_state)@@ -1078,7 +1078,6 @@ __thermal_cooling_device_register(struct device_node *np,if (ret <0 ) goto out_kfree_cdev; cdev->id = ret; - id = ret;
Quoted 14 lines
drivers/thermal/thermal_core.c __thermal_cooling_device_register(struct device_node *np, · line 1140
Quoted 11 lines
drivers/thermal/thermal_core.c +1
-1cdev->type =kstrdup_const (type ? type :"" ,GFP_KERNEL );if (!cdev->type) {@@ -1135,7 +1134,7 @@ __thermal_cooling_device_register(struct device_node *np, out_cdev_type:kfree_const (cdev->type); out_ida_remove: -ida_free (&thermal_cdev_ida, id); +ida_free (&thermal_cdev_ida, cdev->id); out_kfree_cdev:kfree (cdev);return ERR_PTR (ret);Reviewed-by Lukasz Luba <[email protected]>
Applied as 7.1 material, thanks!