All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Dong Aisheng <aisheng.dong@nxp.com>, linux-clk@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, mturquette@baylibre.com,
	hdegoede@redhat.com, b.zolnierkie@samsung.com,
	linux@armlinux.org.uk, linux-fbdev@vger.kernel.org,
	linux-imx@nxp.com, Dong Aisheng <aisheng.dong@nxp.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>
Subject: Re: [PATCH V2 2/4] clk: add new APIs to operate on all available clocks
Date: Fri, 23 Mar 2018 09:56:57 -0700	[thread overview]
Message-ID: <152182421754.178046.7553203878044979411@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <1521602391-30356-3-git-send-email-aisheng.dong@nxp.com>

Quoting Dong Aisheng (2018-03-20 20:19:49)
> @@ -50,6 +52,38 @@ static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
>         return ret;
>  }
>  EXPORT_SYMBOL(of_clk_bulk_get);
> +
> +static int __must_check of_clk_bulk_get_all(struct device_node *np,
> +                                           struct clk_bulk_data **clks)
> +{
> +       struct clk_bulk_data *clk_bulk;
> +       int num_clks;
> +       int ret;
> +
> +       num_clks = of_clk_get_parent_count(np);
> +       if (!num_clks)
> +               return 0;
> +
> +       clk_bulk = kcalloc(num_clks, sizeof(*clk_bulk), GFP_KERNEL);

Can be kmalloc_array? of_clk_bulk_get() already clears things out
appropriately.

> +       if (!clk_bulk)
> +               return -ENOMEM;
> +
> +       ret = of_clk_bulk_get(np, num_clks, clk_bulk);
> +       if (ret) {
> +               kfree(clk_bulk);
> +               return ret;
> +       }
> +
> +       *clks = clk_bulk;
> +
> +       return num_clks;
> +}
> +#else
> +static int __must_check of_clk_bulk_get_all(struct device_node *np,
> +                                           struct clk_bulk_data **clks)
> +{
> +       return -ENOENT;
> +}
>  #endif

This else can probably be dropped too.

>  
>  void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
> @@ -90,6 +124,29 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks,
>  }
>  EXPORT_SYMBOL(clk_bulk_get);
>  
> +void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks)
> +{
> +       if (IS_ERR_OR_NULL(clks))
> +               return;
> +
> +       clk_bulk_put(num_clks, clks);
> +
> +       kfree(clks);
> +}
> +EXPORT_SYMBOL(clk_bulk_put_all);
> +
> +int __must_check clk_bulk_get_all(struct device *dev,
> +                                 struct clk_bulk_data **clks)
> +{
> +       struct device_node *np = dev_of_node(dev);
> +
> +       if (!np)
> +               return 0;
> +
> +       return of_clk_bulk_get_all(np, clks);
> +}
> +EXPORT_SYMBOL(clk_bulk_get_all);

Looks better!

WARNING: multiple messages have this Message-ID (diff)
From: Stephen Boyd <sboyd@kernel.org>
To: Dong Aisheng <aisheng.dong@nxp.com>, linux-clk@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, mturquette@baylibre.com,
	hdegoede@redhat.com, b.zolnierkie@samsung.com,
	linux@armlinux.org.uk, linux-fbdev@vger.kernel.org,
	linux-imx@nxp.com, Dong Aisheng <aisheng.dong@nxp.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>
Subject: Re: [PATCH V2 2/4] clk: add new APIs to operate on all available clocks
Date: Fri, 23 Mar 2018 09:56:57 -0700	[thread overview]
Message-ID: <152182421754.178046.7553203878044979411@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <1521602391-30356-3-git-send-email-aisheng.dong@nxp.com>

