Skip to contentSkip to conversation

clk: tegra: clk-tegra124-dfll-fcpu: don't use devm functions for regulator

PATCH Applied Alexandru Ardelean 3 participants 4 messages Jun 24, 2021 – Jun 25, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: tegra: clk-tegra124-dfll-fcpu: don't use devm functions for regulator

The purpose of the device-managed functions is to bind the life-time of an object to that of a parent device object.

This is not the case for the 'vdd-cpu' regulator in this driver. A reference is obtained via devm_regulator_get() and immediately released with devm_regulator_put().

In this case, the usage of devm_ functions is slightly excessive, as the un-managed versions of these functions is a little cleaner (and slightly more economical in terms of allocation).

This change converts the devm_regulator_{get,put}() to regulator_{get,put}() in the get_alignment_from_regulator() function of this driver.

---
 drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c +2 -2
index 2ac2679d696d..5e339ad0a97c 100644
@@ -537,7 +537,7 @@ static void get_alignment_from_dt(struct device *dev,
 static int get_alignment_from_regulator(struct device *dev,
 					 struct rail_alignment *align)
 {
-	struct regulator *reg = devm_regulator_get(dev, "vdd-cpu");
+	struct regulator *reg = regulator_get(dev, "vdd-cpu");
 
 	if (IS_ERR(reg))
 		return PTR_ERR(reg);
@@ -545,7 +545,7 @@ static int get_alignment_from_regulator(struct device *dev,
 	align->offset_uv = regulator_list_voltage(reg, 0);
 	align->step_uv = regulator_get_linear_step(reg);
 
-	devm_regulator_put(reg);
+	regulator_put(reg);
 
 	return 0;
 }
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Alexandru Ardelean

The purpose of the device-managed functions is to bind the life-time of an object to that of a parent device object.

This is not the case for the 'vdd-cpu' regulator in this driver. A reference is obtained via devm_regulator_get() and immediately released with devm_regulator_put().

In this case, the usage of devm_ functions is slightly excessive, as the un-managed versions of these functions is a little cleaner (and slightly more economical in terms of allocation).

Quoted 8 lines

This change converts the devm_regulator_{get,put}() to regulator_{get,put}() in the get_alignment_from_regulator() function of this driver.

---
 drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Indeed, this seems unnecessary:

Mike, Stephen: do you want to pick this up directly or would you prefer if I collected this into a clk branch for the next cycle?

Thierry

maintainer
#2 lore raw

Quoting Thierry Reding (2021-06-24 04:57:08)

Quoted 21 lines · Alexandru Ardelean
Quoted 11 lines

The purpose of the device-managed functions is to bind the life-time of an object to that of a parent device object.

This is not the case for the 'vdd-cpu' regulator in this driver. A reference is obtained via devm_regulator_get() and immediately released with devm_regulator_put().

In this case, the usage of devm_ functions is slightly excessive, as the un-managed versions of these functions is a little cleaner (and slightly more economical in terms of allocation).

Quoted 8 lines

This change converts the devm_regulator_{get,put}() to regulator_{get,put}() in the get_alignment_from_regulator() function of this driver.

---
 drivers/clk/tegra/clk-tegra124-dfll-fcpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 7 lines

Indeed, this seems unnecessary:

Mike, Stephen: do you want to pick this up directly or would you prefer if I collected this into a clk branch for the next cycle?

No worries. I got it.

maintainer Applied
#3 lore raw
In reply to Alexandru Ardelean

Quoting Alexandru Ardelean (2021-06-24 01:47:37)

Quoted 11 lines

The purpose of the device-managed functions is to bind the life-time of an object to that of a parent device object.

This is not the case for the 'vdd-cpu' regulator in this driver. A reference is obtained via devm_regulator_get() and immediately released with devm_regulator_put().

In this case, the usage of devm_ functions is slightly excessive, as the un-managed versions of these functions is a little cleaner (and slightly more economical in terms of allocation).

Quoted 6 lines

This change converts the devm_regulator_{get,put}() to regulator_{get,put}() in the get_alignment_from_regulator() function of this driver.

---

Applied to clk-next