mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-06 22:05:22 +02:00
soc: qcom: ice: 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> Link: https://lore.kernel.org/r/20240813-b4-cleanup-h-of-node-put-other-v1-3-cfb67323a95c@linaro.org Signed-off-by: Bjorn Andersson <andersson@kernel.org>
This commit is contained in:
parent
c50203cbba
commit
877840f13b
|
@ -8,6 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/bitfield.h>
|
#include <linux/bitfield.h>
|
||||||
|
#include <linux/cleanup.h>
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/iopoll.h>
|
#include <linux/iopoll.h>
|
||||||
|
@ -265,7 +266,6 @@ struct qcom_ice *of_qcom_ice_get(struct device *dev)
|
||||||
{
|
{
|
||||||
struct platform_device *pdev = to_platform_device(dev);
|
struct platform_device *pdev = to_platform_device(dev);
|
||||||
struct qcom_ice *ice;
|
struct qcom_ice *ice;
|
||||||
struct device_node *node;
|
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
|
|
||||||
|
@ -292,15 +292,15 @@ struct qcom_ice *of_qcom_ice_get(struct device *dev)
|
||||||
* (legacy DT binding), then it must at least provide a phandle
|
* (legacy DT binding), then it must at least provide a phandle
|
||||||
* to the ICE devicetree node, otherwise ICE is not supported.
|
* to the ICE devicetree node, otherwise ICE is not supported.
|
||||||
*/
|
*/
|
||||||
node = of_parse_phandle(dev->of_node, "qcom,ice", 0);
|
struct device_node *node __free(device_node) = of_parse_phandle(dev->of_node,
|
||||||
|
"qcom,ice", 0);
|
||||||
if (!node)
|
if (!node)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pdev = of_find_device_by_node(node);
|
pdev = of_find_device_by_node(node);
|
||||||
if (!pdev) {
|
if (!pdev) {
|
||||||
dev_err(dev, "Cannot find device node %s\n", node->name);
|
dev_err(dev, "Cannot find device node %s\n", node->name);
|
||||||
ice = ERR_PTR(-EPROBE_DEFER);
|
return ERR_PTR(-EPROBE_DEFER);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ice = platform_get_drvdata(pdev);
|
ice = platform_get_drvdata(pdev);
|
||||||
|
@ -308,8 +308,7 @@ struct qcom_ice *of_qcom_ice_get(struct device *dev)
|
||||||
dev_err(dev, "Cannot get ice instance from %s\n",
|
dev_err(dev, "Cannot get ice instance from %s\n",
|
||||||
dev_name(&pdev->dev));
|
dev_name(&pdev->dev));
|
||||||
platform_device_put(pdev);
|
platform_device_put(pdev);
|
||||||
ice = ERR_PTR(-EPROBE_DEFER);
|
return ERR_PTR(-EPROBE_DEFER);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ice->link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER);
|
ice->link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER);
|
||||||
|
@ -321,9 +320,6 @@ struct qcom_ice *of_qcom_ice_get(struct device *dev)
|
||||||
ice = ERR_PTR(-EINVAL);
|
ice = ERR_PTR(-EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
of_node_put(node);
|
|
||||||
|
|
||||||
return ice;
|
return ice;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(of_qcom_ice_get);
|
EXPORT_SYMBOL_GPL(of_qcom_ice_get);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user