* [PATCH] can: flexcan: Deferred on Regulator return EPROBE_DEFER
@ 2015-03-22 16:35 Andreas Werner
2015-03-22 17:23 ` Marc Kleine-Budde
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Werner @ 2015-03-22 16:35 UTC (permalink / raw)
To: Marc Kleine-Budde; +Cc: linux-can
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>
---
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.
---
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;
+ }
+
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);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] can: flexcan: Deferred on Regulator return EPROBE_DEFER
2015-03-22 16:35 [PATCH] can: flexcan: Deferred on Regulator return EPROBE_DEFER Andreas Werner
@ 2015-03-22 17:23 ` Marc Kleine-Budde
0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2015-03-22 17:23 UTC (permalink / raw)
To: Andreas Werner; +Cc: linux-can
[-- 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 --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-22 17:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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.