Quoting Dong Aisheng (2018-03-20 20:19:49)
> @@ -50,6 +52,38 @@ static int __must_check of_clk_bulk_get(struct device_=
node *np, int num_clks,
>         return ret;
>  }
>  EXPORT_SYMBOL(of_clk_bulk_get);
> +
> +static int __must_check of_clk_bulk_get_all(struct device_node *np,
> +                                           struct clk_bulk_data **clks)
> +{
> +       struct clk_bulk_data *clk_bulk;
> +       int num_clks;
> +       int ret;
> +
> +       num_clks =3D of_clk_get_parent_count(np);
> +       if (!num_clks)
> +               return 0;
> +
> +       clk_bulk =3D kcalloc(num_clks, sizeof(*clk_bulk), GFP_KERNEL);

Can be kmalloc_array? of_clk_bulk_get() already clears things out
appropriately.

> +       if (!clk_bulk)
> +               return -ENOMEM;
> +
> +       ret =3D of_clk_bulk_get(np, num_clks, clk_bulk);
> +       if (ret) {
> +               kfree(clk_bulk);
> +               return ret;
> +       }
> +
> +       *clks =3D clk_bulk;
> +
> +       return num_clks;
> +}
> +#else
> +static int __must_check of_clk_bulk_get_all(struct device_node *np,
> +                                           struct clk_bulk_data **clks)
> +{
> +       return -ENOENT;
> +}
>  #endif

This else can probably be dropped too.

>  =

>  void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
> @@ -90,6 +124,29 @@ int __must_check clk_bulk_get(struct device *dev, int=
 num_clks,
>  }
>  EXPORT_SYMBOL(clk_bulk_get);
>  =

> +void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks)
> +{
> +       if (IS_ERR_OR_NULL(clks))
> +               return;
> +
> +       clk_bulk_put(num_clks, clks);
> +
> +       kfree(clks);
> +}
> +EXPORT_SYMBOL(clk_bulk_put_all);
> +
> +int __must_check clk_bulk_get_all(struct device *dev,
> +                                 struct clk_bulk_data **clks)
> +{
> +       struct device_node *np =3D dev_of_node(dev);
> +
> +       if (!np)
> +               return 0;
> +
> +       return of_clk_bulk_get_all(np, clks);
> +}
> +EXPORT_SYMBOL(clk_bulk_get_all);

Looks better!

WARNING: multiple messages have this Message-ID (diff)
From: Stephen Boyd <sboyd@kernel.org>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V2 2/4] clk: add new APIs to operate on all available clocks
Date: Fri, 23 Mar 2018 16:56:57 +0000	[thread overview]
Message-ID: <152182421754.178046.7553203878044979411@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <1521602391-30356-3-git-send-email-aisheng.dong@nxp.com>

Quoting Dong Aisheng (2018-03-20 20:19:49)
> @@ -50,6 +52,38 @@ static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
>         return ret;
>  }
>  EXPORT_SYMBOL(of_clk_bulk_get);
> +
> +static int __must_check of_clk_bulk_get_all(struct device_node *np,
> +                                           struct clk_bulk_data **clks)
> +{
> +       struct clk_bulk_data *clk_bulk;
> +       int num_clks;
> +       int ret;
> +
> +       num_clks = of_clk_get_parent_count(np);
> +       if (!num_clks)
> +               return 0;
> +
> +       clk_bulk = kcalloc(num_clks, sizeof(*clk_bulk), GFP_KERNEL);

Can be kmalloc_array? of_clk_bulk_get() already clears things out
appropriately.

> +       if (!clk_bulk)
> +               return -ENOMEM;
> +
> +       ret = of_clk_bulk_get(np, num_clks, clk_bulk);
> +       if (ret) {
> +               kfree(clk_bulk);
> +               return ret;
> +       }
> +
> +       *clks = clk_bulk;
> +
> +       return num_clks;
> +}
> +#else
> +static int __must_check of_clk_bulk_get_all(struct device_node *np,
> +                                           struct clk_bulk_data **clks)
> +{
> +       return -ENOENT;
> +}
>  #endif

This else can probably be dropped too.

