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: ad9467: add backend test mode helpers

Group the backend configurations to be done in preparing and stopping
calibration in two new helpers analogous to ad9467_testmode_set(). This
is in preparation for adding support for debugFS test_mode where
we need similar configurations as in the calibration process.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240802-dev-iio-backend-add-debugfs-v2-7-4cb62852f0d0@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Nuno Sa and committed by
Jonathan Cameron
5b30937b c031fee0

+42 -25
+42 -25
drivers/iio/adc/ad9467.c
··· 494 494 AN877_ADC_TRANSFER_SYNC); 495 495 } 496 496 497 - static int ad9647_calibrate_prepare(struct ad9467_state *st) 497 + static int ad9467_backend_testmode_on(struct ad9467_state *st, 498 + unsigned int chan, 499 + enum iio_backend_test_pattern pattern) 498 500 { 499 501 struct iio_backend_data_fmt data = { 500 502 .enable = false, 501 503 }; 504 + int ret; 505 + 506 + ret = iio_backend_data_format_set(st->back, chan, &data); 507 + if (ret) 508 + return ret; 509 + 510 + ret = iio_backend_test_pattern_set(st->back, chan, pattern); 511 + if (ret) 512 + return ret; 513 + 514 + return iio_backend_chan_enable(st->back, chan); 515 + } 516 + 517 + static int ad9467_backend_testmode_off(struct ad9467_state *st, 518 + unsigned int chan) 519 + { 520 + struct iio_backend_data_fmt data = { 521 + .enable = true, 522 + .sign_extend = true, 523 + }; 524 + int ret; 525 + 526 + ret = iio_backend_chan_disable(st->back, chan); 527 + if (ret) 528 + return ret; 529 + 530 + ret = iio_backend_test_pattern_set(st->back, chan, 531 + IIO_BACKEND_NO_TEST_PATTERN); 532 + if (ret) 533 + return ret; 534 + 535 + return iio_backend_data_format_set(st->back, chan, &data); 536 + } 537 + 538 + static int ad9647_calibrate_prepare(struct ad9467_state *st) 539 + { 502 540 unsigned int c; 503 541 int ret; 504 542 ··· 549 511 if (ret) 550 512 return ret; 551 513 552 - ret = iio_backend_data_format_set(st->back, c, &data); 553 - if (ret) 554 - return ret; 555 - 556 - ret = iio_backend_test_pattern_set(st->back, c, 557 - IIO_BACKEND_ADI_PRBS_9A); 558 - if (ret) 559 - return ret; 560 - 561 - ret = iio_backend_chan_enable(st->back, c); 514 + ret = ad9467_backend_testmode_on(st, c, 515 + IIO_BACKEND_ADI_PRBS_9A); 562 516 if (ret) 563 517 return ret; 564 518 } ··· 631 601 632 602 static int ad9647_calibrate_stop(struct ad9467_state *st) 633 603 { 634 - struct iio_backend_data_fmt data = { 635 - .sign_extend = true, 636 - .enable = true, 637 - }; 638 604 unsigned int c, mode; 639 605 int ret; 640 606 641 607 for (c = 0; c < st->info->num_channels; c++) { 642 - ret = iio_backend_chan_disable(st->back, c); 643 - if (ret) 644 - return ret; 645 - 646 - ret = iio_backend_test_pattern_set(st->back, c, 647 - IIO_BACKEND_NO_TEST_PATTERN); 648 - if (ret) 649 - return ret; 650 - 651 - ret = iio_backend_data_format_set(st->back, c, &data); 608 + ret = ad9467_backend_testmode_off(st, c); 652 609 if (ret) 653 610 return ret; 654 611