All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org>,
	linux-leds@vger.kernel.org
Cc: "Marek Behún" <kabel@kernel.org>
Subject: [PATCH v3 1/6] leds: turris-omnia: drop unnecessary mutex locking
Date: Wed,  2 Aug 2023 18:07:43 +0200	[thread overview]
Message-ID: <20230802160748.11208-2-kabel@kernel.org> (raw)
In-Reply-To: <20230802160748.11208-1-kabel@kernel.org>

Do not lock driver mutex in the global LED panel brightness sysfs
accessors brightness_show() and brightness_store().

The mutex locking is unnecessary here. The I2C transfers are guarded by
I2C core locking mechanism, and the LED commands itself do not interfere
with other commands.

Fixes: 089381b27abe ("leds: initial support for Turris Omnia LEDs")
Signed-off-by: Marek Behún <kabel@kernel.org>
---
 drivers/leds/leds-turris-omnia.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
index 64b2d7b6d3f3..bbd610100e41 100644
--- a/drivers/leds/leds-turris-omnia.c
+++ b/drivers/leds/leds-turris-omnia.c
@@ -156,12 +156,9 @@ static ssize_t brightness_show(struct device *dev, struct device_attribute *a,
 			       char *buf)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	struct omnia_leds *leds = i2c_get_clientdata(client);
 	int ret;
 
-	mutex_lock(&leds->lock);
 	ret = i2c_smbus_read_byte_data(client, CMD_LED_GET_BRIGHTNESS);
-	mutex_unlock(&leds->lock);
 
 	if (ret < 0)
 		return ret;
@@ -173,7 +170,6 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
 				const char *buf, size_t count)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	struct omnia_leds *leds = i2c_get_clientdata(client);
 	unsigned long brightness;
 	int ret;
 
@@ -183,15 +179,10 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
 	if (brightness > 100)
 		return -EINVAL;
 
-	mutex_lock(&leds->lock);
 	ret = i2c_smbus_write_byte_data(client, CMD_LED_SET_BRIGHTNESS,
 					(u8)brightness);
-	mutex_unlock(&leds->lock);
-
-	if (ret < 0)
-		return ret;
 
-	return count;
+	return ret < 0 ? ret : count;
 }
 static DEVICE_ATTR_RW(brightness);
 
-- 
2.41.0


  reply	other threads:[~2023-08-02 16:08 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-02 16:07 [PATCH v3 0/6] leds: turris-omnia: updates Marek Behún
2023-08-02 16:07 ` Marek Behún [this message]
2023-08-18  8:09   ` [PATCH v3 1/6] leds: turris-omnia: drop unnecessary mutex locking Lee Jones
2023-08-18  9:23   ` (subset) " Lee Jones
2023-08-02 16:07 ` [PATCH v3 2/6] leds: turris-omnia: do not use SMBUS calls Marek Behún
2023-08-18  8:08   ` Lee Jones
2023-08-21 10:01     ` Marek Behún
2023-08-21 12:45       ` Lee Jones
2023-08-02 16:07 ` [PATCH v3 3/6] leds: turris-omnia: use sysfs_emit() instead of sprintf() Marek Behún
2023-08-18  9:18   ` (subset) " Lee Jones
2023-08-02 16:07 ` [PATCH v3 4/6] leds: turris-omnia: make set_brightness() more efficient Marek Behún
2023-08-18  9:42   ` Lee Jones
2023-08-21 10:14     ` Marek Behún
2023-08-21 12:39       ` Lee Jones
2023-08-02 16:07 ` [PATCH v3 5/6] leds: turris-omnia: support HW controlled mode via private trigger Marek Behún
2023-08-02 16:13   ` Marek Behún
2023-08-18  8:00     ` Lee Jones
2023-08-18 21:12     ` Jacek Anaszewski
2023-08-21  8:15       ` Lee Jones
2023-08-18  9:09   ` Lee Jones
2023-08-21 10:34     ` Marek Behún
2023-08-21 12:36       ` Lee Jones
2023-08-02 16:07 ` [PATCH v3 6/6] leds: turris-omnia: add support for enabling/disabling HW gamma correction Marek Behún
2023-08-18 10:30   ` Lee Jones
2023-08-21 10:46     ` Marek Behún
2023-08-21 12:26       ` Lee Jones
2023-08-14  7:33 ` [PATCH v3 0/6] leds: turris-omnia: updates 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=20230802160748.11208-2-kabel@kernel.org \
    --to=kabel@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.