1 From 8f3d612a5c949489b2860b74ff34c5914a9216dd Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org>
3 Date: Wed, 2 Aug 2023 18:07:43 +0200
4 Subject: [PATCH 2/6] leds: turris-omnia: Drop unnecessary mutex locking
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Do not lock driver mutex in the global LED panel brightness sysfs
10 accessors brightness_show() and brightness_store().
12 The mutex locking is unnecessary here. The I2C transfers are guarded by
13 I2C core locking mechanism, and the LED commands itself do not interfere
16 Fixes: 089381b27abe ("leds: initial support for Turris Omnia LEDs")
17 Signed-off-by: Marek BehĂșn <kabel@kernel.org>
18 Reviewed-by: Lee Jones <lee@kernel.org>
19 Link: https://lore.kernel.org/r/20230802160748.11208-2-kabel@kernel.org
20 Signed-off-by: Lee Jones <lee@kernel.org>
22 drivers/leds/leds-turris-omnia.c | 11 +----------
23 1 file changed, 1 insertion(+), 10 deletions(-)
25 --- a/drivers/leds/leds-turris-omnia.c
26 +++ b/drivers/leds/leds-turris-omnia.c
27 @@ -156,12 +156,9 @@ static ssize_t brightness_show(struct de
30 struct i2c_client *client = to_i2c_client(dev);
31 - struct omnia_leds *leds = i2c_get_clientdata(client);
34 - mutex_lock(&leds->lock);
35 ret = i2c_smbus_read_byte_data(client, CMD_LED_GET_BRIGHTNESS);
36 - mutex_unlock(&leds->lock);
40 @@ -173,7 +170,6 @@ static ssize_t brightness_store(struct d
41 const char *buf, size_t count)
43 struct i2c_client *client = to_i2c_client(dev);
44 - struct omnia_leds *leds = i2c_get_clientdata(client);
45 unsigned long brightness;
48 @@ -183,15 +179,10 @@ static ssize_t brightness_store(struct d
52 - mutex_lock(&leds->lock);
53 ret = i2c_smbus_write_byte_data(client, CMD_LED_SET_BRIGHTNESS,
55 - mutex_unlock(&leds->lock);
61 + return ret < 0 ? ret : count;
63 static DEVICE_ATTR_RW(brightness);