diff mbox series

[v3,2/3] clk: Make __clk_hw_register_fixed_factor non-static

Message ID 20220226040723.143705-2-marex@denx.de (mailing list archive)
State Accepted, archived
Headers show
Series [v3,1/3] dt-bindings: clk: rs9: Add Renesas 9-series I2C PCIe clock generator | expand

Commit Message

Marek Vasut Feb. 26, 2022, 4:07 a.m. UTC
Access to the full parameters of __clk_hw_register_fixed_factor()
is useful in case a driver is registering fixed clock with only
single parent, in which case the driver should set parent_name to
NULL and parent_index to 0, and access to this function permits it
to do just that.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: devicetree@vger.kernel.org
To: linux-clk@vger.kernel.org
---
V2: - New patch
V3: - No change
---
 drivers/clk/clk-fixed-factor.c | 2 +-
 include/linux/clk-provider.h   | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Stephen Boyd March 15, 2022, 11:58 p.m. UTC | #1
Quoting Marek Vasut (2022-02-25 20:07:22)
> Access to the full parameters of __clk_hw_register_fixed_factor()
> is useful in case a driver is registering fixed clock with only
> single parent, in which case the driver should set parent_name to
> NULL and parent_index to 0, and access to this function permits it
> to do just that.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Stephen Boyd <sboyd@kernel.org>
> Cc: devicetree@vger.kernel.org
> To: linux-clk@vger.kernel.org
> ---

Applied to clk-next
Stephen Boyd March 18, 2022, 9:03 p.m. UTC | #2
Quoting Marek Vasut (2022-02-25 20:07:22)
> Access to the full parameters of __clk_hw_register_fixed_factor()
> is useful in case a driver is registering fixed clock with only
> single parent, in which case the driver should set parent_name to
> NULL and parent_index to 0, and access to this function permits it
> to do just that.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Stephen Boyd <sboyd@kernel.org>
> Cc: devicetree@vger.kernel.org
> To: linux-clk@vger.kernel.org
> ---
> V2: - New patch
> V3: - No change

This isn't exported. Given that we don't typically export an internal
function (hence the double underscore) I'm going to change this to be a
new function. See the attached patch.

---8<----
diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
index 81d8c9e430a2..54942d758ee6 100644
--- a/drivers/clk/clk-fixed-factor.c
+++ b/drivers/clk/clk-fixed-factor.c
@@ -76,7 +76,7 @@ static void devm_clk_hw_register_fixed_factor_release(struct device *dev, void *
 	clk_hw_unregister(&fix->hw);
 }
 
