linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marek Behún" <marek.behun@nic.cz>
To: linux-leds@vger.kernel.org
Cc: "Pavel Machek" <pavel@ucw.cz>,
	jacek.anaszewski@gmail.com, "Dan Murphy" <dmurphy@ti.com>,
	"Ondřej Jirman" <megous@megous.com>,
	netdev@vger.kernel.org, "Russell King" <linux@armlinux.org.uk>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Gregory Clement" <gregory.clement@bootlin.com>,
	"Andrew Lunn" <andrew@lunn.ch>,
	linux-kernel@vger.kernel.org, "Marek Behún" <marek.behun@nic.cz>
Subject: [PATCH RFC leds + net-next 2/3] leds: trigger: return error value if .activate() failed
Date: Thu, 16 Jul 2020 19:17:29 +0200	[thread overview]
Message-ID: <20200716171730.13227-3-marek.behun@nic.cz> (raw)
In-Reply-To: <20200716171730.13227-1-marek.behun@nic.cz>

Currently when the .activate() method fails and returns a negative error
code while writing to the /sys/class/leds/<LED>/trigger file, the write
system call does not inform the user abouth this failure.

This patch fixes this.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/leds/led-triggers.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 81e758d5a048..804e0d624f47 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -40,7 +40,7 @@ ssize_t led_trigger_write(struct file *filp, struct kobject *kobj,
 	struct device *dev = kobj_to_dev(kobj);
 	struct led_classdev *led_cdev = dev_get_drvdata(dev);
 	struct led_trigger *trig;
-	int ret = count;
+	int ret;
 
 	mutex_lock(&led_cdev->led_access);
 
@@ -58,7 +58,7 @@ ssize_t led_trigger_write(struct file *filp, struct kobject *kobj,
 	list_for_each_entry(trig, &trigger_list, next_trig) {
 		if (sysfs_streq(buf, trig->name) && trigger_relevant(led_cdev, trig)) {
 			down_write(&led_cdev->trigger_lock);
-			led_trigger_set(led_cdev, trig);
+			ret = led_trigger_set(led_cdev, trig);
 			up_write(&led_cdev->trigger_lock);
 
 			up_read(&triggers_list_lock);
@@ -71,7 +71,7 @@ ssize_t led_trigger_write(struct file *filp, struct kobject *kobj,
 
 unlock:
 	mutex_unlock(&led_cdev->led_access);
-	return ret;
+	return ret < 0 ? ret : count;
 }
 EXPORT_SYMBOL_GPL(led_trigger_write);
 
-- 
2.26.2


  parent reply	other threads:[~2020-07-16 17:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16 17:17 [PATCH RFC leds + net-next 0/3] Add support for LEDs on Marvell PHYs Marek Behún
2020-07-16 17:17 ` [PATCH RFC leds + net-next 1/3] leds: trigger: add support for LED-private device triggers Marek Behún
2020-07-20 11:20   ` Pavel Machek
2020-07-20 19:14   ` Jacek Anaszewski
2020-07-21 20:54     ` Pavel Machek
2020-07-16 17:17 ` Marek Behún [this message]
2020-07-20 11:17   ` [PATCH RFC leds + net-next 2/3] leds: trigger: return error value if .activate() failed Pavel Machek
2020-07-16 17:17 ` [PATCH RFC leds + net-next 3/3] net: phy: marvell: add support for PHY LEDs via LED class Marek Behún
2020-07-16 17:30 ` [PATCH RFC leds + net-next 0/3] Add support for LEDs on Marvell PHYs Ondřej Jirman
2020-07-16 18:56 ` Andrew Lunn
2020-07-23 12:41   ` Marek Behún

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=20200716171730.13227-3-marek.behun@nic.cz \
    --to=marek.behun@nic.cz \
    --cc=andrew@lunn.ch \
    --cc=dmurphy@ti.com \
    --cc=gregory.clement@bootlin.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=megous@megous.com \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=thomas.petazzoni@bootlin.com \
    /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).