Re: [PATCH 20/20] of: deprecate and rename of_property_for_each_u32()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Wed, Jul 03, 2024 at 12:37:04PM +0200, Luca Ceresoli wrote:
> of_property_for_each_u32() is meant to disappear. All the call sites not
> using the 3rd and 4th arguments have already been replaced by
> of_property_for_each_u32_new().
> 
> Deprecate the old macro. Also rename it to minimize the number of new
> usages and encourage conversion to the of_property_for_each_u32_new() macro
> in not(-yet)-upstream code.
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@xxxxxxxxxxx>
> 
> ---
> 
> Notes:
> 
>  * The following files have not been build-tested simply because I haven't
>    managed to have a config that enables them so far:
> 
>      drivers/irqchip/irq-pic32-evic.c
>      drivers/pinctrl/pinctrl-k210.c
> 
>  * These have not been converted yet as they are not trivial, and they will
>    need to use a more specific function that does the lookup they need and
>    returns the result:
> 
>      drivers/clk/clk-si5351.c

I would do something like this:

	sz = of_property_read_variable_u32_array(np, "silabs,pll-source", array, 2, 4);
	if (sz >= 2)
		pdata->pll_src[array[0]] = val_to_src(array[1]);
	if (sz >= 4)
		pdata->pll_src[array[2]] = val_to_src(array[3]);


>      drivers/clk/clk.c

Wouldn't this work:

8<------------------------------------------------------

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 8cca52be993f..33a8cc193556 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -5371,6 +5371,7 @@ const char *of_clk_get_parent_name(const struct device_node *np, int index)
        int rc;
        int count;
        struct clk *clk;
+       bool found = false;
 
        rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index,
                                        &clkspec);
@@ -5383,15 +5384,16 @@ const char *of_clk_get_parent_name(const struct device_node *np, int index)
        /* if there is an indices property, use it to transfer the index
         * specified into an array offset for the clock-output-names property.
         */
-       of_property_for_each_u32(clkspec.np, "clock-indices", prop, vp, pv) {
+       of_property_for_each_u32_new(clkspec.np, "clock-indices", pv) {
                if (index == pv) {
                        index = count;
+                       found = true;
                        break;
                }
                count++;
        }
        /* We went off the end of 'clock-indices' without finding it */
-       if (prop && !vp)
+       if (of_property_present(clkspec.np, "clock-indices") && !found)
                return NULL;
 
        if (of_property_read_string_index(clkspec.np, "clock-output-names",




[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux