From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Andreas Werner <kernel@andy89.org>
Cc: linux-can@vger.kernel.org
Subject: Re: [PATCH] can: flexcan: Deferred on Regulator return EPROBE_DEFER
Date: Sun, 22 Mar 2015 18:23:16 +0100 [thread overview]
Message-ID: <550EFA84.7010409@pengutronix.de> (raw)
In-Reply-To: <CAB4L-ghK_dzo-G_81LwjLh8oJxm6pzWkO4_8fZ6auUbycXF_4A@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3208 bytes --]
On 03/22/2015 05:35 PM, Andreas Werner wrote:
> Return EPROBE_DEFER if Regulator returns EPROBE_DEFER
>
> If the Flexcan driver is built into kernel and a regulator is used to
> enable the CAN transceiver, the Flexcan driver may not use the regulator.
>
> When initializing the Flexcan device with a regulator defined in the device
> tree, but not initialized, the regulator subsystem returns EPROBE_DEFER, hence
> the Flexcan init fails.
>
> The solution for this is to return EPROBE_DEFER if regulator is not initialized
> and wait until the regulator is initialized.
>
> Signed-off-by: Andreas Werner <kernel@andy89.org>
Applied to can, with some minor changes.
> ---
> I tested this Patch on a self made Freescale Vybrid VF610 board we developed in
> the Formula Student Team of the UaS RheinMain. I think this Patch is working on
> all other SoC with a Flexcan Controller. I tested it with the head rev of
> linux-can and linux 3.19.2.
>
> Since this is my first patch for the Linux Kernel, please tell me if
> there are formal
> failures.
No failures, but you can improve things. Please use git send-email to
post your patches, as your MUA, which is probably google, converts the
tabs into spaces, so that the patch doesn't apply anymore.
> ---
> drivers/net/can/flexcan.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> index b1d583b..c575163 100644
> --- a/drivers/net/can/flexcan.c
> +++ b/drivers/net/can/flexcan.c
> @@ -1164,11 +1164,19 @@ static int flexcan_probe(struct platform_device *pdev)
> void __iomem *base;
> int err, irq;
> u32 clock_freq = 0;
> + struct regulator *reg_xceiver = NULL;
>
> if (pdev->dev.of_node)
> of_property_read_u32(pdev->dev.of_node,
> "clock-frequency", &clock_freq);
>
> + reg_xceiver = devm_regulator_get(&pdev->dev, "xceiver");
> + if (PTR_ERR(reg_xceiver) == -EPROBE_DEFER) {
> + return -EPROBE_DEFER;
> + } else if (IS_ERR(reg_xceiver)) {
> + reg_xceiver = NULL;
> + }
I've moved this in front of the of_property_read_u32, as I don't want to
tear the clock handling apart. Further I've removed the curly braces.
> +
> if (!clock_freq) {
> clk_ipg = devm_clk_get(&pdev->dev, "ipg");
> if (IS_ERR(clk_ipg)) {
> @@ -1225,10 +1233,7 @@ static int flexcan_probe(struct platform_device *pdev)
> priv->clk_per = clk_per;
> priv->pdata = dev_get_platdata(&pdev->dev);
> priv->devtype_data = devtype_data;
> -
> - priv->reg_xceiver = devm_regulator_get(&pdev->dev, "xceiver");
> - if (IS_ERR(priv->reg_xceiver))
> - priv->reg_xceiver = NULL;
> + priv->reg_xceiver = reg_xceiver;
>
> netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT);
>
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: 819 bytes --]
prev parent reply other threads:[~2015-03-22 17:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-22 16:35 [PATCH] can: flexcan: Deferred on Regulator return EPROBE_DEFER Andreas Werner
2015-03-22 17:23 ` Marc Kleine-Budde [this message]
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=550EFA84.7010409@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=kernel@andy89.org \
--cc=linux-can@vger.kernel.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.