All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: "Lothar Waßmann" <LW@KARO-electronics.de>
Cc: Hui Wang <jason77.wang@gmail.com>,
	Steffen Trumtrar <s.trumtrar@pengutronix.de>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	linux-can@vger.kernel.org, kernel@pengutronix.de,
	Shawn Guo <shawn.guo@linaro.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] can: flexcan: add 2nd clock to support imx53 and newer
Date: Wed, 18 Jul 2012 11:21:49 +0200	[thread overview]
Message-ID: <5006802D.8070707@pengutronix.de> (raw)
In-Reply-To: <20486.31827.477680.302450@ipc1.ka-ro>

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

On 07/18/2012 11:05 AM, Lothar Waßmann wrote:
> Hi,
> 
> Marc Kleine-Budde writes:
>> On 07/18/2012 04:12 AM, Hui Wang wrote:
>>> Marc Kleine-Budde wrote:
>>>> From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
>>>>
>>>> This patch add support for a second clock to the flexcan driver. On
>>>> modern
>>>> freescale ARM cores like the imx53 and imx6q two clocks ("ipg" and "per")
>>>> must be enabled in order to access the CAN core.
>>>> -        clock_freq = clk_get_rate(clk);
>>>>      }
>>>>  
>>>>      mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>> @@ -1039,7 +1052,8 @@ static int __devinit flexcan_probe(struct
>>>> platform_device *pdev)
>>>>          CAN_CTRLMODE_BERR_REPORTING;
>>>>      priv->base = base;
>>>>      priv->dev = dev;
>>>> -    priv->clk = clk;
>>>> +    priv->clk_ipg = clk_ipg;
>>>> +    priv->clk_per = clk_per;
>>>>      priv->pdata = pdev->dev.platform_data;
>>>>      priv->devtype_data = devtype_data;
>>>>  
>>>> @@ -1067,9 +1081,11 @@ static int __devinit flexcan_probe(struct
>>>> platform_device *pdev)
>>>>   failed_map:
>>>>      release_mem_region(mem->start, mem_size);
>>>>   failed_get:
>>>> -    if (clk)
>>>> -        clk_put(clk);
>>>>   failed_clock:
>>>> +    if (clk_per)
>>>>   
>>> Use if (!IS_ERR(clk_per))
>>
>> Yes, good catch.
>>
>> Is it allowed to call clk_put with a NULL pointer? Both clocks can be
>> NULL, if the frequency is defined via the device tree, this is case for
>> powerpc.
>>
> This has been discussed here already several times. Everything
> returned by clk_get() that does not satisfy the IS_ERR() check, is a
> valid clk cookie and can be used for the clk API calls.

I've switched to devm completely (see Patch v2), so the clk_put is obsolete.

In this particular driver the NULL pointer in question is not returned
via the clk_get(). On powerpc we don't use clk_get(), because it's not
working (AFIAK) on the p1010 (the powerpc arch that has a flexcan).

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: 262 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: mkl@pengutronix.de (Marc Kleine-Budde)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] can: flexcan: add 2nd clock to support imx53 and newer
Date: Wed, 18 Jul 2012 11:21:49 +0200	[thread overview]
Message-ID: <5006802D.8070707@pengutronix.de> (raw)
In-Reply-To: <20486.31827.477680.302450@ipc1.ka-ro>

On 07/18/2012 11:05 AM, Lothar Wa?mann wrote:
> Hi,
> 
> Marc Kleine-Budde writes:
>> On 07/18/2012 04:12 AM, Hui Wang wrote:
>>> Marc Kleine-Budde wrote:
>>>> From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
>>>>
>>>> This patch add support for a second clock to the flexcan driver. On
>>>> modern
>>>> freescale ARM cores like the imx53 and imx6q two clocks ("ipg" and "per")
>>>> must be enabled in order to access the CAN core.
>>>> -        clock_freq = clk_get_rate(clk);
>>>>      }
>>>>  
>>>>      mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>> @@ -1039,7 +1052,8 @@ static int __devinit flexcan_probe(struct
>>>> platform_device *pdev)
>>>>          CAN_CTRLMODE_BERR_REPORTING;
>>>>      priv->base = base;
>>>>      priv->dev = dev;
>>>> -    priv->clk = clk;
>>>> +    priv->clk_ipg = clk_ipg;
>>>> +    priv->clk_per = clk_per;
>>>>      priv->pdata = pdev->dev.platform_data;
>>>>      priv->devtype_data = devtype_data;
>>>>  
>>>> @@ -1067,9 +1081,11 @@ static int __devinit flexcan_probe(struct
>>>> platform_device *pdev)
>>>>   failed_map:
>>>>      release_mem_region(mem->start, mem_size);
>>>>   failed_get:
>>>> -    if (clk)
>>>> -        clk_put(clk);
>>>>   failed_clock:
>>>> +    if (clk_per)
>>>>   
>>> Use if (!IS_ERR(clk_per))
>>
>> Yes, good catch.
>>
>> Is it allowed to call clk_put with a NULL pointer? Both clocks can be
>> NULL, if the frequency is defined via the device tree, this is case for
>> powerpc.
>>
> This has been discussed here already several times. Everything
> returned by clk_get() that does not satisfy the IS_ERR() check, is a
> valid clk cookie and can be used for the clk API calls.

I've switched to devm completely (see Patch v2), so the clk_put is obsolete.

In this particular driver the NULL pointer in question is not returned
via the clk_get(). On powerpc we don't use clk_get(), because it's not
working (AFIAK) on the p1010 (the powerpc arch that has a flexcan).

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   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120718/34408bf6/attachment.sig>

  reply	other threads:[~2012-07-18  9:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-17 22:05 [PATCH] can: flexcan: add 2nd clock to support imx53 and newer Marc Kleine-Budde
2012-07-17 22:05 ` Marc Kleine-Budde
2012-07-18  2:12 ` Hui Wang
2012-07-18  2:12   ` Hui Wang
2012-07-18  8:37   ` Marc Kleine-Budde
2012-07-18  8:37     ` Marc Kleine-Budde
2012-07-18  8:48     ` Hui Wang
2012-07-18  8:48       ` Hui Wang
2012-07-18  8:49     ` Sascha Hauer
2012-07-18  8:49       ` Sascha Hauer
2012-07-18  9:05     ` Lothar Waßmann
2012-07-18  9:05       ` Lothar Waßmann
2012-07-18  9:21       ` Marc Kleine-Budde [this message]
2012-07-18  9:21         ` 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=5006802D.8070707@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=LW@KARO-electronics.de \
    --cc=jason77.wang@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-can@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=s.trumtrar@pengutronix.de \
    --cc=shawn.guo@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 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.