Skip to content

Commit e6cd877

Browse files
Natália Salvino Andréjic23
authored andcommitted
iio: light: HID: hid-sensor-prox: Refactor channel initialization
Replace the local prox_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 cded217 commit e6cd877

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

drivers/iio/light/hid-sensor-prox.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>
@@ -67,17 +68,6 @@ static const struct iio_chan_spec prox_channels[] = {
6768
PROX_CHANNEL(false, 0),
6869
};
6970

70-
/* Adjust channel real bits based on report descriptor */
71-
static void prox_adjust_channel_bit_mask(struct iio_chan_spec *channels,
72-
int channel, int size)
73-
{
74-
channels[channel].scan_type.sign = 's';
75-
/* Real storage bits will change based on the report desc. */
76-
channels[channel].scan_type.realbits = size * 8;
77-
/* Maximum size of a sample to capture is u32 */
78-
channels[channel].scan_type.storagebits = sizeof(u32) * 8;
79-
}
80-
8171
/* Channel read_raw handler */
8272
static int prox_read_raw(struct iio_dev *indio_dev,
8373
struct iio_chan_spec const *chan,
@@ -250,8 +240,11 @@ static int prox_parse_report(struct platform_device *pdev,
250240
st->scan_mask[0] |= BIT(index);
251241
channels[index] = prox_channels[i];
252242
channels[index].scan_index = index;
253-
prox_adjust_channel_bit_mask(channels, index,
254-
st->prox_attr[index].size);
243+
channels[index].scan_type = (struct iio_scan_type) {
244+
.format = 's',
245+
.realbits = BYTES_TO_BITS(st->prox_attr[index].size),
246+
.storagebits = BITS_PER_TYPE(u32),
247+
};
255248
dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr[index].index,
256249
st->prox_attr[index].report_id);
257250
st->scale_precision[index] =

0 commit comments

Comments
 (0)