>  
>  void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
> @@ -90,6 +124,29 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks,
>  }
>  EXPORT_SYMBOL(clk_bulk_get);
>  
> +void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks)
> +{
> +       if (IS_ERR_OR_NULL(clks))
> +               return;
> +
> +       clk_bulk_put(num_clks, clks);
> +
> +       kfree(clks);
> +}
> +EXPORT_SYMBOL(clk_bulk_put_all);
> +
> +int __must_check clk_bulk_get_all(struct device *dev,
> +                                 struct clk_bulk_data **clks)
> +{
> +       struct device_node *np = dev_of_node(dev);
> +
> +       if (!np)
> +               return 0;
> +
> +       return of_clk_bulk_get_all(np, clks);
> +}
> +EXPORT_SYMBOL(clk_bulk_get_all);

Looks better!

WARNING: multiple messages have this Message-ID (diff)
From: sboyd@kernel.org (Stephen Boyd)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 2/4] clk: add new APIs to operate on all available clocks
Date: Fri, 23 Mar 2018 09:56:57 -0700	[thread overview]
Message-ID: <152182421754.178046.7553203878044979411@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <1521602391-30356-3-git-send-email-aisheng.dong@nxp.com>

Quoting Dong Aisheng (2018-03-20 20:19:49)
> @@ -50,6 +52,38 @@ static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
>         return ret;
>  }
>  EXPORT_SYMBOL(of_clk_bulk_get);
> +
> +static int __must_check of_clk_bulk_get_all(struct device_node *np,
> +                                           struct clk_bulk_data **clks)
> +{
> +       struct clk_bulk_data *clk_bulk;
> +       int num_clks;
> +       int ret;
> +
> +       num_clks = of_clk_get_parent_count(np);
> +       if (!num_clks)
> +               return 0;
> +
> +       clk_bulk = kcalloc(num_clks, sizeof(*clk_bulk), GFP_KERNEL);

Can be kmalloc_array? of_clk_bulk_get() already clears things out
appropriately.

> +       if (!clk_bulk)
> +               return -ENOMEM;
> +
> +       ret = of_clk_bulk_get(np, num_clks, clk_bulk);
> +       if (ret) {
> +               kfree(clk_bulk);
> +               return ret;
> +       }
> +
> +       *clks = clk_bulk;
> +
> +       return num_clks;
> +}
> +#else
> +static int __must_check of_clk_bulk_get_all(struct device_node *np,
> +                                           struct clk_bulk_data **clks)
> +{
> +       return -ENOENT;
> +}
>  #endif

This else can probably be dropped too.

>  
>  void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
> @@ -90,6 +124,29 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks,
>  }
>  EXPORT_SYMBOL(clk_bulk_get);
>  
> +void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks)
> +{
> +       if (IS_ERR_OR_NULL(clks))
> +               return;
> +
> +       clk_bulk_put(num_clks, clks);
> +
> +       kfree(clks);
> +}
> +EXPORT_SYMBOL(clk_bulk_put_all);
> +
> +int __must_check clk_bulk_get_all(struct device *dev,
> +                                 struct clk_bulk_data **clks)
> +{
> +       struct device_node *np = dev_of_node(dev);
> +
> +       if (!np)
> +               return 0;
> +
> +       return of_clk_bulk_get_all(np, clks);
> +}
> +EXPORT_SYMBOL(clk_bulk_get_all);

