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: dac: adi-axi-dac: use unique bus free check

Use a unique function for the bus free check by polling, to reduce
duplicated code. An error is always thrown in case of timeout.

Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250523-ad3552r-fix-bus-read-v3-2-310e726dd964@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Angelo Dureghello and committed by
Jonathan Cameron
9182f3b4 1543572f

+22 -20
+22 -20
drivers/iio/dac/adi-axi-dac.c
··· 635 635 AXI_DAC_CNTRL_2_SDR_DDR_N); 636 636 } 637 637 638 + static int axi_dac_wait_bus_free(struct axi_dac_state *st) 639 + { 640 + u32 val; 641 + int ret; 642 + 643 + ret = regmap_read_poll_timeout(st->regmap, AXI_DAC_UI_STATUS_REG, val, 644 + FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, val) == 0, 10, 645 + 100 * KILO); 646 + if (ret == -ETIMEDOUT) 647 + dev_err(st->dev, "AXI bus timeout\n"); 648 + 649 + return ret; 650 + } 651 + 638 652 static int axi_dac_data_stream_enable(struct iio_backend *back) 639 653 { 640 654 struct axi_dac_state *st = iio_backend_get_priv(back); 641 - int ret, val; 655 + int ret; 642 656 643 - ret = regmap_read_poll_timeout(st->regmap, 644 - AXI_DAC_UI_STATUS_REG, val, 645 - FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, val) == 0, 646 - 10, 100 * KILO); 657 + ret = axi_dac_wait_bus_free(st); 647 658 if (ret) 648 659 return ret; 649 660 ··· 745 734 if (ret) 746 735 return ret; 747 736 748 - ret = regmap_read_poll_timeout(st->regmap, 749 - AXI_DAC_UI_STATUS_REG, ival, 750 - FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, ival) == 0, 751 - 10, 100 * KILO); 752 - if (ret == -ETIMEDOUT) 753 - dev_err(st->dev, "AXI read timeout\n"); 737 + ret = axi_dac_wait_bus_free(st); 738 + if (ret) 739 + return ret; 754 740 755 741 /* Cleaning always AXI_DAC_CUSTOM_CTRL_TRANSFER_DATA */ 756 742 return regmap_clear_bits(st->regmap, AXI_DAC_CUSTOM_CTRL_REG, ··· 768 760 { 769 761 struct axi_dac_state *st = iio_backend_get_priv(back); 770 762 int ret; 771 - u32 ival; 772 763 773 764 guard(mutex)(&st->lock); 774 765 ··· 780 773 if (ret) 781 774 return ret; 782 775 783 - ret = regmap_read_poll_timeout(st->regmap, 784 - AXI_DAC_UI_STATUS_REG, ival, 785 - FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, ival) == 0, 786 - 10, 100 * KILO); 776 + ret = axi_dac_wait_bus_free(st); 787 777 if (ret) 788 778 return ret; 789 779 ··· 791 787 enum ad3552r_io_mode mode) 792 788 { 793 789 struct axi_dac_state *st = iio_backend_get_priv(back); 794 - int ival, ret; 790 + int ret; 795 791 796 792 if (mode > AD3552R_IO_MODE_QSPI) 797 793 return -EINVAL; ··· 804 800 if (ret) 805 801 return ret; 806 802 807 - return regmap_read_poll_timeout(st->regmap, AXI_DAC_UI_STATUS_REG, ival, 808 - FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, ival) == 0, 10, 809 - 100 * KILO); 803 + return axi_dac_wait_bus_free(st); 810 804 } 811 805 812 806 static void axi_dac_child_remove(void *data)