mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-07 22:34:18 +08:00
leds: turris-omnia: Drop unnecessary mutex locking
[ Upstream commit760b6b7925
] 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:089381b27a
("leds: initial support for Turris Omnia LEDs") Signed-off-by: Marek Behún <kabel@kernel.org> Reviewed-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230802160748.11208-2-kabel@kernel.org Signed-off-by: Lee Jones <lee@kernel.org> Stable-dep-of:6de283b96b
("leds: turris-omnia: Do not use SMBUS calls") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
c9a4f13c58
commit
aec3706971
@ -156,12 +156,9 @@ static ssize_t brightness_show(struct device *dev, struct device_attribute *a,
|
|||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct i2c_client *client = to_i2c_client(dev);
|
struct i2c_client *client = to_i2c_client(dev);
|
||||||
struct omnia_leds *leds = i2c_get_clientdata(client);
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&leds->lock);
|
|
||||||
ret = i2c_smbus_read_byte_data(client, CMD_LED_GET_BRIGHTNESS);
|
ret = i2c_smbus_read_byte_data(client, CMD_LED_GET_BRIGHTNESS);
|
||||||
mutex_unlock(&leds->lock);
|
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -173,7 +170,6 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
|
|||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct i2c_client *client = to_i2c_client(dev);
|
struct i2c_client *client = to_i2c_client(dev);
|
||||||
struct omnia_leds *leds = i2c_get_clientdata(client);
|
|
||||||
unsigned long brightness;
|
unsigned long brightness;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -183,15 +179,10 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
|
|||||||
if (brightness > 100)
|
if (brightness > 100)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&leds->lock);
|
|
||||||
ret = i2c_smbus_write_byte_data(client, CMD_LED_SET_BRIGHTNESS,
|
ret = i2c_smbus_write_byte_data(client, CMD_LED_SET_BRIGHTNESS,
|
||||||
(u8)brightness);
|
(u8)brightness);
|
||||||
mutex_unlock(&leds->lock);
|
|
||||||
|
|
||||||
if (ret < 0)
|
return ret < 0 ? ret : count;
|
||||||
return ret;
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR_RW(brightness);
|
static DEVICE_ATTR_RW(brightness);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user