mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
i3c: master: Update dev_nack_retry_count under maintenance lock
Protect master->dev_nack_retry_count against concurrent sysfs updates
by updating it while holding the bus maintenance lock.
Consequently, combine adjacent return statements into one.
For consistency, read dev_nack_retry_count while holding the bus normaluse
lock.
Fixes: b58f47eb39 ("i3c: add sysfs entry and attribute for Device NACK Retry count")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260616113752.196140-2-adrian.hunter@intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
parent
8d8afa4283
commit
ab5f9c5cb5
|
|
@ -744,7 +744,14 @@ static DEVICE_ATTR_RW(hotjoin);
|
|||
static ssize_t dev_nack_retry_count_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
return sysfs_emit(buf, "%u\n", dev_to_i3cmaster(dev)->dev_nack_retry_count);
|
||||
struct i3c_bus *i3cbus = dev_to_i3cbus(dev);
|
||||
ssize_t ret;
|
||||
|
||||
i3c_bus_normaluse_lock(i3cbus);
|
||||
ret = sysfs_emit(buf, "%u\n", dev_to_i3cmaster(dev)->dev_nack_retry_count);
|
||||
i3c_bus_normaluse_unlock(i3cbus);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t dev_nack_retry_count_store(struct device *dev,
|
||||
|
|
@ -762,14 +769,11 @@ static ssize_t dev_nack_retry_count_store(struct device *dev,
|
|||
|
||||
i3c_bus_maintenance_lock(i3cbus);
|
||||
ret = master->ops->set_dev_nack_retry(master, val);
|
||||
if (!ret)
|
||||
master->dev_nack_retry_count = val;
|
||||
i3c_bus_maintenance_unlock(i3cbus);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
master->dev_nack_retry_count = val;
|
||||
|
||||
return count;
|
||||
return ret ?: count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR_RW(dev_nack_retry_count);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user