Skip to content

Commit 78026a6

Browse files
larsclausenjic23
authored andcommitted
iio:imu:adis: Add debugfs register access support
Provide a IIO debugfs register access function for the ADIS library. This function can be used by individual drivers to allow raw register access via debugfs. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent 709ab36 commit 78026a6

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎drivers/iio/imu/adis.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,29 @@ int adis_read_reg_16(struct adis *adis, unsigned int reg, uint16_t *val)
135135
}
136136
EXPORT_SYMBOL_GPL(adis_read_reg_16);
137137

138+
#ifdef CONFIG_DEBUG_FS
139+
140+
int adis_debugfs_reg_access(struct iio_dev *indio_dev,
141+
unsigned int reg, unsigned int writeval, unsigned int *readval)
142+
{
143+
struct adis *adis = iio_device_get_drvdata(indio_dev);
144+
145+
if (readval) {
146+
uint16_t val16;
147+
int ret;
148+
149+
ret = adis_read_reg_16(adis, reg, &val16);
150+
*readval = val16;
151+
152+
return ret;
153+
} else {
154+
return adis_write_reg_16(adis, reg, writeval);
155+
}
156+
}
157+
EXPORT_SYMBOL(adis_debugfs_reg_access);
158+
159+
#endif
160+
138161
/**
139162
* adis_enable_irq() - Enable or disable data ready IRQ
140163
* @adis: The adis device

‎include/linux/iio/imu/adis.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,15 @@ static inline void adis_remove_trigger(struct adis *adis)
183183

184184
#endif /* CONFIG_IIO_BUFFER */
185185

186+
#ifdef CONFIG_DEBUG_FS
187+
188+
int adis_debugfs_reg_access(struct iio_dev *indio_dev,
189+
unsigned int reg, unsigned int writeval, unsigned int *readval);
190+
191+
#else
192+
193+
#define adis_debugfs_reg_access NULL
194+
195+
#endif
196+
186197
#endif

0 commit comments

Comments
 (0)