leds: sgm3140: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
This commit is contained in:
Krzysztof Kozlowski 2020-08-26 16:50:12 +02:00 коммит произвёл Pavel Machek
Родитель 7e8da60596
Коммит 4582e783a2
1 изменённых файлов: 9 добавлений и 18 удалений

Просмотреть файл

@ -195,30 +195,21 @@ static int sgm3140_probe(struct platform_device *pdev)
priv->flash_gpio = devm_gpiod_get(&pdev->dev, "flash", GPIOD_OUT_LOW); priv->flash_gpio = devm_gpiod_get(&pdev->dev, "flash", GPIOD_OUT_LOW);
ret = PTR_ERR_OR_ZERO(priv->flash_gpio); ret = PTR_ERR_OR_ZERO(priv->flash_gpio);
if (ret) { if (ret)
if (ret != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, ret,
dev_err(&pdev->dev, "Failed to request flash gpio\n");
"Failed to request flash gpio: %d\n", ret);
return ret;
}
priv->enable_gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW); priv->enable_gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW);
ret = PTR_ERR_OR_ZERO(priv->enable_gpio); ret = PTR_ERR_OR_ZERO(priv->enable_gpio);
if (ret) { if (ret)
if (ret != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, ret,
dev_err(&pdev->dev, "Failed to request enable gpio\n");
"Failed to request enable gpio: %d\n", ret);
return ret;
}
priv->vin_regulator = devm_regulator_get(&pdev->dev, "vin"); priv->vin_regulator = devm_regulator_get(&pdev->dev, "vin");
ret = PTR_ERR_OR_ZERO(priv->vin_regulator); ret = PTR_ERR_OR_ZERO(priv->vin_regulator);
if (ret) { if (ret)
if (ret != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, ret,
dev_err(&pdev->dev, "Failed to request regulator\n");
"Failed to request regulator: %d\n", ret);
return ret;
}
child_node = fwnode_get_next_available_child_node(pdev->dev.fwnode, child_node = fwnode_get_next_available_child_node(pdev->dev.fwnode,
NULL); NULL);