Skip to content

Commit 92c2472

Browse files
dlechjic23
authored andcommitted
iio: adc: ad7173: fix num_slots
Fix the num_slots value for most chips in the ad7173 driver. The correct value is the number of CHANNELx registers on the chip. In commit 4310e15 ("iio: adc: ad7173: don't make copy of ad_sigma_delta_info struct"), we refactored struct ad_sigma_delta_info to be static const data instead of being dynamically populated during driver probe. However, there was an existing bug in commit 76a1e6a ("iio: adc: ad7173: add AD7173 driver") where num_slots was incorrectly set to the number of CONFIGx registers instead of the number of CHANNELx registers. This bug was partially propagated to the refactored code in that the 16-channel chips were only given 8 slots instead of 16 although we did managed to fix the 8-channel chips and one of the 4-channel chips in that commit. However, we botched two of the 4-channel chips and ended up incorrectly giving them 8 slots during the refactoring. This patch fixes that mistake on the 4-channel chips and also corrects the 16-channel chips to have 16 slots. Fixes: 4310e15 ("iio: adc: ad7173: don't make copy of ad_sigma_delta_info struct") Signed-off-by: David Lechner <[email protected]> Reviewed-by: Nuno Sá <[email protected]> Link: https://patch.msgid.link/20250706-iio-adc-ad7173-fix-num_slots-on-most-chips-v3-1-d1f5453198a7@baylibre.com Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 0eb8d7b commit 92c2472

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

drivers/iio/adc/ad7173.c

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -771,10 +771,26 @@ static const struct ad_sigma_delta_info ad7173_sigma_delta_info_8_slots = {
771771
.num_slots = 8,
772772
};
773773

774+
static const struct ad_sigma_delta_info ad7173_sigma_delta_info_16_slots = {
775+
.set_channel = ad7173_set_channel,
776+
.append_status = ad7173_append_status,
777+
.disable_all = ad7173_disable_all,
778+
.disable_one = ad7173_disable_one,
779+
.set_mode = ad7173_set_mode,
780+
.has_registers = true,
781+
.has_named_irqs = true,
782+
.addr_shift = 0,
783+
.read_mask = BIT(6),
784+
.status_ch_mask = GENMASK(3, 0),
785+
.data_reg = AD7173_REG_DATA,
786+
.num_resetclks = 64,
787+
.num_slots = 16,
788+
};
789+
774790
static const struct ad7173_device_info ad4111_device_info = {
775791
.name = "ad4111",
776792
.id = AD4111_ID,
777-
.sd_info = &ad7173_sigma_delta_info_8_slots,
793+
.sd_info = &ad7173_sigma_delta_info_16_slots,
778794
.num_voltage_in_div = 8,
779795
.num_channels = 16,
780796
.num_configs = 8,
@@ -796,7 +812,7 @@ static const struct ad7173_device_info ad4111_device_info = {
796812
static const struct ad7173_device_info ad4112_device_info = {
797813
.name = "ad4112",
798814
.id = AD4112_ID,
799-
.sd_info = &ad7173_sigma_delta_info_8_slots,
815+
.sd_info = &ad7173_sigma_delta_info_16_slots,
800816
.num_voltage_in_div = 8,
801817
.num_channels = 16,
802818
.num_configs = 8,
@@ -817,7 +833,7 @@ static const struct ad7173_device_info ad4112_device_info = {
817833
static const struct ad7173_device_info ad4113_device_info = {
818834
.name = "ad4113",
819835
.id = AD4113_ID,
820-
.sd_info = &ad7173_sigma_delta_info_8_slots,
836+
.sd_info = &ad7173_sigma_delta_info_16_slots,
821837
.num_voltage_in_div = 8,
822838
.num_channels = 16,
823839
.num_configs = 8,
@@ -836,7 +852,7 @@ static const struct ad7173_device_info ad4113_device_info = {
836852
static const struct ad7173_device_info ad4114_device_info = {
837853
.name = "ad4114",
838854
.id = AD4114_ID,
839-
.sd_info = &ad7173_sigma_delta_info_8_slots,
855+
.sd_info = &ad7173_sigma_delta_info_16_slots,
840856
.num_voltage_in_div = 16,
841857
.num_channels = 16,
842858
.num_configs = 8,
@@ -855,7 +871,7 @@ static const struct ad7173_device_info ad4114_device_info = {
855871
static const struct ad7173_device_info ad4115_device_info = {
856872
.name = "ad4115",
857873
.id = AD4115_ID,
858-
.sd_info = &ad7173_sigma_delta_info_8_slots,
874+
.sd_info = &ad7173_sigma_delta_info_16_slots,
859875
.num_voltage_in_div = 16,
860876
.num_channels = 16,
861877
.num_configs = 8,
@@ -874,7 +890,7 @@ static const struct ad7173_device_info ad4115_device_info = {
874890
static const struct ad7173_device_info ad4116_device_info = {
875891
.name = "ad4116",
876892
.id = AD4116_ID,
877-
.sd_info = &ad7173_sigma_delta_info_8_slots,
893+
.sd_info = &ad7173_sigma_delta_info_16_slots,
878894
.num_voltage_in_div = 11,
879895
.num_channels = 16,
880896
.num_configs = 8,
@@ -893,7 +909,7 @@ static const struct ad7173_device_info ad4116_device_info = {
893909
static const struct ad7173_device_info ad7172_2_device_info = {
894910
.name = "ad7172-2",
895911
.id = AD7172_2_ID,
896-
.sd_info = &ad7173_sigma_delta_info_8_slots,
912+
.sd_info = &ad7173_sigma_delta_info_4_slots,
897913
.num_voltage_in = 5,
898914
.num_channels = 4,
899915
.num_configs = 4,
@@ -926,7 +942,7 @@ static const struct ad7173_device_info ad7172_4_device_info = {
926942
static const struct ad7173_device_info ad7173_8_device_info = {
927943
.name = "ad7173-8",
928944
.id = AD7173_ID,
929-
.sd_info = &ad7173_sigma_delta_info_8_slots,
945+
.sd_info = &ad7173_sigma_delta_info_16_slots,
930946
.num_voltage_in = 17,
931947
.num_channels = 16,
932948
.num_configs = 8,
@@ -943,7 +959,7 @@ static const struct ad7173_device_info ad7173_8_device_info = {
943959
static const struct ad7173_device_info ad7175_2_device_info = {
944960
.name = "ad7175-2",
945961
.id = AD7175_2_ID,
946-
.sd_info = &ad7173_sigma_delta_info_8_slots,
962+
.sd_info = &ad7173_sigma_delta_info_4_slots,
947963
.num_voltage_in = 5,
948964
.num_channels = 4,
949965
.num_configs = 4,
@@ -960,7 +976,7 @@ static const struct ad7173_device_info ad7175_2_device_info = {
960976
static const struct ad7173_device_info ad7175_8_device_info = {
961977
.name = "ad7175-8",
962978
.id = AD7175_8_ID,
963-
.sd_info = &ad7173_sigma_delta_info_8_slots,
979+
.sd_info = &ad7173_sigma_delta_info_16_slots,
964980
.num_voltage_in = 17,
965981
.num_channels = 16,
966982
.num_configs = 8,

0 commit comments

Comments
 (0)