Skip to content

Commit 3814ca3

Browse files
Dan Murphymarckleinebudde
authored andcommitted
can: tcan4x5x: tcan4x5x_can_probe(): turn on the power before parsing the config
The tcan4x5x_parse_config() function now performs action on the device either reading or writing and a reset. If the devive has a switchable power supppy (i.e. regulator is managed) it needs to be turned on. So turn on the regulator if available. If the parsing fails, turn off the regulator. Fixes: 2de4973 ("can: tcan45x: Make wake-up GPIO an optional GPIO") Signed-off-by: Dan Murphy <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 3069ce6 commit 3814ca3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/net/can/m_can/tcan4x5x.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,6 @@ static int tcan4x5x_parse_config(struct m_can_classdev *cdev)
374374
if (IS_ERR(tcan4x5x->device_state_gpio))
375375
tcan4x5x->device_state_gpio = NULL;
376376

377-
tcan4x5x->power = devm_regulator_get_optional(cdev->dev,
378-
"vsup");
379-
if (PTR_ERR(tcan4x5x->power) == -EPROBE_DEFER)
380-
return -EPROBE_DEFER;
381-
382377
return 0;
383378
}
384379

@@ -412,6 +407,12 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
412407
if (!priv)
413408
return -ENOMEM;
414409

410+
priv->power = devm_regulator_get_optional(&spi->dev, "vsup");
411+
if (PTR_ERR(priv->power) == -EPROBE_DEFER)
412+
return -EPROBE_DEFER;
413+
else
414+
priv->power = NULL;
415+
415416
mcan_class->device_data = priv;
416417

417418
m_can_class_get_clocks(mcan_class);
@@ -451,11 +452,13 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
451452
priv->regmap = devm_regmap_init(&spi->dev, &tcan4x5x_bus,
452453
&spi->dev, &tcan4x5x_regmap);
453454

454-
ret = tcan4x5x_parse_config(mcan_class);
455+
ret = tcan4x5x_power_enable(priv->power, 1);
455456
if (ret)
456457
goto out_clk;
457458

458-
tcan4x5x_power_enable(priv->power, 1);
459+
ret = tcan4x5x_parse_config(mcan_class);
460+
if (ret)
461+
goto out_power;
459462

460463
ret = tcan4x5x_init(mcan_class);
461464
if (ret)

0 commit comments

Comments
 (0)