mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Sanchayan Maity <maitysanchayan@gmail.com>
Cc: a.zummo@towertech.it, rtc-linux@googlegroups.com,
	stefan@agner.ch, shawn.guo@linaro.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCHv2] drivers/rtc/rtc-snvs: Add clock support
Date: Thu, 4 Dec 2014 16:12:07 -0800	[thread overview]
Message-ID: <20141204161207.0753031dc675793e9534c1de@linux-foundation.org> (raw)
In-Reply-To: <bf8571fc7474877be39a5a4e9d4705358e63d840.1417585458.git.maitysanchayan@gmail.com>

On Wed,  3 Dec 2014 11:28:55 +0530 Sanchayan Maity <maitysanchayan@gmail.com> wrote:

> This patch adds clock enable and disable support for
> the SNVS peripheral, which is required for using the
> RTC within the SNVS block.
> 
> The clock is not strictly enforced, as this would
> break the i.MX devices. The clocking for the i.MX
> devices seems to be enabled elsewhere and enabling
> RTC SNVS for Vybrid results in a crash. This patch
> adds the clock support but also makes it optional
> so Vybrid platform can use the clock if defined
> while making sure not to break i.MX .
> 
> ...

I assume this hasn't been tested with CONFIG_HAVE_CLK=n.  It all
*looks* OK, but the clk API does its tests for clk==NULL in some very
deep places.

> --- a/drivers/rtc/rtc-snvs.c
> +++ b/drivers/rtc/rtc-snvs.c
.
> ...
>
> @@ -288,10 +302,16 @@ static int snvs_rtc_probe(struct platform_device *pdev)
>  	if (IS_ERR(data->rtc)) {
>  		ret = PTR_ERR(data->rtc);
>  		dev_err(&pdev->dev, "failed to register rtc: %d\n", ret);
> -		return ret;
> +		goto error_rtc_device_register;
>  	}
>  
>  	return 0;
> +
> +error_rtc_device_register:
> +	if (data->clk)
> +		clk_disable_unprepare(data->clk);

>From my reading, there's no need to test data->clk here -
clk_disable_unprepare() handles that.

It doesn't hurt to test it - a reasonable approach would be to look
around at what other users of the clk API are doing, and do that.


> +	return ret;
>  }
>  
>  #ifdef CONFIG_PM_SLEEP
> @@ -302,16 +322,26 @@ static int snvs_rtc_suspend(struct device *dev)
>  	if (device_may_wakeup(dev))
>  		enable_irq_wake(data->irq);
>  
> +	if (data->clk)
> +		clk_disable_unprepare(data->clk);

Ditto.

>  	return 0;
>  }
>  
>  static int snvs_rtc_resume(struct device *dev)
>  {
>  	struct snvs_rtc_data *data = dev_get_drvdata(dev);
> +	int ret;
>  
>  	if (device_may_wakeup(dev))
>  		disable_irq_wake(data->irq);
>  
> +	if (data->clk) {
> +		ret = clk_prepare_enable(data->clk);
> +		if (ret)
> +			return ret;
> +	}

It could be omitted here also.

>  	return 0;
>  }
>  #endif


  parent reply	other threads:[~2014-12-05  0:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-03  5:58 [RESEND PATCHv2] Add SNVS clock support to rtc-snvs driver Sanchayan Maity
2014-12-03  5:58 ` [RESEND PATCHv2] drivers/rtc/rtc-snvs: Add clock support Sanchayan Maity
2014-12-04  9:36   ` Stefan Agner
2014-12-04 10:05   ` Alessandro Zummo
2014-12-04 12:29     ` Stefan Agner
2014-12-04 16:54       ` Alessandro Zummo
2014-12-05  0:12   ` Andrew Morton [this message]
2014-12-05 14:54     ` Stefan Agner
2014-12-05 21:44       ` Andrew Morton

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=20141204161207.0753031dc675793e9534c1de@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=a.zummo@towertech.it \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maitysanchayan@gmail.com \
    --cc=rtc-linux@googlegroups.com \
    --cc=shawn.guo@linaro.org \
    --cc=stefan@agner.ch \
    /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

all inboxes | Powered by JetHome®