mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-28 16:53:49 +00:00
regulator: max8997: 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://patch.msgid.link/20240814-cleanup-h-of-node-put-regulator-v1-3-87151088b883@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
f372c262d4
commit
ea13bd391d
@ -8,6 +8,7 @@
|
||||
// This driver is based on max8998.c
|
||||
|
||||
#include <linux/bug.h>
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/slab.h>
|
||||
@ -876,7 +877,7 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
|
||||
struct max8997_platform_data *pdata)
|
||||
{
|
||||
struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
|
||||
struct device_node *pmic_np, *regulators_np, *reg_np;
|
||||
struct device_node *pmic_np, *reg_np;
|
||||
struct max8997_regulator_data *rdata;
|
||||
unsigned int i, dvs_voltage_nr = 1;
|
||||
|
||||
@ -886,7 +887,8 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
regulators_np = of_get_child_by_name(pmic_np, "regulators");
|
||||
struct device_node *regulators_np __free(device_node) = of_get_child_by_name(pmic_np,
|
||||
"regulators");
|
||||
if (!regulators_np) {
|
||||
dev_err(&pdev->dev, "could not find regulators sub-node\n");
|
||||
return -EINVAL;
|
||||
@ -898,10 +900,8 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
|
||||
rdata = devm_kcalloc(&pdev->dev,
|
||||
pdata->num_regulators, sizeof(*rdata),
|
||||
GFP_KERNEL);
|
||||
if (!rdata) {
|
||||
of_node_put(regulators_np);
|
||||
if (!rdata)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
pdata->regulators = rdata;
|
||||
for_each_child_of_node(regulators_np, reg_np) {
|
||||
@ -922,7 +922,6 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
|
||||
rdata->reg_node = reg_np;
|
||||
rdata++;
|
||||
}
|
||||
of_node_put(regulators_np);
|
||||
|
||||
pdata->buck1_gpiodvs = of_property_read_bool(pmic_np, "max8997,pmic-buck1-uses-gpio-dvs");
|
||||
pdata->buck2_gpiodvs = of_property_read_bool(pmic_np, "max8997,pmic-buck2-uses-gpio-dvs");
|
||||
|
Loading…
Reference in New Issue
Block a user