Looks better!

  reply	other threads:[~2018-03-23 16:57 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-21  3:19 [PATCH V2 0/4] clk: new APIs to handle all available clocks Dong Aisheng
2018-03-21  3:19 ` Dong Aisheng
2018-03-21  3:19 ` Dong Aisheng
2018-03-21  3:19 ` [PATCH V2 1/4] clk: bulk: add of_clk_bulk_get() Dong Aisheng
2018-03-21  3:19   ` Dong Aisheng
2018-03-21  3:19   ` Dong Aisheng
2018-03-23 16:53   ` Stephen Boyd
2018-03-23 16:53     ` Stephen Boyd
2018-03-23 16:53     ` Stephen Boyd
2018-03-23 16:53     ` Stephen Boyd
2018-05-25  9:48     ` A.s. Dong
2018-05-25  9:48       ` A.s. Dong
2018-05-25  9:48       ` A.s. Dong
2018-05-25  9:48       ` A.s. Dong
2018-03-21  3:19 ` [PATCH V2 2/4] clk: add new APIs to operate on all available clocks Dong Aisheng
2018-03-21  3:19   ` Dong Aisheng
2018-03-21  3:19   ` Dong Aisheng
2018-03-23 16:56   ` Stephen Boyd [this message]
2018-03-23 16:56     ` Stephen Boyd
2018-03-23 16:56     ` Stephen Boyd
2018-03-23 16:56     ` Stephen Boyd
2018-05-25  9:49     ` A.s. Dong
2018-05-25  9:49       ` A.s. Dong
2018-05-25  9:49       ` A.s. Dong
2018-05-25  9:49       ` A.s. Dong
2018-03-21  3:19 ` [PATCH V2 3/4] clk: add managed version of clk_bulk_get_all Dong Aisheng
2018-03-21  3:19   ` Dong Aisheng
2018-03-21  3:19   ` Dong Aisheng
2018-03-23  6:49   ` kbuild test robot
2018-03-23  6:49     ` kbuild test robot
2018-03-23  6:49     ` kbuild test robot
2018-05-25  9:51     ` A.s. Dong
2018-05-25  9:51       ` A.s. Dong
2018-05-25  9:51       ` A.s. Dong
2018-05-25  9:51       ` A.s. Dong
2018-03-21  3:19 ` [PATCH V2 4/4] video: simplefb: switch to use clk_bulk API to simplify clock operations Dong Aisheng
2018-03-21  3:19   ` Dong Aisheng
2018-03-21  3:19   ` Dong Aisheng
2018-03-23  5:28   ` kbuild test robot
2018-03-23  5:28     ` kbuild test robot
2018-03-23  5:28     ` kbuild test robot
  -- strict thread matches above, loose matches on Subject: below --
2018-03-21  2:54 [PATCH V2 0/4] clk: new APIs to handle all available clocks Dong Aisheng
2018-03-21  2:54 ` Dong Aisheng
2018-03-21  2:54 ` Dong Aisheng
2018-03-21  2:54 ` Dong Aisheng
2018-03-21  2:54 ` [PATCH V2 1/4] clk: bulk: add of_clk_bulk_get() Dong Aisheng
2018-03-21  2:54   ` Dong Aisheng
2018-03-21  2:54   ` Dong Aisheng
2018-03-21  2:54   ` Dong Aisheng
2018-03-21  2:54 ` [PATCH V2 2/4] clk: add new APIs to operate on all available clocks Dong Aisheng
2018-03-21  2:54   ` Dong Aisheng
2018-03-21  2:54   ` Dong Aisheng
2018-03-21  2:54   ` Dong Aisheng
2018-03-21  2:54 ` [PATCH V2 3/4] clk: add managed version of clk_bulk_get_all Dong Aisheng
2018-03-21  2:54   ` Dong Aisheng
2018-03-21  2:54   ` Dong Aisheng
2018-03-21  2:54   ` Dong Aisheng
2018-03-21  2:54 ` [PATCH V2 4/4] video: simplefb: switch to use clk_bulk API to simplify clock operations Dong Aisheng
2018-03-21  2:54   ` Dong Aisheng
2018-03-21  2:54   ` Dong Aisheng
2018-03-21  2:54   ` Dong Aisheng
2018-03-25 16:29   ` kbuild test robot
2018-03-25 16:29     ` kbuild test robot
2018-03-25 16:29     ` kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=152182421754.178046.7553203878044979411@swboyd.mtv.corp.google.com \
    --to=sboyd@kernel.org \
    --cc=aisheng.dong@nxp.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.