From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Amit Virdi <amit.virdi@st.com>
Cc: linux-can@vger.kernel.org, wg@grandegger.com,
bhupesh.sharma@st.com, anilkumar@ti.com, spear-devel@list.st.com
Subject: Re: [PATCH 3/3] can: c_can: Enable clock before first use
Date: Thu, 20 Dec 2012 15:07:18 +0100 [thread overview]
Message-ID: <50D31B96.8010501@pengutronix.de> (raw)
In-Reply-To: <3ce526df6a4f9e71f8b05132689db7426bae6bbb.1355996839.git.amit.virdi@st.com>
[-- Attachment #1: Type: text/plain, Size: 1890 bytes --]
On 12/20/2012 11:05 AM, Amit Virdi wrote:
> Current implementation assumes clock to be always enabled. Instead,
> explicitly enable device clock before usage.
>
> Signed-off-by: Amit Virdi <amit.virdi@st.com>
> Reviewed-by: Shiraz Hashim <shiraz.hashim@st.com>
> ---
> drivers/net/can/c_can/c_can_platform.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
> index 6e8dc56..d0bd6e6 100644
> --- a/drivers/net/can/c_can/c_can_platform.c
> +++ b/drivers/net/can/c_can/c_can_platform.c
> @@ -194,6 +194,12 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev)
> goto exit;
> }
>
> + ret = clk_prepare_enable(clk);
> + if (ret) {
> + dev_err(&pdev->dev, "could not prepare CAN clock\n");
> + goto exit_no_clk_en;
> + }
> +
> /* get the platform data */
> mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> irq = platform_get_irq(pdev, 0);
> @@ -295,6 +301,8 @@ exit_iounmap:
> exit_release_mem:
> release_mem_region(mem->start, resource_size(mem));
> exit_free_clk:
> + clk_disable_unprepare(clk);
> +exit_no_clk_en:
> clk_put(clk);
> exit:
> dev_err(&pdev->dev, "probe failed\n");
Why do you have to enable the clock if the driver is loaded? What about
disabling the clock on driver unload. The clock should be enabled on
open and disabled on close if the network interface. If you need to
access the registers of your hardware, you should enable the clock
before accessing the regs and disable the clock when finished.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]
next prev parent reply other threads:[~2012-12-20 14:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-20 10:05 [PATCH 0/3] c_can: Update can support Amit Virdi
2012-12-20 10:05 ` [PATCH 1/3] can: c_can: Correct register alignment info passing through DT Amit Virdi
2012-12-20 13:59 ` Marc Kleine-Budde
2013-01-16 7:40 ` Amit Virdi
2012-12-20 10:05 ` [PATCH 2/3] can: c_can: Provide generic interface to configure c-can message objects Amit Virdi
2012-12-20 10:26 ` Wolfgang Grandegger
2012-12-20 10:53 ` Amit Virdi
2012-12-20 11:06 ` Bhupesh SHARMA
2012-12-20 11:12 ` Wolfgang Grandegger
2012-12-20 11:18 ` Amit Virdi
2012-12-20 12:20 ` Wolfgang Grandegger
2012-12-20 14:04 ` Marc Kleine-Budde
2012-12-20 20:13 ` Wolfgang Grandegger
2013-01-16 7:45 ` Amit Virdi
2013-01-16 8:25 ` Bhupesh SHARMA
2013-01-16 9:01 ` Wolfgang Grandegger
2013-01-16 9:03 ` Wolfgang Grandegger
2013-01-16 9:11 ` Amit Virdi
2012-12-20 10:05 ` [PATCH 3/3] can: c_can: Enable clock before first use Amit Virdi
2012-12-20 14:07 ` Marc Kleine-Budde [this message]
2013-01-16 8:03 ` Amit Virdi
2013-01-16 9:54 ` AnilKumar, Chimata
2013-01-16 13:53 ` Rafael J. Wysocki
2012-12-20 13:57 ` [PATCH 0/3] c_can: Update can support Marc Kleine-Budde
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=50D31B96.8010501@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=amit.virdi@st.com \
--cc=anilkumar@ti.com \
--cc=bhupesh.sharma@st.com \
--cc=linux-can@vger.kernel.org \
--cc=spear-devel@list.st.com \
--cc=wg@grandegger.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 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).