iio: proximity: vcnl3020: add DMA safe buffer
Add DMA safe buffer for bulk transfers. Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com> Link: https://lore.kernel.org/r/20210722154420.915082-2-i.mikhaylov@yadro.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
9c6cd755b5
commit
f5e9e38e70
@ -57,12 +57,14 @@ static const int vcnl3020_prox_sampling_frequency[][2] = {
|
|||||||
* @dev: vcnl3020 device.
|
* @dev: vcnl3020 device.
|
||||||
* @rev: revision id.
|
* @rev: revision id.
|
||||||
* @lock: lock for protecting access to device hardware registers.
|
* @lock: lock for protecting access to device hardware registers.
|
||||||
|
* @buf: DMA safe __be16 buffer.
|
||||||
*/
|
*/
|
||||||
struct vcnl3020_data {
|
struct vcnl3020_data {
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
u8 rev;
|
u8 rev;
|
||||||
struct mutex lock;
|
struct mutex lock;
|
||||||
|
__be16 buf ____cacheline_aligned;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,7 +146,6 @@ static int vcnl3020_measure_proximity(struct vcnl3020_data *data, int *val)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
unsigned int reg;
|
unsigned int reg;
|
||||||
__be16 res;
|
|
||||||
|
|
||||||
mutex_lock(&data->lock);
|
mutex_lock(&data->lock);
|
||||||
|
|
||||||
@ -163,12 +164,12 @@ static int vcnl3020_measure_proximity(struct vcnl3020_data *data, int *val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* high & low result bytes read */
|
/* high & low result bytes read */
|
||||||
rc = regmap_bulk_read(data->regmap, VCNL_PS_RESULT_HI, &res,
|
rc = regmap_bulk_read(data->regmap, VCNL_PS_RESULT_HI, &data->buf,
|
||||||
sizeof(res));
|
sizeof(data->buf));
|
||||||
if (rc)
|
if (rc)
|
||||||
goto err_unlock;
|
goto err_unlock;
|
||||||
|
|
||||||
*val = be16_to_cpu(res);
|
*val = be16_to_cpu(data->buf);
|
||||||
|
|
||||||
err_unlock:
|
err_unlock:
|
||||||
mutex_unlock(&data->lock);
|
mutex_unlock(&data->lock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user