4178f150d9fc4eb4241a3f64c5a4367db9963cdd
[openwrt/staging/robimarko.git] /
1 From 760b6b7925bf09491aafa4727eef74fc6bf738b0 Mon Sep 17 00:00:00 2001
2 From: Marek BehĂșn <kabel@kernel.org>
3 Date: Wed, 2 Aug 2023 18:07:43 +0200
4 Subject: 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 (limited to 'drivers/leds/leds-turris-omnia.c')
26
27 --- a/drivers/leds/leds-turris-omnia.c
28 +++ b/drivers/leds/leds-turris-omnia.c
29 @@ -156,12 +156,9 @@ static ssize_t brightness_show(struct de
30 char *buf)
31 {
32 struct i2c_client *client = to_i2c_client(dev);
33 - struct omnia_leds *leds = i2c_get_clientdata(client);
34 int ret;
35
36 - mutex_lock(&leds->lock);
37 ret = i2c_smbus_read_byte_data(client, CMD_LED_GET_BRIGHTNESS);
38 - mutex_unlock(&leds->lock);
39
40 if (ret < 0)
41 return ret;
42 @@ -173,7 +170,6 @@ static ssize_t brightness_store(struct d
43 const char *buf, size_t count)
44 {
45 struct i2c_client *client = to_i2c_client(dev);
46 - struct omnia_leds *leds = i2c_get_clientdata(client);
47 unsigned long brightness;
48 int ret;
49
50 @@ -183,15 +179,10 @@ static ssize_t brightness_store(struct d
51 if (brightness > 100)
52 return -EINVAL;
53
54 - mutex_lock(&leds->lock);
55 ret = i2c_smbus_write_byte_data(client, CMD_LED_SET_BRIGHTNESS,
56 (u8)brightness);
57 - mutex_unlock(&leds->lock);
58
59 - if (ret < 0)
60 - return ret;
61 -
62 - return count;
63 + return ret < 0 ? ret : count;
64 }
65 static DEVICE_ATTR_RW(brightness);
66