mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-05 21:35:46 +02:00
firmware: tegra: bpmp: Use scoped device node handling to simplify error paths
Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Thierry Reding <treding@nvidia.com>
This commit is contained in:
parent
9c3a62c20f
commit
8812b8689e
|
@ -3,6 +3,7 @@
|
||||||
* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
|
* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/cleanup.h>
|
||||||
#include <linux/clk/tegra.h>
|
#include <linux/clk/tegra.h>
|
||||||
#include <linux/genalloc.h>
|
#include <linux/genalloc.h>
|
||||||
#include <linux/mailbox_client.h>
|
#include <linux/mailbox_client.h>
|
||||||
|
@ -34,29 +35,24 @@ channel_to_ops(struct tegra_bpmp_channel *channel)
|
||||||
|
|
||||||
struct tegra_bpmp *tegra_bpmp_get(struct device *dev)
|
struct tegra_bpmp *tegra_bpmp_get(struct device *dev)
|
||||||
{
|
{
|
||||||
|
struct device_node *np __free(device_node);
|
||||||
struct platform_device *pdev;
|
struct platform_device *pdev;
|
||||||
struct tegra_bpmp *bpmp;
|
struct tegra_bpmp *bpmp;
|
||||||
struct device_node *np;
|
|
||||||
|
|
||||||
np = of_parse_phandle(dev->of_node, "nvidia,bpmp", 0);
|
np = of_parse_phandle(dev->of_node, "nvidia,bpmp", 0);
|
||||||
if (!np)
|
if (!np)
|
||||||
return ERR_PTR(-ENOENT);
|
return ERR_PTR(-ENOENT);
|
||||||
|
|
||||||
pdev = of_find_device_by_node(np);
|
pdev = of_find_device_by_node(np);
|
||||||
if (!pdev) {
|
if (!pdev)
|
||||||
bpmp = ERR_PTR(-ENODEV);
|
return ERR_PTR(-ENODEV);
|
||||||
goto put;
|
|
||||||
}
|
|
||||||
|
|
||||||
bpmp = platform_get_drvdata(pdev);
|
bpmp = platform_get_drvdata(pdev);
|
||||||
if (!bpmp) {
|
if (!bpmp) {
|
||||||
bpmp = ERR_PTR(-EPROBE_DEFER);
|
|
||||||
put_device(&pdev->dev);
|
put_device(&pdev->dev);
|
||||||
goto put;
|
return ERR_PTR(-EPROBE_DEFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
put:
|
|
||||||
of_node_put(np);
|
|
||||||
return bpmp;
|
return bpmp;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(tegra_bpmp_get);
|
EXPORT_SYMBOL_GPL(tegra_bpmp_get);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user