iio: st_sensors: Add a local lock for protecting odr
[ Upstream commit 474010127e2505fc463236470908e1ff5ddb3578 ] Right now the (framework) mlock lock is (ab)used for multiple purposes: 1- protecting concurrent accesses over the odr local cache 2- avoid changing samplig frequency whilst buffer is running Let's start by handling situation #1 with a local lock. Suggested-by: Jonathan Cameron <jic23@kernel.org> Cc: Denis Ciocca <denis.ciocca@st.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/r/20220207143840.707510-7-miquel.raynal@bootlin.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
5a89a92efc
commit
7821d743ab
@@ -228,6 +228,7 @@ struct st_sensor_settings {
|
||||
* @hw_irq_trigger: if we're using the hardware interrupt on the sensor.
|
||||
* @hw_timestamp: Latest timestamp from the interrupt handler, when in use.
|
||||
* @buffer_data: Data used by buffer part.
|
||||
* @odr_lock: Local lock for preventing concurrent ODR accesses/changes
|
||||
*/
|
||||
struct st_sensor_data {
|
||||
struct device *dev;
|
||||
@@ -253,6 +254,8 @@ struct st_sensor_data {
|
||||
s64 hw_timestamp;
|
||||
|
||||
char buffer_data[ST_SENSORS_MAX_BUFFER_SIZE] ____cacheline_aligned;
|
||||
|
||||
struct mutex odr_lock;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_IIO_BUFFER
|
||||
|
||||
Reference in New Issue
Block a user