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: adc: ad7606: rename chan_scale to a more generic chan_info

Non functional, renaming chan-related chan_scale structure to a more
generic chan_info, to host other chan specific settings, not just
scale-related.

Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20250606-wip-bl-ad7606-calibration-v9-6-6e014a1f92a2@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Angelo Dureghello and committed by
Jonathan Cameron
cc2eca43 9dc4ef3a

+75 -75
+71 -71
drivers/iio/adc/ad7606.c
··· 283 283 struct iio_chan_spec *chan) 284 284 { 285 285 struct ad7606_state *st = iio_priv(indio_dev); 286 - struct ad7606_chan_scale *cs = &st->chan_scales[chan->scan_index]; 286 + struct ad7606_chan_info *ci = &st->chan_info[chan->scan_index]; 287 287 288 288 if (!st->sw_mode_en) { 289 289 /* tied to logic low, analog input range is +/- 5V */ 290 - cs->range = 0; 291 - cs->scale_avail = ad7606_16bit_hw_scale_avail; 292 - cs->num_scales = ARRAY_SIZE(ad7606_16bit_hw_scale_avail); 290 + ci->range = 0; 291 + ci->scale_avail = ad7606_16bit_hw_scale_avail; 292 + ci->num_scales = ARRAY_SIZE(ad7606_16bit_hw_scale_avail); 293 293 return 0; 294 294 } 295 295 296 296 /* Scale of 0.076293 is only available in sw mode */ 297 297 /* After reset, in software mode, ±10 V is set by default */ 298 - cs->range = 2; 299 - cs->scale_avail = ad7606_16bit_sw_scale_avail; 300 - cs->num_scales = ARRAY_SIZE(ad7606_16bit_sw_scale_avail); 298 + ci->range = 2; 299 + ci->scale_avail = ad7606_16bit_sw_scale_avail; 300 + ci->num_scales = ARRAY_SIZE(ad7606_16bit_sw_scale_avail); 301 301 302 302 return 0; 303 303 } ··· 359 359 struct iio_chan_spec *chan) 360 360 { 361 361 struct ad7606_state *st = iio_priv(indio_dev); 362 - struct ad7606_chan_scale *cs = &st->chan_scales[chan->scan_index]; 362 + struct ad7606_chan_info *ci = &st->chan_info[chan->scan_index]; 363 363 bool bipolar, differential; 364 364 int ret; 365 365 366 366 if (!st->sw_mode_en) { 367 - cs->range = 0; 368 - cs->scale_avail = ad7606_18bit_hw_scale_avail; 369 - cs->num_scales = ARRAY_SIZE(ad7606_18bit_hw_scale_avail); 367 + ci->range = 0; 368 + ci->scale_avail = ad7606_18bit_hw_scale_avail; 369 + ci->num_scales = ARRAY_SIZE(ad7606_18bit_hw_scale_avail); 370 370 return 0; 371 371 } 372 372 ··· 376 376 return ret; 377 377 378 378 if (differential) { 379 - cs->scale_avail = ad7606c_18bit_differential_bipolar_scale_avail; 380 - cs->num_scales = 379 + ci->scale_avail = ad7606c_18bit_differential_bipolar_scale_avail; 380 + ci->num_scales = 381 381 ARRAY_SIZE(ad7606c_18bit_differential_bipolar_scale_avail); 382 382 /* Bipolar differential ranges start at 8 (b1000) */ 383 - cs->reg_offset = 8; 384 - cs->range = 1; 383 + ci->reg_offset = 8; 384 + ci->range = 1; 385 385 chan->differential = 1; 386 386 chan->channel2 = chan->channel; 387 387 ··· 391 391 chan->differential = 0; 392 392 393 393 if (bipolar) { 394 - cs->scale_avail = ad7606c_18bit_single_ended_bipolar_scale_avail; 395 - cs->num_scales = 394 + ci->scale_avail = ad7606c_18bit_single_ended_bipolar_scale_avail; 395 + ci->num_scales = 396 396 ARRAY_SIZE(ad7606c_18bit_single_ended_bipolar_scale_avail); 397 397 /* Bipolar single-ended ranges start at 0 (b0000) */ 398 - cs->reg_offset = 0; 399 - cs->range = 3; 398 + ci->reg_offset = 0; 399 + ci->range = 3; 400 400 chan->scan_type.sign = 's'; 401 401 402 402 return 0; 403 403 } 404 404 405 - cs->scale_avail = ad7606c_18bit_single_ended_unipolar_scale_avail; 406 - cs->num_scales = 405 + ci->scale_avail = ad7606c_18bit_single_ended_unipolar_scale_avail; 406 + ci->num_scales = 407 407 ARRAY_SIZE(ad7606c_18bit_single_ended_unipolar_scale_avail); 408 408 /* Unipolar single-ended ranges start at 5 (b0101) */ 409 - cs->reg_offset = 5; 410 - cs->range = 1; 409 + ci->reg_offset = 5; 410 + ci->range = 1; 411 411 chan->scan_type.sign = 'u'; 412 412 413 413 return 0; ··· 417 417 struct iio_chan_spec *chan) 418 418 { 419 419 struct ad7606_state *st = iio_priv(indio_dev); 420 - struct ad7606_chan_scale *cs = &st->chan_scales[chan->scan_index]; 420 + struct ad7606_chan_info *ci = &st->chan_info[chan->scan_index]; 421 421 bool bipolar, differential; 422 422 int ret; 423 423 424 424 if (!st->sw_mode_en) { 425 - cs->range = 0; 426 - cs->scale_avail = ad7606_16bit_hw_scale_avail; 427 - cs->num_scales = ARRAY_SIZE(ad7606_16bit_hw_scale_avail); 425 + ci->range = 0; 426 + ci->scale_avail = ad7606_16bit_hw_scale_avail; 427 + ci->num_scales = ARRAY_SIZE(ad7606_16bit_hw_scale_avail); 428 428 return 0; 429 429 } 430 430 ··· 434 434 return ret; 435 435 436 436 if (differential) { 437 - cs->scale_avail = ad7606c_16bit_differential_bipolar_scale_avail; 438 - cs->num_scales = 437 + ci->scale_avail = ad7606c_16bit_differential_bipolar_scale_avail; 438 + ci->num_scales = 439 439 ARRAY_SIZE(ad7606c_16bit_differential_bipolar_scale_avail); 440 440 /* Bipolar differential ranges start at 8 (b1000) */ 441 - cs->reg_offset = 8; 442 - cs->range = 1; 441 + ci->reg_offset = 8; 442 + ci->range = 1; 443 443 chan->differential = 1; 444 444 chan->channel2 = chan->channel; 445 445 chan->scan_type.sign = 's'; ··· 450 450 chan->differential = 0; 451 451 452 452 if (bipolar) { 453 - cs->scale_avail = ad7606c_16bit_single_ended_bipolar_scale_avail; 454 - cs->num_scales = 453 + ci->scale_avail = ad7606c_16bit_single_ended_bipolar_scale_avail; 454 + ci->num_scales = 455 455 ARRAY_SIZE(ad7606c_16bit_single_ended_bipolar_scale_avail); 456 456 /* Bipolar single-ended ranges start at 0 (b0000) */ 457 - cs->reg_offset = 0; 458 - cs->range = 3; 457 + ci->reg_offset = 0; 458 + ci->range = 3; 459 459 chan->scan_type.sign = 's'; 460 460 461 461 return 0; 462 462 } 463 463 464 - cs->scale_avail = ad7606c_16bit_single_ended_unipolar_scale_avail; 465 - cs->num_scales = 464 + ci->scale_avail = ad7606c_16bit_single_ended_unipolar_scale_avail; 465 + ci->num_scales = 466 466 ARRAY_SIZE(ad7606c_16bit_single_ended_unipolar_scale_avail); 467 467 /* Unipolar single-ended ranges start at 5 (b0101) */ 468 - cs->reg_offset = 5; 469 - cs->range = 1; 468 + ci->reg_offset = 5; 469 + ci->range = 1; 470 470 chan->scan_type.sign = 'u'; 471 471 472 472 return 0; ··· 476 476 struct iio_chan_spec *chan) 477 477 { 478 478 struct ad7606_state *st = iio_priv(indio_dev); 479 - struct ad7606_chan_scale *cs = &st->chan_scales[chan->scan_index]; 479 + struct ad7606_chan_info *ci = &st->chan_info[chan->scan_index]; 480 480 481 - cs->range = 0; 482 - cs->scale_avail = ad7607_hw_scale_avail; 483 - cs->num_scales = ARRAY_SIZE(ad7607_hw_scale_avail); 481 + ci->range = 0; 482 + ci->scale_avail = ad7607_hw_scale_avail; 483 + ci->num_scales = ARRAY_SIZE(ad7607_hw_scale_avail); 484 484 return 0; 485 485 } 486 486 ··· 488 488 struct iio_chan_spec *chan) 489 489 { 490 490 struct ad7606_state *st = iio_priv(indio_dev); 491 - struct ad7606_chan_scale *cs = &st->chan_scales[chan->scan_index]; 491 + struct ad7606_chan_info *ci = &st->chan_info[chan->scan_index]; 492 492 493 - cs->range = 0; 494 - cs->scale_avail = ad7606_18bit_hw_scale_avail; 495 - cs->num_scales = ARRAY_SIZE(ad7606_18bit_hw_scale_avail); 493 + ci->range = 0; 494 + ci->scale_avail = ad7606_18bit_hw_scale_avail; 495 + ci->num_scales = ARRAY_SIZE(ad7606_18bit_hw_scale_avail); 496 496 return 0; 497 497 } 498 498 ··· 500 500 struct iio_chan_spec *chan) 501 501 { 502 502 struct ad7606_state *st = iio_priv(indio_dev); 503 - struct ad7606_chan_scale *cs = &st->chan_scales[chan->scan_index]; 503 + struct ad7606_chan_info *ci = &st->chan_info[chan->scan_index]; 504 504 505 - cs->range = 0; 506 - cs->scale_avail = ad7609_hw_scale_avail; 507 - cs->num_scales = ARRAY_SIZE(ad7609_hw_scale_avail); 505 + ci->range = 0; 506 + ci->scale_avail = ad7609_hw_scale_avail; 507 + ci->num_scales = ARRAY_SIZE(ad7609_hw_scale_avail); 508 508 return 0; 509 509 } 510 510 ··· 743 743 { 744 744 int ret, ch = 0; 745 745 struct ad7606_state *st = iio_priv(indio_dev); 746 - struct ad7606_chan_scale *cs; 746 + struct ad7606_chan_info *ci; 747 747 struct pwm_state cnvst_pwm_state; 748 748 749 749 switch (m) { ··· 758 758 case IIO_CHAN_INFO_SCALE: 759 759 if (st->sw_mode_en) 760 760 ch = chan->scan_index; 761 - cs = &st->chan_scales[ch]; 762 - *val = cs->scale_avail[cs->range][0]; 763 - *val2 = cs->scale_avail[cs->range][1]; 761 + ci = &st->chan_info[ch]; 762 + *val = ci->scale_avail[ci->range][0]; 763 + *val2 = ci->scale_avail[ci->range][1]; 764 764 return IIO_VAL_INT_PLUS_MICRO; 765 765 case IIO_CHAN_INFO_OVERSAMPLING_RATIO: 766 766 *val = st->oversampling; ··· 795 795 { 796 796 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 797 797 struct ad7606_state *st = iio_priv(indio_dev); 798 - struct ad7606_chan_scale *cs = &st->chan_scales[0]; 799 - const unsigned int (*vals)[2] = cs->scale_avail; 798 + struct ad7606_chan_info *ci = &st->chan_info[0]; 799 + const unsigned int (*vals)[2] = ci->scale_avail; 800 800 unsigned int i; 801 801 size_t len = 0; 802 802 803 - for (i = 0; i < cs->num_scales; i++) 803 + for (i = 0; i < ci->num_scales; i++) 804 804 len += scnprintf(buf + len, PAGE_SIZE - len, "%u.%06u ", 805 805 vals[i][0], vals[i][1]); 806 806 buf[len - 1] = '\n'; ··· 901 901 { 902 902 struct ad7606_state *st = iio_priv(indio_dev); 903 903 unsigned int scale_avail_uv[AD760X_MAX_SCALES]; 904 - struct ad7606_chan_scale *cs; 904 + struct ad7606_chan_info *ci; 905 905 int i, ret, ch = 0; 906 906 907 907 guard(mutex)(&st->lock); ··· 910 910 case IIO_CHAN_INFO_SCALE: 911 911 if (st->sw_mode_en) 912 912 ch = chan->scan_index; 913 - cs = &st->chan_scales[ch]; 914 - for (i = 0; i < cs->num_scales; i++) { 915 - scale_avail_uv[i] = cs->scale_avail[i][0] * MICRO + 916 - cs->scale_avail[i][1]; 913 + ci = &st->chan_info[ch]; 914 + for (i = 0; i < ci->num_scales; i++) { 915 + scale_avail_uv[i] = ci->scale_avail[i][0] * MICRO + 916 + ci->scale_avail[i][1]; 917 917 } 918 918 val = (val * MICRO) + val2; 919 - i = find_closest(val, scale_avail_uv, cs->num_scales); 919 + i = find_closest(val, scale_avail_uv, ci->num_scales); 920 920 921 921 if (!iio_device_claim_direct(indio_dev)) 922 922 return -EBUSY; 923 - ret = st->write_scale(indio_dev, ch, i + cs->reg_offset); 923 + ret = st->write_scale(indio_dev, ch, i + ci->reg_offset); 924 924 iio_device_release_direct(indio_dev); 925 925 if (ret < 0) 926 926 return ret; 927 - cs->range = i; 927 + ci->range = i; 928 928 929 929 return 0; 930 930 case IIO_CHAN_INFO_OVERSAMPLING_RATIO: ··· 1115 1115 long info) 1116 1116 { 1117 1117 struct ad7606_state *st = iio_priv(indio_dev); 1118 - struct ad7606_chan_scale *cs; 1118 + struct ad7606_chan_info *ci; 1119 1119 unsigned int ch = 0; 1120 1120 1121 1121 switch (info) { ··· 1130 1130 if (st->sw_mode_en) 1131 1131 ch = chan->scan_index; 1132 1132 1133 - cs = &st->chan_scales[ch]; 1134 - *vals = (int *)cs->scale_avail; 1135 - *length = cs->num_scales * 2; 1133 + ci = &st->chan_info[ch]; 1134 + *vals = (int *)ci->scale_avail; 1135 + *length = ci->num_scales * 2; 1136 1136 *type = IIO_VAL_INT_PLUS_MICRO; 1137 1137 1138 1138 return IIO_AVAIL_LIST; ··· 1655 1655 struct ad7606_state *st = iio_priv(indio_dev); 1656 1656 1657 1657 if (st->gpio_standby) { 1658 - gpiod_set_value(st->gpio_range, st->chan_scales[0].range); 1658 + gpiod_set_value(st->gpio_range, st->chan_info[0].range); 1659 1659 gpiod_set_value(st->gpio_standby, 1); 1660 1660 ad7606_reset(st); 1661 1661 }
+4 -4
drivers/iio/adc/ad7606.h
··· 86 86 }; 87 87 88 88 /** 89 - * struct ad7606_chan_scale - channel scale configuration 89 + * struct ad7606_chan_info - channel configuration 90 90 * @scale_avail: pointer to the array which stores the available scales 91 91 * @num_scales: number of elements stored in the scale_avail array 92 92 * @range: voltage range selection, selects which scale to apply 93 93 * @reg_offset: offset for the register value, to be applied when 94 94 * writing the value of 'range' to the register value 95 95 */ 96 - struct ad7606_chan_scale { 96 + struct ad7606_chan_info { 97 97 #define AD760X_MAX_SCALES 16 98 98 const unsigned int (*scale_avail)[2]; 99 99 unsigned int num_scales; ··· 106 106 * @dev: pointer to kernel device 107 107 * @chip_info: entry in the table of chips that describes this device 108 108 * @bops: bus operations (SPI or parallel) 109 - * @chan_scales: scale configuration for channels 109 + * @chan_info: scale configuration for channels 110 110 * @oversampling: oversampling selection 111 111 * @cnvst_pwm: pointer to the PWM device connected to the cnvst pin 112 112 * @base_address: address from where to read data in parallel operation ··· 137 137 struct device *dev; 138 138 const struct ad7606_chip_info *chip_info; 139 139 const struct ad7606_bus_ops *bops; 140 - struct ad7606_chan_scale chan_scales[AD760X_MAX_CHANNELS]; 140 + struct ad7606_chan_info chan_info[AD760X_MAX_CHANNELS]; 141 141 unsigned int oversampling; 142 142 struct pwm_device *cnvst_pwm; 143 143 void __iomem *base_address;