aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/iio/imu
diff options
context:
space:
mode:
authorNuno Sá <nuno.sa@analog.com>2020-04-13 10:24:42 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2020-04-25 16:10:44 +0100
commitb9c5eec725d67b548e4dfdc406d6ca2c6d30d1c2 (patch)
treeb73655984539cb5c215393087baf730a330073cd /drivers/iio/imu
parentiio: imu: adis: Add irq flag variable (diff)
downloadwireguard-linux-b9c5eec725d67b548e4dfdc406d6ca2c6d30d1c2.tar.xz
wireguard-linux-b9c5eec725d67b548e4dfdc406d6ca2c6d30d1c2.zip
iio: adis: Add adis_update_bits() APIs
This patch adds a `regmap_update_bits()` like API to the ADIS library. It provides locked and unlocked variant. Signed-off-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/imu')
-rw-r--r--drivers/iio/imu/adis.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/iio/imu/adis.c b/drivers/iio/imu/adis.c
index 2e7d0d337f8f..c539dfa3b8d3 100644
--- a/drivers/iio/imu/adis.c
+++ b/drivers/iio/imu/adis.c
@@ -223,6 +223,31 @@ int __adis_read_reg(struct adis *adis, unsigned int reg,
return ret;
}
EXPORT_SYMBOL_GPL(__adis_read_reg);
+/**
+ * __adis_update_bits_base() - ADIS Update bits function - Unlocked version
+ * @adis: The adis device
+ * @reg: The address of the lower of the two registers
+ * @mask: Bitmask to change
+ * @val: Value to be written
+ * @size: Size of the register to update
+ *
+ * Updates the desired bits of @reg in accordance with @mask and @val.
+ */
+int __adis_update_bits_base(struct adis *adis, unsigned int reg, const u32 mask,
+ const u32 val, u8 size)
+{
+ int ret;
+ u32 __val;
+
+ ret = __adis_read_reg(adis, reg, &__val, size);
+ if (ret)
+ return ret;
+
+ __val = (__val & ~mask) | (val & mask);
+
+ return __adis_write_reg(adis, reg, __val, size);
+}
+EXPORT_SYMBOL_GPL(__adis_update_bits_base);
#ifdef CONFIG_DEBUG_FS