Skip to content

Commit f1cb3d3

Browse files
Natália Salvino Andréjic23
authored andcommitted
iio: pressure: HID: hid-sensor-press: Refactor channel initialization
Replace the local press_adjust_channel_bit_mask() function with a compound literal for scan_type initialization to improve code readability. Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br> Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br> Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent 3390026 commit f1cb3d3

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

drivers/iio/pressure/hid-sensor-press.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* HID Sensors Driver
44
* Copyright (c) 2014, Intel Corporation.
55
*/
6+
#include <linux/bitops.h>
67
#include <linux/device.h>
78
#include <linux/platform_device.h>
89
#include <linux/module.h>
@@ -53,17 +54,6 @@ static const struct iio_chan_spec press_channels[] = {
5354

5455
};
5556

56-
/* Adjust channel real bits based on report descriptor */
57-
static void press_adjust_channel_bit_mask(struct iio_chan_spec *channels,
58-
int channel, int size)
59-
{
60-
channels[channel].scan_type.sign = 's';
61-
/* Real storage bits will change based on the report desc. */
62-
channels[channel].scan_type.realbits = size * 8;
63-
/* Maximum size of a sample to capture is u32 */
64-
channels[channel].scan_type.storagebits = sizeof(u32) * 8;
65-
}
66-
6757
/* Channel read_raw handler */
6858
static int press_read_raw(struct iio_dev *indio_dev,
6959
struct iio_chan_spec const *chan,
@@ -225,8 +215,11 @@ static int press_parse_report(struct platform_device *pdev,
225215
&st->press_attr);
226216
if (ret < 0)
227217
return ret;
228-
press_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_PRESSURE,
229-
st->press_attr.size);
218+
channels[CHANNEL_SCAN_INDEX_PRESSURE].scan_type = (struct iio_scan_type) {
219+
.format = 's',
220+
.realbits = BYTES_TO_BITS(st->press_attr.size),
221+
.storagebits = BITS_PER_TYPE(u32),
222+
};
230223

231224
dev_dbg(&pdev->dev, "press %x:%x\n", st->press_attr.index,
232225
st->press_attr.report_id);

0 commit comments

Comments
 (0)