Re: [PATCH v2] leds: triggers: Check return value of kobject_uevent_env()
From: Joe Perches
Date: Mon Sep 19 2016 - 06:19:23 EST
On Mon, 2016-09-19 at 12:05 +0200, Jacek Anaszewski wrote:
> Log error message if kobject_uevent_env() fails in led_trigger_set().
trivia:
> diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
[]
> @@ -141,7 +141,9 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
> if (event) {
> envp[0] = event;
> envp[1] = NULL;
> - kobject_uevent_env(&led_cdev->dev->kobj, KOBJ_CHANGE, envp);
> + if (kobject_uevent_env(&led_cdev->dev->kobj, KOBJ_CHANGE, envp))
> + dev_err(led_cdev->dev,
> + "led_trigger_set: Error sending uevent\n");
It is generally better to use %s, __func__ than to embed
a function name in the format string.
+ dev_err(led_cdev->dev, "%s: Error sending uevent\n",
+ __func__);
Then Function renaming and code refactoring is less
error prone.