On Mon, 7 Jan 2019 at 18:49, Pavel Machek <pavel@xxxxxx> wrote: > > Hi! > > > Multiple LED triggers might need to access default pattern so add a > > helper for that. > > > > } > > EXPORT_SYMBOL_GPL(led_update_brightness); > > > > +u32 *led_get_default_pattern(struct led_classdev *led_cdev, unsigned int *size) > > +{ > > + struct device_node *np = dev_of_node(led_cdev->dev); > > + u32 *pattern; > > + int count; > > + > > + if (!np) > > + return NULL; > > + > > + count = of_property_count_u32_elems(np, "led-pattern"); > > + if (count < 0) > > + return NULL; > > + > > + pattern = kcalloc(count, sizeof(*pattern), GFP_KERNEL); > > + if (!pattern) > > + return NULL; > > + > > + if (of_property_read_u32_array(np, "led-pattern", pattern, count)) > > + goto err; > > Just kfree and return here. No need for goto if that is just one case. OK > > > > /** > > + * led_get_default_pattern - return default pattern > > + * > > + * @led_cdev: the LED to get default pattern for > > + * @size: pointer for storing the number of elements in returned array, > > + * modified only if return != NULL > > + * > > + * Return: Allocated array of integers with default pattern from DeviceTree > > + * or NULL. Caller is responsible for kfree(). > > + */ > > "DeviceTree" -> "device tree". Sure, thanks for the feedback! Best regards, Krzysztof