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: ad7768-1: refactor ad7768_write_raw()

Squash __ad7768_write_raw() back to ad7768_write_raw() to allow the
addition of new attributes without requiring a direct mode claim.

Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Jonathan Santos and committed by
Jonathan Cameron
e7b0312c 404a3b4c

+26 -24
+26 -24
drivers/iio/adc/ad7768-1.c
··· 742 742 return ad7768_filter_regval_to_type[FIELD_GET(mask, mode)]; 743 743 } 744 744 745 + static int ad7768_update_dec_rate(struct iio_dev *dev, unsigned int dec_rate) 746 + { 747 + struct ad7768_state *st = iio_priv(dev); 748 + int ret; 749 + 750 + ret = ad7768_configure_dig_fil(dev, st->filter_type, dec_rate); 751 + if (ret) 752 + return ret; 753 + 754 + /* Update sampling frequency */ 755 + return ad7768_set_freq(st, st->samp_freq); 756 + } 757 + 745 758 static const struct iio_enum ad7768_filter_type_iio_enum = { 746 759 .items = ad7768_filter_enum, 747 760 .num_items = ARRAY_SIZE(ad7768_filter_enum), ··· 880 867 } 881 868 } 882 869 883 - static int __ad7768_write_raw(struct iio_dev *indio_dev, 884 - struct iio_chan_spec const *chan, 885 - int val, int val2, long info) 870 + static int ad7768_write_raw(struct iio_dev *indio_dev, 871 + struct iio_chan_spec const *chan, 872 + int val, int val2, long info) 886 873 { 887 874 struct ad7768_state *st = iio_priv(indio_dev); 888 875 int ret; 889 876 890 877 switch (info) { 891 878 case IIO_CHAN_INFO_SAMP_FREQ: 892 - return ad7768_set_freq(st, val); 879 + if (!iio_device_claim_direct(indio_dev)) 880 + return -EBUSY; 893 881 882 + ret = ad7768_set_freq(st, val); 883 + iio_device_release_direct(indio_dev); 884 + return ret; 894 885 case IIO_CHAN_INFO_OVERSAMPLING_RATIO: 895 - ret = ad7768_configure_dig_fil(indio_dev, st->filter_type, val); 896 - if (ret) 897 - return ret; 886 + if (!iio_device_claim_direct(indio_dev)) 887 + return -EBUSY; 898 888 899 - /* Update sampling frequency */ 900 - return ad7768_set_freq(st, st->samp_freq); 889 + ret = ad7768_update_dec_rate(indio_dev, val); 890 + iio_device_release_direct(indio_dev); 891 + return ret; 901 892 default: 902 893 return -EINVAL; 903 894 } 904 - } 905 - 906 - static int ad7768_write_raw(struct iio_dev *indio_dev, 907 - struct iio_chan_spec const *chan, 908 - int val, int val2, long info) 909 - { 910 - int ret; 911 - 912 - if (!iio_device_claim_direct(indio_dev)) 913 - return -EBUSY; 914 - 915 - ret = __ad7768_write_raw(indio_dev, chan, val, val2, info); 916 - iio_device_release_direct(indio_dev); 917 - 918 - return ret; 919 895 } 920 896 921 897 static int ad7768_read_label(struct iio_dev *indio_dev,