Skip to content

Commit a32d3f4

Browse files
Werner2005sashalevin
authored andcommitted
can: flexcan: Deferred on Regulator return EPROBE_DEFER
[ Upstream commit 555828e ] 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> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent 44d8cbe commit a32d3f4

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎drivers/net/can/flexcan.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,12 +1224,19 @@ static int flexcan_probe(struct platform_device *pdev)
12241224
const struct flexcan_devtype_data *devtype_data;
12251225
struct net_device *dev;
12261226
struct flexcan_priv *priv;
1227+
struct regulator *reg_xceiver;
12271228
struct resource *mem;
12281229
struct clk *clk_ipg = NULL, *clk_per = NULL;
12291230
void __iomem *base;
12301231
int err, irq;
12311232
u32 clock_freq = 0;
12321233

1234+
reg_xceiver = devm_regulator_get(&pdev->dev, "xceiver");
1235+
if (PTR_ERR(reg_xceiver) == -EPROBE_DEFER)
1236+
return -EPROBE_DEFER;
1237+
else if (IS_ERR(reg_xceiver))
1238+
reg_xceiver = NULL;
1239+
12331240
if (pdev->dev.of_node)
12341241
of_property_read_u32(pdev->dev.of_node,
12351242
"clock-frequency", &clock_freq);
@@ -1291,9 +1298,7 @@ static int flexcan_probe(struct platform_device *pdev)
12911298
priv->pdata = dev_get_platdata(&pdev->dev);
12921299
priv->devtype_data = devtype_data;
12931300

1294-
priv->reg_xceiver = devm_regulator_get(&pdev->dev, "xceiver");
1295-
if (IS_ERR(priv->reg_xceiver))
1296-
priv->reg_xceiver = NULL;
1301+
priv->reg_xceiver = reg_xceiver;
12971302

12981303
netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT);
12991304

0 commit comments

Comments
 (0)