linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v6 2/5] leds: Add helper for getting default pattern from Device Tree
Date: Mon, 7 Jan 2019 18:49:24 +0100	[thread overview]
Message-ID: <20190107174924.GD933@amd> (raw)
In-Reply-To: <1546596524-19863-3-git-send-email-krzk@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 1368 bytes --]

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.


>  /**
> + * 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".

									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2019-01-07 17:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-04 10:08 [PATCH v6 0/5] leds: trigger: Add pattern initialization from Device Tree Krzysztof Kozlowski
2019-01-04 10:08 ` [PATCH v6 1/5] dt-bindings: leds: " Krzysztof Kozlowski
2019-01-07 17:47   ` Pavel Machek
2019-01-04 10:08 ` [PATCH v6 2/5] leds: Add helper for getting default pattern " Krzysztof Kozlowski
2019-01-07 17:49   ` Pavel Machek [this message]
2019-01-09 14:03     ` Krzysztof Kozlowski
2019-01-04 10:08 ` [PATCH v6 3/5] leds: trigger: pattern: Add pattern initialization " Krzysztof Kozlowski
2019-01-04 10:08 ` [PATCH v6 4/5] leds: trigger: oneshot: Add " Krzysztof Kozlowski
2019-01-04 10:08 ` [PATCH v6 5/5] leds: trigger: timer: " Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190107174924.GD933@amd \
    --to=pavel@ucw.cz \
    --cc=devicetree@vger.kernel.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).