lkml.org 
[lkml]   [2019]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH v6 2/5] leds: Add helper for getting default pattern from Device Tree
    On Mon, 7 Jan 2019 at 18:49, Pavel Machek <pavel@ucw.cz> 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

    \
     
     \ /
      Last update: 2019-01-09 15:05    [W:2.430 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site