Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: imu: inv_icm42600: Convert to uXX and sXX integer types

The driver code is full of intXX_t and uintXX_t types which is
not the pattern we use in the IIO subsystem. Switch the driver
to use kernel internal types for that. No functional changes.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://patch.msgid.link/20250616090423.575736-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Andy Shevchenko and committed by
Jonathan Cameron
a4135386 8540a6f9

+57 -57
+4 -4
drivers/iio/imu/inv_icm42600/inv_icm42600.h
··· 164 164 struct inv_icm42600_suspended suspended; 165 165 struct iio_dev *indio_gyro; 166 166 struct iio_dev *indio_accel; 167 - uint8_t buffer[2] __aligned(IIO_DMA_MINALIGN); 167 + u8 buffer[2] __aligned(IIO_DMA_MINALIGN); 168 168 struct inv_icm42600_fifo fifo; 169 169 struct { 170 - int64_t gyro; 171 - int64_t accel; 170 + s64 gyro; 171 + s64 accel; 172 172 } timestamp; 173 173 }; 174 174 ··· 410 410 inv_icm42600_get_mount_matrix(const struct iio_dev *indio_dev, 411 411 const struct iio_chan_spec *chan); 412 412 413 - uint32_t inv_icm42600_odr_to_period(enum inv_icm42600_odr odr); 413 + u32 inv_icm42600_odr_to_period(enum inv_icm42600_odr odr); 414 414 415 415 int inv_icm42600_set_accel_conf(struct inv_icm42600_state *st, 416 416 struct inv_icm42600_sensor_conf *conf,
+13 -13
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
··· 177 177 */ 178 178 struct inv_icm42600_accel_buffer { 179 179 struct inv_icm42600_fifo_sensor_data accel; 180 - int16_t temp; 180 + s16 temp; 181 181 aligned_s64 timestamp; 182 182 }; 183 183 ··· 241 241 242 242 static int inv_icm42600_accel_read_sensor(struct iio_dev *indio_dev, 243 243 struct iio_chan_spec const *chan, 244 - int16_t *val) 244 + s16 *val) 245 245 { 246 246 struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev); 247 247 struct inv_icm42600_sensor_state *accel_st = iio_priv(indio_dev); ··· 284 284 if (ret) 285 285 goto exit; 286 286 287 - *val = (int16_t)be16_to_cpup(data); 287 + *val = (s16)be16_to_cpup(data); 288 288 if (*val == INV_ICM42600_DATA_INVALID) 289 289 ret = -EINVAL; 290 290 exit: ··· 492 492 int *val, int *val2) 493 493 { 494 494 struct device *dev = regmap_get_device(st->map); 495 - int64_t val64; 496 - int32_t bias; 495 + s64 val64; 496 + s32 bias; 497 497 unsigned int reg; 498 - int16_t offset; 499 - uint8_t data[2]; 498 + s16 offset; 499 + u8 data[2]; 500 500 int ret; 501 501 502 502 if (chan->type != IIO_ACCEL) ··· 550 550 * result in micro (1000000) 551 551 * (offset * 5 * 9.806650 * 1000000) / 10000 552 552 */ 553 - val64 = (int64_t)offset * 5LL * 9806650LL; 553 + val64 = (s64)offset * 5LL * 9806650LL; 554 554 /* for rounding, add + or - divisor (10000) divided by 2 */ 555 555 if (val64 >= 0) 556 556 val64 += 10000LL / 2LL; ··· 568 568 int val, int val2) 569 569 { 570 570 struct device *dev = regmap_get_device(st->map); 571 - int64_t val64; 572 - int32_t min, max; 571 + s64 val64; 572 + s32 min, max; 573 573 unsigned int reg, regval; 574 - int16_t offset; 574 + s16 offset; 575 575 int ret; 576 576 577 577 if (chan->type != IIO_ACCEL) ··· 596 596 inv_icm42600_accel_calibbias[1]; 597 597 max = inv_icm42600_accel_calibbias[4] * 1000000L + 598 598 inv_icm42600_accel_calibbias[5]; 599 - val64 = (int64_t)val * 1000000LL + (int64_t)val2; 599 + val64 = (s64)val * 1000000LL + (s64)val2; 600 600 if (val64 < min || val64 > max) 601 601 return -EINVAL; 602 602 ··· 671 671 int *val, int *val2, long mask) 672 672 { 673 673 struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev); 674 - int16_t data; 674 + s16 data; 675 675 int ret; 676 676 677 677 switch (chan->type) {
+11 -11
drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
··· 26 26 #define INV_ICM42600_FIFO_HEADER_ODR_GYRO BIT(0) 27 27 28 28 struct inv_icm42600_fifo_1sensor_packet { 29 - uint8_t header; 29 + u8 header; 30 30 struct inv_icm42600_fifo_sensor_data data; 31 - int8_t temp; 31 + s8 temp; 32 32 } __packed; 33 33 #define INV_ICM42600_FIFO_1SENSOR_PACKET_SIZE 8 34 34 35 35 struct inv_icm42600_fifo_2sensors_packet { 36 - uint8_t header; 36 + u8 header; 37 37 struct inv_icm42600_fifo_sensor_data accel; 38 38 struct inv_icm42600_fifo_sensor_data gyro; 39 - int8_t temp; 39 + s8 temp; 40 40 __be16 timestamp; 41 41 } __packed; 42 42 #define INV_ICM42600_FIFO_2SENSORS_PACKET_SIZE 16 43 43 44 44 ssize_t inv_icm42600_fifo_decode_packet(const void *packet, const void **accel, 45 - const void **gyro, const int8_t **temp, 45 + const void **gyro, const s8 **temp, 46 46 const void **timestamp, unsigned int *odr) 47 47 { 48 48 const struct inv_icm42600_fifo_1sensor_packet *pack1 = packet; 49 49 const struct inv_icm42600_fifo_2sensors_packet *pack2 = packet; 50 - uint8_t header = *((const uint8_t *)packet); 50 + u8 header = *((const u8 *)packet); 51 51 52 52 /* FIFO empty */ 53 53 if (header & INV_ICM42600_FIFO_HEADER_MSG) { ··· 100 100 101 101 void inv_icm42600_buffer_update_fifo_period(struct inv_icm42600_state *st) 102 102 { 103 - uint32_t period_gyro, period_accel, period; 103 + u32 period_gyro, period_accel, period; 104 104 105 105 if (st->fifo.en & INV_ICM42600_SENSOR_GYRO) 106 106 period_gyro = inv_icm42600_odr_to_period(st->conf.gyro.odr); ··· 204 204 { 205 205 size_t packet_size, wm_size; 206 206 unsigned int wm_gyro, wm_accel, watermark; 207 - uint32_t period_gyro, period_accel, period; 208 - uint32_t latency_gyro, latency_accel, latency; 207 + u32 period_gyro, period_accel, period; 208 + u32 latency_gyro, latency_accel, latency; 209 209 bool restore; 210 210 __le16 raw_wm; 211 211 int ret; ··· 459 459 __be16 *raw_fifo_count; 460 460 ssize_t i, size; 461 461 const void *accel, *gyro, *timestamp; 462 - const int8_t *temp; 462 + const s8 *temp; 463 463 unsigned int odr; 464 464 int ret; 465 465 ··· 550 550 struct inv_icm42600_sensor_state *gyro_st = iio_priv(st->indio_gyro); 551 551 struct inv_icm42600_sensor_state *accel_st = iio_priv(st->indio_accel); 552 552 struct inv_sensors_timestamp *ts; 553 - int64_t gyro_ts, accel_ts; 553 + s64 gyro_ts, accel_ts; 554 554 int ret; 555 555 556 556 gyro_ts = iio_get_time_ns(st->indio_gyro);
+5 -5
drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h
··· 28 28 struct inv_icm42600_fifo { 29 29 unsigned int on; 30 30 unsigned int en; 31 - uint32_t period; 31 + u32 period; 32 32 struct { 33 33 unsigned int gyro; 34 34 unsigned int accel; ··· 41 41 size_t accel; 42 42 size_t total; 43 43 } nb; 44 - uint8_t data[2080] __aligned(IIO_DMA_MINALIGN); 44 + u8 data[2080] __aligned(IIO_DMA_MINALIGN); 45 45 }; 46 46 47 47 /* FIFO data packet */ ··· 52 52 } __packed; 53 53 #define INV_ICM42600_FIFO_DATA_INVALID -32768 54 54 55 - static inline int16_t inv_icm42600_fifo_get_sensor_data(__be16 d) 55 + static inline s16 inv_icm42600_fifo_get_sensor_data(__be16 d) 56 56 { 57 57 return be16_to_cpu(d); 58 58 } ··· 60 60 static inline bool 61 61 inv_icm42600_fifo_is_data_valid(const struct inv_icm42600_fifo_sensor_data *s) 62 62 { 63 - int16_t x, y, z; 63 + s16 x, y, z; 64 64 65 65 x = inv_icm42600_fifo_get_sensor_data(s->x); 66 66 y = inv_icm42600_fifo_get_sensor_data(s->y); ··· 75 75 } 76 76 77 77 ssize_t inv_icm42600_fifo_decode_packet(const void *packet, const void **accel, 78 - const void **gyro, const int8_t **temp, 78 + const void **gyro, const s8 **temp, 79 79 const void **timestamp, unsigned int *odr); 80 80 81 81 extern const struct iio_buffer_setup_ops inv_icm42600_buffer_ops;
+3 -3
drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
··· 103 103 EXPORT_SYMBOL_NS_GPL(inv_icm42600_spi_regmap_config, "IIO_ICM42600"); 104 104 105 105 struct inv_icm42600_hw { 106 - uint8_t whoami; 106 + u8 whoami; 107 107 const char *name; 108 108 const struct inv_icm42600_conf *conf; 109 109 }; ··· 188 188 return &st->orientation; 189 189 } 190 190 191 - uint32_t inv_icm42600_odr_to_period(enum inv_icm42600_odr odr) 191 + u32 inv_icm42600_odr_to_period(enum inv_icm42600_odr odr) 192 192 { 193 - static uint32_t odr_periods[INV_ICM42600_ODR_NB] = { 193 + static u32 odr_periods[INV_ICM42600_ODR_NB] = { 194 194 /* reserved values */ 195 195 0, 0, 0, 196 196 /* 8kHz */
+18 -18
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
··· 77 77 */ 78 78 struct inv_icm42600_gyro_buffer { 79 79 struct inv_icm42600_fifo_sensor_data gyro; 80 - int16_t temp; 80 + s16 temp; 81 81 aligned_s64 timestamp; 82 82 }; 83 83 ··· 139 139 140 140 static int inv_icm42600_gyro_read_sensor(struct inv_icm42600_state *st, 141 141 struct iio_chan_spec const *chan, 142 - int16_t *val) 142 + s16 *val) 143 143 { 144 144 struct device *dev = regmap_get_device(st->map); 145 145 struct inv_icm42600_sensor_conf conf = INV_ICM42600_SENSOR_CONF_INIT; ··· 179 179 if (ret) 180 180 goto exit; 181 181 182 - *val = (int16_t)be16_to_cpup(data); 182 + *val = (s16)be16_to_cpup(data); 183 183 if (*val == INV_ICM42600_DATA_INVALID) 184 184 ret = -EINVAL; 185 185 exit: ··· 399 399 int *val, int *val2) 400 400 { 401 401 struct device *dev = regmap_get_device(st->map); 402 - int64_t val64; 403 - int32_t bias; 402 + s64 val64; 403 + s32 bias; 404 404 unsigned int reg; 405 - int16_t offset; 406 - uint8_t data[2]; 405 + s16 offset; 406 + u8 data[2]; 407 407 int ret; 408 408 409 409 if (chan->type != IIO_ANGL_VEL) ··· 457 457 * result in nano (1000000000) 458 458 * (offset * 64 * Pi * 1000000000) / (2048 * 180) 459 459 */ 460 - val64 = (int64_t)offset * 64LL * 3141592653LL; 460 + val64 = (s64)offset * 64LL * 3141592653LL; 461 461 /* for rounding, add + or - divisor (2048 * 180) divided by 2 */ 462 462 if (val64 >= 0) 463 463 val64 += 2048 * 180 / 2; ··· 475 475 int val, int val2) 476 476 { 477 477 struct device *dev = regmap_get_device(st->map); 478 - int64_t val64, min, max; 478 + s64 val64, min, max; 479 479 unsigned int reg, regval; 480 - int16_t offset; 480 + s16 offset; 481 481 int ret; 482 482 483 483 if (chan->type != IIO_ANGL_VEL) ··· 498 498 } 499 499 500 500 /* inv_icm42600_gyro_calibbias: min - step - max in nano */ 501 - min = (int64_t)inv_icm42600_gyro_calibbias[0] * 1000000000LL + 502 - (int64_t)inv_icm42600_gyro_calibbias[1]; 503 - max = (int64_t)inv_icm42600_gyro_calibbias[4] * 1000000000LL + 504 - (int64_t)inv_icm42600_gyro_calibbias[5]; 505 - val64 = (int64_t)val * 1000000000LL + (int64_t)val2; 501 + min = (s64)inv_icm42600_gyro_calibbias[0] * 1000000000LL + 502 + (s64)inv_icm42600_gyro_calibbias[1]; 503 + max = (s64)inv_icm42600_gyro_calibbias[4] * 1000000000LL + 504 + (s64)inv_icm42600_gyro_calibbias[5]; 505 + val64 = (s64)val * 1000000000LL + (s64)val2; 506 506 if (val64 < min || val64 > max) 507 507 return -EINVAL; 508 508 ··· 577 577 int *val, int *val2, long mask) 578 578 { 579 579 struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev); 580 - int16_t data; 580 + s16 data; 581 581 int ret; 582 582 583 583 switch (chan->type) { ··· 803 803 ssize_t i, size; 804 804 unsigned int no; 805 805 const void *accel, *gyro, *timestamp; 806 - const int8_t *temp; 806 + const s8 *temp; 807 807 unsigned int odr; 808 - int64_t ts_val; 808 + s64 ts_val; 809 809 /* buffer is copied to userspace, zeroing it to avoid any data leak */ 810 810 struct inv_icm42600_gyro_buffer buffer = { }; 811 811
+3 -3
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c
··· 13 13 #include "inv_icm42600.h" 14 14 #include "inv_icm42600_temp.h" 15 15 16 - static int inv_icm42600_temp_read(struct inv_icm42600_state *st, int16_t *temp) 16 + static int inv_icm42600_temp_read(struct inv_icm42600_state *st, s16 *temp) 17 17 { 18 18 struct device *dev = regmap_get_device(st->map); 19 19 __be16 *raw; ··· 31 31 if (ret) 32 32 goto exit; 33 33 34 - *temp = (int16_t)be16_to_cpup(raw); 34 + *temp = (s16)be16_to_cpup(raw); 35 35 if (*temp == INV_ICM42600_DATA_INVALID) 36 36 ret = -EINVAL; 37 37 ··· 48 48 int *val, int *val2, long mask) 49 49 { 50 50 struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev); 51 - int16_t temp; 51 + s16 temp; 52 52 int ret; 53 53 54 54 if (chan->type != IIO_TEMP)