Skip to content

Commit 760b6b7

Browse files
elkablolag-linaro
authored andcommitted
leds: turris-omnia: Drop unnecessary mutex locking
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: 089381b ("leds: initial support for Turris Omnia LEDs") Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Lee Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 72a2972 commit 760b6b7

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

drivers/leds/leds-turris-omnia.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,9 @@ static ssize_t brightness_show(struct device *dev, struct device_attribute *a,
156156
char *buf)
157157
{
158158
struct i2c_client *client = to_i2c_client(dev);
159-
struct omnia_leds *leds = i2c_get_clientdata(client);
160159
int ret;
161160

162-
mutex_lock(&leds->lock);
163161
ret = i2c_smbus_read_byte_data(client, CMD_LED_GET_BRIGHTNESS);
164-
mutex_unlock(&leds->lock);
165162

166163
if (ret < 0)
167164
return ret;
@@ -173,7 +170,6 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
173170
const char *buf, size_t count)
174171
{
175172
struct i2c_client *client = to_i2c_client(dev);
176-
struct omnia_leds *leds = i2c_get_clientdata(client);
177173
unsigned long brightness;
178174
int ret;
179175

@@ -183,15 +179,10 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
183179
if (brightness > 100)
184180
return -EINVAL;
185181

186-
mutex_lock(&leds->lock);
187182
ret = i2c_smbus_write_byte_data(client, CMD_LED_SET_BRIGHTNESS,
188183
(u8)brightness);
189-
mutex_unlock(&leds->lock);
190-
191-
if (ret < 0)
192-
return ret;
193184

194-
return count;
185+
return ret < 0 ? ret : count;
195186
}
196187
static DEVICE_ATTR_RW(brightness);
197188

0 commit comments

Comments
 (0)