devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Emilio Lopez <emilio@elopez.com.ar>,
	Mike Turquette <mturquette@linaro.org>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	devicetree <devicetree@vger.kernel.org>,
	linux-sunxi@googlegroups.com
Subject: Re: [PATCH 1/9] clk: sunxi: Give sunxi_factors_register a registers parameter
Date: Fri, 21 Nov 2014 09:35:55 +0100	[thread overview]
Message-ID: <20141121083555.GK24143@lukather> (raw)
In-Reply-To: <1416498928-1300-2-git-send-email-hdegoede@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3783 bytes --]

Hi Hans,

On Thu, Nov 20, 2014 at 04:55:20PM +0100, Hans de Goede wrote:
> Before this commit sunxi_factors_register uses of_iomap(node, 0) to get
> the clk registers. The sun6i prcm has factor clocks, for which we want to
> use sunxi_factors_register, but of_iomap(node, 0) does not work for the prcm
> factor clocks, because the prcm uses the mfd framework, so the registers
> are not part of the dt-node, instead they are added to the platform_device,
> as platform_device resources.
> 
> This commit makes getting the registers the callers duty, so that
> sunxi_factors_register can be used with mfd instantiated platform device too.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Funny, I was thinking of doing exactly the same thing for MMC clocks :)

> ---
>  drivers/clk/sunxi/clk-factors.c    | 10 ++++------
>  drivers/clk/sunxi/clk-factors.h    |  7 ++++---
>  drivers/clk/sunxi/clk-mod0.c       |  6 ++++--
>  drivers/clk/sunxi/clk-sun8i-mbus.c |  2 +-
>  drivers/clk/sunxi/clk-sunxi.c      |  3 ++-
>  5 files changed, 15 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
> index f83ba09..fc4f4b5 100644
> --- a/drivers/clk/sunxi/clk-factors.c
> +++ b/drivers/clk/sunxi/clk-factors.c
> @@ -156,9 +156,10 @@ static const struct clk_ops clk_factors_ops = {
>  	.set_rate = clk_factors_set_rate,
>  };
>  
> -struct clk * __init sunxi_factors_register(struct device_node *node,
> -					   const struct factors_data *data,
> -					   spinlock_t *lock)
> +struct clk *sunxi_factors_register(struct device_node *node,
> +				   const struct factors_data *data,
> +				   spinlock_t *lock,
> +				   void __iomem *reg)
>  {
>  	struct clk *clk;
>  	struct clk_factors *factors;
> @@ -168,11 +169,8 @@ struct clk * __init sunxi_factors_register(struct device_node *node,
>  	struct clk_hw *mux_hw = NULL;
>  	const char *clk_name = node->name;
>  	const char *parents[FACTORS_MAX_PARENTS];
> -	void __iomem *reg;
>  	int i = 0;
>  
> -	reg = of_iomap(node, 0);
> -
>  	/* if we have a mux, we will have >1 parents */
>  	while (i < FACTORS_MAX_PARENTS &&
>  	       (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
> diff --git a/drivers/clk/sunxi/clk-factors.h b/drivers/clk/sunxi/clk-factors.h
> index 9913840..1f5526d 100644
> --- a/drivers/clk/sunxi/clk-factors.h
> +++ b/drivers/clk/sunxi/clk-factors.h
> @@ -37,8 +37,9 @@ struct clk_factors {
>  	spinlock_t *lock;
>  };
>  
> -struct clk * __init sunxi_factors_register(struct device_node *node,
> -					   const struct factors_data *data,
> -					   spinlock_t *lock);
> +struct clk *sunxi_factors_register(struct device_node *node,
> +				   const struct factors_data *data,
> +				   spinlock_t *lock,
> +				   void __iomem *reg);

Why are you dropping the __init there?

>  
>  #endif
> diff --git a/drivers/clk/sunxi/clk-mod0.c b/drivers/clk/sunxi/clk-mod0.c
> index 4a56385..9530833 100644
> --- a/drivers/clk/sunxi/clk-mod0.c
> +++ b/drivers/clk/sunxi/clk-mod0.c
> @@ -78,7 +78,8 @@ static DEFINE_SPINLOCK(sun4i_a10_mod0_lock);
>  
>  static void __init sun4i_a10_mod0_setup(struct device_node *node)
>  {
> -	sunxi_factors_register(node, &sun4i_a10_mod0_data, &sun4i_a10_mod0_lock);
> +	sunxi_factors_register(node, &sun4i_a10_mod0_data,
> +			       &sun4i_a10_mod0_lock, of_iomap(node, 0));

As of_iomap can fail, I'd rather check the returned value before
calling sunxi_factors_register.

I know it wasn't done before, but it's the right thing to do, as it
would lead to an instant crash if that fails.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2014-11-21  8:35 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20 15:55 [PATCH 0/9] sun6i / A31 ir receiver support Hans de Goede
     [not found] ` <1416498928-1300-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-20 15:55   ` [PATCH 1/9] clk: sunxi: Give sunxi_factors_register a registers parameter Hans de Goede
2014-11-21  8:35     ` Maxime Ripard [this message]
2014-11-21  8:44       ` Hans de Goede
     [not found]         ` <546EFB83.1020806-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-21 11:15           ` Maxime Ripard
2014-11-20 15:55   ` [PATCH 2/9] clk: sunxi: Make sun4i_a10_mod0_data available outside of clk-mod0.c Hans de Goede
2014-11-20 15:55   ` [PATCH 3/9] clk: sunxi: Add prcm mod0 clock driver Hans de Goede
     [not found]     ` <1416498928-1300-4-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-20 18:24       ` Chen-Yu Tsai
     [not found]         ` <CAGb2v66zoAy93mjZn+yf8zvCmkQ8AVWH92jKL-gyu90E5HLuuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-20 19:32           ` Hans de Goede
2014-11-21  8:49       ` Maxime Ripard
2014-11-21  9:13         ` Hans de Goede
     [not found]           ` <546F0226.2040700-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-24 22:03             ` Maxime Ripard
2014-11-25  8:29               ` Hans de Goede
     [not found]                 ` <54743DE1.7020704-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-25  8:37                   ` Hans de Goede
2014-11-26 21:13                   ` Maxime Ripard
2014-11-27  8:41                     ` Hans de Goede
     [not found]                       ` <5476E3A5.4000708-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-27  9:28                         ` Chen-Yu Tsai
     [not found]                           ` <CAGb2v652m0bCdPWFF4LWwjcrCJZvnLibFPw8xXJ3Q-Ge+_-p7g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-27 10:10                             ` Hans de Goede
     [not found]                               ` <5476F8AB.2000601-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-27 19:05                                 ` Maxime Ripard
2014-11-28 13:37                                   ` Hans de Goede
     [not found]                                     ` <54787A8A.6040209-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-12-02 15:45                                       ` Maxime Ripard
2014-12-03  9:49                                         ` Hans de Goede
     [not found]                                           ` <547EDCA0.4040805-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-12-07 18:08                                             ` Maxime Ripard
2014-12-08  8:19                                               ` Hans de Goede
     [not found]                                                 ` <54855EF6.1000900-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-12-09  8:51                                                   ` Maxime Ripard
2014-11-27 18:51                         ` Maxime Ripard
2014-11-27 16:40                     ` Boris Brezillon
2014-11-27 19:15                       ` Maxime Ripard
2014-11-20 15:55   ` [PATCH 4/9] rc: sunxi-cir: Add support for an optional reset controller Hans de Goede
2014-11-20 16:28     ` Mauro Carvalho Chehab
     [not found]       ` <20141120142831.003fb63e-+RedX5hVuTR+urZeOPWqwQ@public.gmane.org>
2014-11-21  8:51         ` Maxime Ripard
     [not found]     ` <1416498928-1300-5-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-20 23:05       ` Julian Calaby
2014-11-20 15:55   ` [PATCH 5/9] rc: sunxi-cir: Add support for the larger fifo found on sun5i and sun6i Hans de Goede
2014-11-20 16:28     ` Mauro Carvalho Chehab
2014-11-21  8:26       ` Maxime Ripard
2014-11-21  8:42         ` Hans de Goede
     [not found]           ` <546EFAE1.9050506-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-21  9:59             ` Maxime Ripard
2014-11-21 10:13               ` Hans de Goede
     [not found]                 ` <546F103D.6050004-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-23 15:47                   ` Maxime Ripard
2014-11-20 15:55   ` [PATCH 6/9] ARM: dts: sun6i: Add ir_clk node Hans de Goede
2014-11-20 15:55   ` [PATCH 7/9] ARM: dts: sun6i: Add ir node Hans de Goede
2014-11-20 15:55   ` [PATCH 8/9] ARM: dts: sun6i: Add pinmux settings for the ir pins Hans de Goede
2014-11-20 15:55   ` [PATCH 9/9] ARM: dts: sun6i: Enable ir receiver on the Mele M9 Hans de Goede

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=20141121083555.GK24143@lukather \
    --to=maxime.ripard@free-electrons.com \
    --cc=devicetree@vger.kernel.org \
    --cc=emilio@elopez.com.ar \
    --cc=hdegoede@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=mturquette@linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).