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: extract setup function without backend

Refactor probe function by moving the initialization specific to
communication without iio-backend into a separate setup function.

The purpose of this modification is better code organization. No
functional changes intended.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Ioana Risteiu <Ioana.Risteiu@analog.com>
Link: https://patch.msgid.link/20250825221355.6214-4-Ioana.Risteiu@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Ioana Risteiu and committed by
Jonathan Cameron
2ca33c50 a9ee7101

+46 -40
+46 -40
drivers/iio/adc/ad7779.c
··· 752 752 return 0; 753 753 } 754 754 755 + static int ad7779_setup_without_backend(struct ad7779_state *st, struct iio_dev *indio_dev) 756 + { 757 + int ret; 758 + struct device *dev = &st->spi->dev; 759 + 760 + indio_dev->info = &ad7779_info; 761 + indio_dev->channels = st->chip_info->channels; 762 + indio_dev->num_channels = ARRAY_SIZE(ad7779_channels); 763 + 764 + st->trig = devm_iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name, 765 + iio_device_id(indio_dev)); 766 + if (!st->trig) 767 + return -ENOMEM; 768 + 769 + st->trig->ops = &ad7779_trigger_ops; 770 + 771 + iio_trigger_set_drvdata(st->trig, st); 772 + 773 + ret = devm_request_irq(dev, st->spi->irq, iio_trigger_generic_data_rdy_poll, 774 + IRQF_ONESHOT | IRQF_NO_AUTOEN, indio_dev->name, 775 + st->trig); 776 + if (ret) 777 + return dev_err_probe(dev, ret, "request IRQ %d failed\n", 778 + st->spi->irq); 779 + 780 + ret = devm_iio_trigger_register(dev, st->trig); 781 + if (ret) 782 + return ret; 783 + 784 + indio_dev->trig = iio_trigger_get(st->trig); 785 + 786 + init_completion(&st->completion); 787 + 788 + ret = devm_iio_triggered_buffer_setup(dev, indio_dev, 789 + &iio_pollfunc_store_time, 790 + &ad7779_trigger_handler, 791 + &ad7779_buffer_setup_ops); 792 + if (ret) 793 + return ret; 794 + 795 + return ad7779_spi_write_mask(st, AD7779_REG_DOUT_FORMAT, 796 + AD7779_DCLK_CLK_DIV_MSK, 797 + FIELD_PREP(AD7779_DCLK_CLK_DIV_MSK, 7)); 798 + } 799 + 755 800 static int ad7779_probe(struct spi_device *spi) 756 801 { 757 802 struct iio_dev *indio_dev; ··· 804 759 struct gpio_desc *reset_gpio, *start_gpio; 805 760 struct device *dev = &spi->dev; 806 761 int ret = -EINVAL; 807 - 808 - if (!spi->irq) 809 - return dev_err_probe(dev, ret, "DRDY irq not present\n"); 810 762 811 763 indio_dev = devm_iio_device_alloc(dev, sizeof(*st)); 812 764 if (!indio_dev) ··· 846 804 return ret; 847 805 848 806 indio_dev->name = st->chip_info->name; 849 - indio_dev->info = &ad7779_info; 850 807 indio_dev->modes = INDIO_DIRECT_MODE; 851 - indio_dev->channels = st->chip_info->channels; 852 - indio_dev->num_channels = ARRAY_SIZE(ad7779_channels); 853 808 854 - st->trig = devm_iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name, 855 - iio_device_id(indio_dev)); 856 - if (!st->trig) 857 - return -ENOMEM; 858 - 859 - st->trig->ops = &ad7779_trigger_ops; 860 - 861 - iio_trigger_set_drvdata(st->trig, st); 862 - 863 - ret = devm_request_irq(dev, spi->irq, iio_trigger_generic_data_rdy_poll, 864 - IRQF_ONESHOT | IRQF_NO_AUTOEN, indio_dev->name, 865 - st->trig); 866 - if (ret) 867 - return dev_err_probe(dev, ret, "request IRQ %d failed\n", 868 - st->spi->irq); 869 - 870 - ret = devm_iio_trigger_register(dev, st->trig); 871 - if (ret) 872 - return ret; 873 - 874 - indio_dev->trig = iio_trigger_get(st->trig); 875 - 876 - init_completion(&st->completion); 877 - 878 - ret = devm_iio_triggered_buffer_setup(dev, indio_dev, 879 - &iio_pollfunc_store_time, 880 - &ad7779_trigger_handler, 881 - &ad7779_buffer_setup_ops); 882 - if (ret) 883 - return ret; 884 - 885 - ret = ad7779_spi_write_mask(st, AD7779_REG_DOUT_FORMAT, 886 - AD7779_DCLK_CLK_DIV_MSK, 887 - FIELD_PREP(AD7779_DCLK_CLK_DIV_MSK, 7)); 809 + ret = ad7779_setup_without_backend(st, indio_dev); 888 810 if (ret) 889 811 return ret; 890 812