Hi,
On 24-03-2023 01:48 am, Christophe JAILLET wrote:
Le 23/03/2023 à 20:45, Naresh Solanki a écrit :
From: Patrick Rudolph <patrick.rudolph@xxxxxxxxxxxxx>
max597x is hot swap controller with indicator LED support.
This driver uses DT property to configure led during boot time &
also provide the LED control in sysfs.
Not sure if I get this right but if led setup fails of_node_put should be called.+static int max597x_led_probe(struct platform_device *pdev)
+{
+ struct device_node *np = dev_of_node(pdev->dev.parent);
+ struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
+ struct device_node *led_node;
+ struct device_node *child;
+ int ret = 0;
+
+ if (!regmap)
+ return -EPROBE_DEFER;
+
+ led_node = of_get_child_by_name(np, "leds");
+ if (!led_node)
+ return -ENODEV;
+
+ for_each_available_child_of_node(led_node, child) {
+ u32 reg;
+
+ if (of_property_read_u32(child, "reg", ®))
+ continue;
+
+ if (reg >= MAX597X_NUM_LEDS) {
+ dev_err(&pdev->dev, "invalid LED (%u >= %d)\n", reg,
+ MAX597X_NUM_LEDS);
+ continue;
+ }
+
+ ret = max597x_setup_led(&pdev->dev, regmap, child, reg);
+ if (ret < 0)
+ of_node_put(child);
This of_node_put() looks odd to me.
"return ret;" or "break;" missing ?Didn't add a break so that it can continue initializing remaining led if any.
+ }
+
+ return ret;
+}
+