-struct clk_hw *
+static struct clk_hw *
 __clk_hw_register_fixed_factor(struct device *dev, struct device_node *np,
 		const char *name, const char *parent_name, int index,
 		unsigned long flags, unsigned int mult, unsigned int div,
@@ -131,6 +131,28 @@ __clk_hw_register_fixed_factor(struct device *dev, struct device_node *np,
 	return hw;
 }
 
+/**
+ * devm_clk_hw_register_fixed_factor_index - Register a fixed factor clock with
+ * parent from DT index
+ * @dev: device that is registering this clock
+ * @name: name of this clock
+ * @index: index of phandle in @dev 'clocks' property
+ * @flags: fixed factor flags
+ * @mult: multiplier
+ * @div: divider
+ *
+ * Return: Pointer to fixed factor clk_hw structure that was registered or
+ * an error pointer.
+ */
+struct clk_hw *devm_clk_hw_register_fixed_factor_index(struct device *dev,
+		const char *name, unsigned int index, unsigned long flags,
+		unsigned int mult, unsigned int div)
+{
+	return __clk_hw_register_fixed_factor(dev, NULL, name, NULL, index,
+					      flags, mult, div, true);
+}
+EXPORT_SYMBOL_GPL(devm_clk_hw_register_fixed_factor_index);
+
 struct clk_hw *clk_hw_register_fixed_factor(struct device *dev,
 		const char *name, const char *parent_name, unsigned long flags,
 		unsigned int mult, unsigned int div)
diff --git a/drivers/clk/clk-renesas-pcie.c b/drivers/clk/clk-renesas-pcie.c
index cd8229dd8123..59d9cf0053eb 100644
--- a/drivers/clk/clk-renesas-pcie.c
+++ b/drivers/clk/clk-renesas-pcie.c
@@ -250,8 +250,8 @@ static int rs9_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	/* Register clock */
 	for (i = 0; i < rs9->chip_info->num_clks; i++) {
 		snprintf(name, 5, "DIF%d", i);
-		hw = __clk_hw_register_fixed_factor(&client->dev, NULL, name,
-						    NULL, 0, 0, 4, 1, true);
+		hw = devm_clk_hw_register_fixed_factor_index(&client->dev, name,
+						    0, 0, 4, 1);
 		if (IS_ERR(hw))
 			return PTR_ERR(hw);
 
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index d216221448d3..b7a7923f6bbb 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -992,11 +992,6 @@ struct clk_fixed_factor {
 #define to_clk_fixed_factor(_hw) container_of(_hw, struct clk_fixed_factor, hw)
 
 extern const struct clk_ops clk_fixed_factor_ops;
-struct clk_hw *
-__clk_hw_register_fixed_factor(struct device *dev, struct device_node *np,
-		const char *name, const char *parent_name, int index,
-		unsigned long flags, unsigned int mult, unsigned int div,
-		bool devm);
 struct clk *clk_register_fixed_factor(struct device *dev, const char *name,
 		const char *parent_name, unsigned long flags,
 		unsigned int mult, unsigned int div);
@@ -1008,6 +1003,9 @@ void clk_hw_unregister_fixed_factor(struct clk_hw *hw);
 struct clk_hw *devm_clk_hw_register_fixed_factor(struct device *dev,
 		const char *name, const char *parent_name, unsigned long flags,
 		unsigned int mult, unsigned int div);
+struct clk_hw *devm_clk_hw_register_fixed_factor_index(struct device *dev,
+		const char *name, unsigned int index, unsigned long flags,
+		unsigned int mult, unsigned int div);
 /**
  * struct clk_fractional_divider - adjustable fractional divider clock
  *
Marek Vasut March 20, 2022, 1:23 p.m. UTC | #3
On 3/18/22 22:03, Stephen Boyd wrote:
> Quoting Marek Vasut (2022-02-25 20:07:22)
>> Access to the full parameters of __clk_hw_register_fixed_factor()
>> is useful in case a driver is registering fixed clock with only
>> single parent, in which case the driver should set parent_name to
>> NULL and parent_index to 0, and access to this function permits it
>> to do just that.
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
>> Cc: Michael Turquette <mturquette@baylibre.com>
>> Cc: Rob Herring <robh+dt@kernel.org>
>> Cc: Stephen Boyd <sboyd@kernel.org>
>> Cc: devicetree@vger.kernel.org
>> To: linux-clk@vger.kernel.org
>> ---
>> V2: - New patch
>> V3: - No change
> 
> This isn't exported. Given that we don't typically export an internal
> function (hence the double underscore) I'm going to change this to be a
> new function. See the attached patch.

I can confirm the change works and looks OK.

Do you want me to send a V4 or will you squash it into these patches 
yourself when applying?
Stephen Boyd March 21, 2022, 7:26 p.m. UTC | #4
Quoting Marek Vasut (2022-03-20 06:23:14)
> On 3/18/22 22:03, Stephen Boyd wrote:
> > Quoting Marek Vasut (2022-02-25 20:07:22)
> >> Access to the full parameters of __clk_hw_register_fixed_factor()
> >> is useful in case a driver is registering fixed clock with only
> >> single parent, in which case the driver should set parent_name to
> >> NULL and parent_index to 0, and access to this function permits it
> >> to do just that.
> >>
> >> Signed-off-by: Marek Vasut <marex@denx.de>
> >> Cc: Michael Turquette <mturquette@baylibre.com>
> >> Cc: Rob Herring <robh+dt@kernel.org>
> >> Cc: Stephen Boyd <sboyd@kernel.org>
> >> Cc: devicetree@vger.kernel.org
> >> To: linux-clk@vger.kernel.org
> >> ---
> >> V2: - New patch
> >> V3: - No change
> > 
> > This isn't exported. Given that we don't typically export an internal
> > function (hence the double underscore) I'm going to change this to be a
> > new function. See the attached patch.
> 
> I can confirm the change works and looks OK.
> 
> Do you want me to send a V4 or will you squash it into these patches 
> yourself when applying?

No need I fixed it up and pushed it out.
Marek Vasut March 21, 2022, 7:43 p.m. UTC | #5
On 3/21/22 20:26, Stephen Boyd wrote:
> Quoting Marek Vasut (2022-03-20 06:23:14)
>> On 3/18/22 22:03, Stephen Boyd wrote:
>>> Quoting Marek Vasut (2022-02-25 20:07:22)
>>>> Access to the full parameters of __clk_hw_register_fixed_factor()
>>>> is useful in case a driver is registering fixed clock with only
>>>> single parent, in which case the driver should set parent_name to
>>>> NULL and parent_index to 0, and access to this function permits it
>>>> to do just that.
>>>>
>>>> Signed-off-by: Marek Vasut <marex@denx.de>
>>>> Cc: Michael Turquette <mturquette@baylibre.com>
>>>> Cc: Rob Herring <robh+dt@kernel.org>
>>>> Cc: Stephen Boyd <sboyd@kernel.org>
>>>> Cc: devicetree@vger.kernel.org
>>>> To: linux-clk@vger.kernel.org
>>>> ---
>>>> V2: - New patch
>>>> V3: - No change
>>>
>>> This isn't exported. Given that we don't typically export an internal
>>> function (hence the double underscore) I'm going to change this to be a
>>> new function. See the attached patch.
>>
>> I can confirm the change works and looks OK.
>>
>> Do you want me to send a V4 or will you squash it into these patches
>> yourself when applying?
> 
> No need I fixed it up and pushed it out.

Thank you
diff mbox series

Patch

diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
index 4e4b6d3676126..81d8c9e430a23 100644
--- a/drivers/clk/clk-fixed-factor.c
+++ b/drivers/clk/clk-fixed-factor.c
@@ -76,7 +76,7 @@  static void devm_clk_hw_register_fixed_factor_release(struct device *dev, void *
 	clk_hw_unregister(&fix->hw);
 }
 
-static struct clk_hw *
+struct clk_hw *
 __clk_hw_register_fixed_factor(struct device *dev, struct device_node *np,
 		const char *name, const char *parent_name, int index,
 		unsigned long flags, unsigned int mult, unsigned int div,
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 2faa6f7aa8a87..d216221448d31 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -992,6 +992,11 @@  struct clk_fixed_factor {
 #define to_clk_fixed_factor(_hw) container_of(_hw, struct clk_fixed_factor, hw)
 
 extern const struct clk_ops clk_fixed_factor_ops;
+struct clk_hw *
+__clk_hw_register_fixed_factor(struct device *dev, struct device_node *np,
+		const char *name, const char *parent_name, int index,
+		unsigned long flags, unsigned int mult, unsigned int div,
+		bool devm);
 struct clk *clk_register_fixed_factor(struct device *dev, const char *name,
 		const char *parent_name, unsigned long flags,
 		unsigned int mult, unsigned int div);