[PATCH v4 2/4] leds: Add managed API to get a LED from a device driver

Tomi Valkeinen tomi.valkeinen at ti.com
Wed Jul 31 13:23:07 UTC 2019


On 17/07/2019 17:15, Jean-Jacques Hiblot wrote:

> +struct led_classdev *__must_check devm_led_get(struct device *dev,
> +					       int index)
> +{
> +	struct led_classdev *led;
> +	struct led_classdev **dr;
> +

Should you check here if dev->of_node == NULL? Or should of_led_get() 
check it.

> +	led = of_led_get(dev->of_node, index);
> +	if (IS_ERR(led))
> +		return led;
> +
> +	dr = devres_alloc(devm_led_release, sizeof(struct led_classdev *),
> +			  GFP_KERNEL);
> +	if (!dr) {
> +		led_put(led);
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	*dr = led;
> +	devres_add(dev, dr);
> +
> +	return led;
> +}

  Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


More information about the dri-devel mailing list