On 19.07.2015 23:40, Jacek Anaszewski wrote: [...]
+/* Platform driver probe */ +static int powernv_led_probe(struct platform_device *pdev) +{ + int num_leds; + struct device_node *led_node; + struct powernv_leds_priv *priv; + + led_node = of_find_node_by_path("/ibm,opal/leds"); + if (!led_node) { + dev_err(&pdev->dev, + "%s: LED parent device node not found\n", __func__); + return -EINVAL; + } + + num_leds = powernv_leds_count(led_node); + if (num_leds <= 0) { + dev_err(&pdev->dev, + "%s: No location code found under LED node\n", + __func__); + return -EINVAL; + }You won't need to count the number of LEDs to register, just allocate memory for each LED during parsing with managed resource allocation API.
You can refer to drivers/leds/leds-bcm6328.c in order to gain full picture on how this can look like. struct powernv_led_data would have to carry the pointer to the new common struct. -- Best Regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-leds" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
