74bde4706d13eb1d24cfd64ab2fce748dcb2198f
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 815-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch
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
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Do not lock driver mutex in the global LED panel brightness sysfs
10 accessors brightness_show() and brightness_store().
11
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
14 with other commands.
15
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>
21 ---
22 drivers/leds/leds-turris-omnia.c | 11 +----------
23 1 file changed, 1 insertion(+), 10 deletions(-)
24
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
28 char *buf)
29 {
30 struct i2c_client *client = to_i2c_client(dev);
31 - struct omnia_leds *leds = i2c_get_clientdata(client);
32 int ret;
33
34 - mutex_lock(&leds->lock);
35 ret = i2c_smbus_read_byte_data(client, CMD_LED_GET_BRIGHTNESS);
36 - mutex_unlock(&leds->lock);
37
38 if (ret < 0)
39 return ret;
40 @@ -173,7 +170,6 @@ static ssize_t brightness_store(struct d
41 const char *buf, size_t count)
42 {
43 struct i2c_client *client = to_i2c_client(dev);
44 - struct omnia_leds *leds = i2c_get_clientdata(client);
45 unsigned long brightness;
46 int ret;
47
48 @@ -183,15 +179,10 @@ static ssize_t brightness_store(struct d
49 if (brightness > 100)
50 return -EINVAL;
51
52 - mutex_lock(&leds->lock);
53 ret = i2c_smbus_write_byte_data(client, CMD_LED_SET_BRIGHTNESS,
54 (u8)brightness);
55 - mutex_unlock(&leds->lock);
56
57 - if (ret < 0)
58 - return ret;
59 -
60 - return count;
61 + return ret < 0 ? ret : count;
62 }
63 static DEVICE_ATTR_RW(brightness);
64