From nobody Fri Feb 13 12:29:17 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BE17CE7A8A for ; Sun, 24 Sep 2023 21:52:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230507AbjIXVwg (ORCPT ); Sun, 24 Sep 2023 17:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbjIXVwd (ORCPT ); Sun, 24 Sep 2023 17:52:33 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4965AFF; Sun, 24 Sep 2023 14:52:26 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3232be274a0so85499f8f.1; Sun, 24 Sep 2023 14:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695592345; x=1696197145; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0uMILxFEAcsaYLKyqAn5+Be+mSQ6Ty4Dmp+SlLyk7Jg=; b=Z8XPN7BKD7EW+BJPfGNJZFWMDroB3PpfnuA41VJtapHcYwo/VcOW0JkDLaPA7qxkt4 WK4vETwUtvjflboC2SCIMXc4t/MyMAw8X8SlkZ1NASaPwXSlXS2CVMesoDdvfRSzWf0N BJCDbGD8ggmXsb93SpW6G1vLP9iLjrz6GUB8uxyf1P2HPgnZeDF/ymrJd0hkWeXAhFSX zgUnn2XUpyyH9IAC40BcaviLPD6A7nm5XOFZimVkofmakFcVoLmhijpDZDUi1gN8wQjS NOB8dbWYZW4UZSRx2mA+13yRw0nX3yL2wsMAO8DHTySOZwv74LFfCqrbqFg0+TyPNM4Z Xm0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695592345; x=1696197145; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0uMILxFEAcsaYLKyqAn5+Be+mSQ6Ty4Dmp+SlLyk7Jg=; b=wiEPZjKA2951rpLFLTTZeI/lwaZ/wzVISJKpYRZAFPFzyhEJItGKlZjAVOMwKngdSI mRk3VPlWKhVIF2UX87MQkf8//fB0INcIcc4l4PhCgvppsDXy7beD/0CW+S3hbwMSQGVa OYx1r0LBXmq1QLOsx7Gz4ifd3/RqeOls4/XJEVDJEPPE/AhXCMf2h75YN8pzNT9PtYrS J0cBEvXF/Wy+EZWkMpTX59yPa/FFDHd2C+MmcwIF1bJ936JROcoOSBesphh0DHyN3GjI +5YkxZEz6krUaApLgAhGzu4Dz8PKCgDBzf7AMYmXxQZNMWWjuKrwAIgBgYPX0HUNXDTp nc+g== X-Gm-Message-State: AOJu0Yw25Jdo476+2tn/lvgrHKX8Fif9Mj+R9vTreGXYrgFYVKx6B267 79yyUMGQqJ0cYSrkm5lUr0M= X-Google-Smtp-Source: AGHT+IEASIW2BP8s0ty1wkGohQK/FBvu2UdCpE8HVoFBHe3DpdWBta7IRhQlQ0kZhwCI8uN0QOREng== X-Received: by 2002:adf:ef83:0:b0:31f:ebfa:54eb with SMTP id d3-20020adfef83000000b0031febfa54ebmr6553331wro.3.1695592344664; Sun, 24 Sep 2023 14:52:24 -0700 (PDT) Received: from spiri.. ([2a02:2f08:a301:7000:1bc9:cab8:e784:6ddb]) by smtp.gmail.com with ESMTPSA id c10-20020a5d4f0a000000b0031f3ad17b2csm10144444wru.52.2023.09.24.14.52.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 14:52:24 -0700 (PDT) From: alisadariana@gmail.com Cc: Alisa-Dariana Roman , Jonathan Cameron , Lars-Peter Clausen , Alexandru Tachici , Michael Hennerich , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/3] iio: adc: ad7192: Use bitfield access macros Date: Mon, 25 Sep 2023 00:51:46 +0300 Message-Id: <20230924215148.102491-2-alisadariana@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230924215148.102491-1-alisadariana@gmail.com> References: <20230924215148.102491-1-alisadariana@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alisa-Dariana Roman Include bitfield.h and update driver to use bitfield access macros GENMASK, FIELD_PREP and FIELD_GET. Remove old macros in favor of using FIELD_PREP and masks. Change %d to %ld to match the type of FIELD_GET(). Signed-off-by: Alisa-Dariana Roman --- drivers/iio/adc/ad7192.c | 73 ++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c index 69d1103b9508..d693f2ce8a20 100644 --- a/drivers/iio/adc/ad7192.c +++ b/drivers/iio/adc/ad7192.c @@ -6,6 +6,7 @@ */ =20 #include +#include #include #include #include @@ -43,7 +44,7 @@ #define AD7192_COMM_WEN BIT(7) /* Write Enable */ #define AD7192_COMM_WRITE 0 /* Write Operation */ #define AD7192_COMM_READ BIT(6) /* Read Operation */ -#define AD7192_COMM_ADDR(x) (((x) & 0x7) << 3) /* Register Address */ +#define AD7192_COMM_ADDR_MASK GENMASK(5, 3) /* Register Address Mask */ #define AD7192_COMM_CREAD BIT(2) /* Continuous Read of Data Register */ =20 /* Status Register Bit Designations (AD7192_REG_STAT) */ @@ -56,17 +57,16 @@ #define AD7192_STAT_CH1 BIT(0) /* Channel 1 */ =20 /* Mode Register Bit Designations (AD7192_REG_MODE) */ -#define AD7192_MODE_SEL(x) (((x) & 0x7) << 21) /* Operation Mode Select */ -#define AD7192_MODE_SEL_MASK (0x7 << 21) /* Operation Mode Select Mask */ -#define AD7192_MODE_STA(x) (((x) & 0x1) << 20) /* Status Register transmis= sion */ +#define AD7192_MODE_SEL_MASK GENMASK(23, 21) /* Operation Mode Select Mask= */ #define AD7192_MODE_STA_MASK BIT(20) /* Status Register transmission Mask = */ -#define AD7192_MODE_CLKSRC(x) (((x) & 0x3) << 18) /* Clock Source Select */ +#define AD7192_MODE_CLKSRC_MASK GENMASK(19, 18) /* Clock Source Select Mas= k */ #define AD7192_MODE_SINC3 BIT(15) /* SINC3 Filter Select */ #define AD7192_MODE_ENPAR BIT(13) /* Parity Enable */ #define AD7192_MODE_CLKDIV BIT(12) /* Clock divide by 2 (AD7190/2 only)*/ #define AD7192_MODE_SCYCLE BIT(11) /* Single cycle conversion */ #define AD7192_MODE_REJ60 BIT(10) /* 50/60Hz notch filter */ -#define AD7192_MODE_RATE(x) ((x) & 0x3FF) /* Filter Update Rate Select */ + /* Filter Update Rate Select Mask */ +#define AD7192_MODE_RATE_MASK GENMASK(9, 0) =20 /* Mode Register: AD7192_MODE_SEL options */ #define AD7192_MODE_CONT 0 /* Continuous Conversion Mode */ @@ -92,13 +92,12 @@ #define AD7192_CONF_CHOP BIT(23) /* CHOP enable */ #define AD7192_CONF_ACX BIT(22) /* AC excitation enable(AD7195 only) */ #define AD7192_CONF_REFSEL BIT(20) /* REFIN1/REFIN2 Reference Select */ -#define AD7192_CONF_CHAN(x) ((x) << 8) /* Channel select */ -#define AD7192_CONF_CHAN_MASK (0x7FF << 8) /* Channel select mask */ +#define AD7192_CONF_CHAN_MASK GENMASK(18, 8) /* Channel select mask */ #define AD7192_CONF_BURN BIT(7) /* Burnout current enable */ #define AD7192_CONF_REFDET BIT(6) /* Reference detect enable */ #define AD7192_CONF_BUF BIT(4) /* Buffered Mode Enable */ #define AD7192_CONF_UNIPOLAR BIT(3) /* Unipolar/Bipolar Enable */ -#define AD7192_CONF_GAIN(x) ((x) & 0x7) /* Gain Select */ +#define AD7192_CONF_GAIN_MASK GENMASK(2, 0) /* Gain Select */ =20 #define AD7192_CH_AIN1P_AIN2M BIT(0) /* AIN1(+) - AIN2(-) */ #define AD7192_CH_AIN3P_AIN4M BIT(1) /* AIN3(+) - AIN4(-) */ @@ -130,7 +129,7 @@ #define CHIPID_AD7192 0x0 #define CHIPID_AD7193 0x2 #define CHIPID_AD7195 0x6 -#define AD7192_ID_MASK 0x0F +#define AD7192_ID_MASK GENMASK(3, 0) =20 /* GPOCON Register Bit Designations (AD7192_REG_GPOCON) */ #define AD7192_GPOCON_BPDSW BIT(6) /* Bridge power-down switch enable */ @@ -272,7 +271,7 @@ static int ad7192_set_channel(struct ad_sigma_delta *sd= , unsigned int channel) struct ad7192_state *st =3D ad_sigma_delta_to_ad7192(sd); =20 st->conf &=3D ~AD7192_CONF_CHAN_MASK; - st->conf |=3D AD7192_CONF_CHAN(channel); + st->conf |=3D FIELD_PREP(AD7192_CONF_CHAN_MASK, channel); =20 return ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, st->conf); } @@ -283,7 +282,7 @@ static int ad7192_set_mode(struct ad_sigma_delta *sd, struct ad7192_state *st =3D ad_sigma_delta_to_ad7192(sd); =20 st->mode &=3D ~AD7192_MODE_SEL_MASK; - st->mode |=3D AD7192_MODE_SEL(mode); + st->mode |=3D FIELD_PREP(AD7192_MODE_SEL_MASK, mode); =20 return ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode); } @@ -295,7 +294,7 @@ static int ad7192_append_status(struct ad_sigma_delta *= sd, bool append) int ret; =20 mode &=3D ~AD7192_MODE_STA_MASK; - mode |=3D AD7192_MODE_STA(append); + mode |=3D FIELD_PREP(AD7192_MODE_STA_MASK, append); =20 ret =3D ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, mode); if (ret < 0) @@ -399,17 +398,17 @@ static int ad7192_setup(struct iio_dev *indio_dev, st= ruct device_node *np) if (ret) return ret; =20 - id &=3D AD7192_ID_MASK; + id =3D FIELD_GET(AD7192_ID_MASK, id); =20 if (id !=3D st->chip_info->chip_id) dev_warn(&st->sd.spi->dev, "device ID query failed (0x%X !=3D 0x%X)\n", id, st->chip_info->chip_id); =20 - st->mode =3D AD7192_MODE_SEL(AD7192_MODE_IDLE) | - AD7192_MODE_CLKSRC(st->clock_sel) | - AD7192_MODE_RATE(480); + st->mode =3D FIELD_PREP(AD7192_MODE_SEL_MASK, AD7192_MODE_IDLE) | + FIELD_PREP(AD7192_MODE_CLKSRC_MASK, st->clock_sel) | + FIELD_PREP(AD7192_MODE_RATE_MASK, 480); =20 - st->conf =3D AD7192_CONF_GAIN(0); + st->conf =3D FIELD_PREP(AD7192_CONF_GAIN_MASK, 0); =20 rej60_en =3D of_property_read_bool(np, "adi,rejection-60-Hz-enable"); if (rej60_en) @@ -455,7 +454,7 @@ static int ad7192_setup(struct iio_dev *indio_dev, stru= ct device_node *np) for (i =3D 0; i < ARRAY_SIZE(st->scale_avail); i++) { scale_uv =3D ((u64)st->int_vref_mv * 100000000) >> (indio_dev->channels[0].scan_type.realbits - - ((st->conf & AD7192_CONF_UNIPOLAR) ? 0 : 1)); + !FIELD_GET(AD7192_CONF_UNIPOLAR, st->conf)); scale_uv >>=3D i; =20 st->scale_avail[i][1] =3D do_div(scale_uv, 100000000) * 10; @@ -472,7 +471,7 @@ static ssize_t ad7192_show_ac_excitation(struct device = *dev, struct iio_dev *indio_dev =3D dev_to_iio_dev(dev); struct ad7192_state *st =3D iio_priv(indio_dev); =20 - return sysfs_emit(buf, "%d\n", !!(st->conf & AD7192_CONF_ACX)); + return sysfs_emit(buf, "%ld\n", FIELD_GET(AD7192_CONF_ACX, st->conf)); } =20 static ssize_t ad7192_show_bridge_switch(struct device *dev, @@ -482,7 +481,8 @@ static ssize_t ad7192_show_bridge_switch(struct device = *dev, struct iio_dev *indio_dev =3D dev_to_iio_dev(dev); struct ad7192_state *st =3D iio_priv(indio_dev); =20 - return sysfs_emit(buf, "%d\n", !!(st->gpocon & AD7192_GPOCON_BPDSW)); + return sysfs_emit(buf, "%ld\n", + FIELD_GET(AD7192_GPOCON_BPDSW, st->gpocon)); } =20 static ssize_t ad7192_set(struct device *dev, @@ -537,14 +537,14 @@ static void ad7192_get_available_filter_freq(struct a= d7192_state *st, =20 /* Formulas for filter at page 25 of the datasheet */ fadc =3D DIV_ROUND_CLOSEST(st->fclk, - AD7192_SYNC4_FILTER * AD7192_MODE_RATE(st->mode)); + AD7192_SYNC4_FILTER * FIELD_GET(AD7192_MODE_RATE_MASK, st->mode)); freq[0] =3D DIV_ROUND_CLOSEST(fadc * 240, 1024); =20 fadc =3D DIV_ROUND_CLOSEST(st->fclk, - AD7192_SYNC3_FILTER * AD7192_MODE_RATE(st->mode)); + AD7192_SYNC3_FILTER * FIELD_GET(AD7192_MODE_RATE_MASK, st->mode)); freq[1] =3D DIV_ROUND_CLOSEST(fadc * 240, 1024); =20 - fadc =3D DIV_ROUND_CLOSEST(st->fclk, AD7192_MODE_RATE(st->mode)); + fadc =3D DIV_ROUND_CLOSEST(st->fclk, FIELD_GET(AD7192_MODE_RATE_MASK, st-= >mode)); freq[2] =3D DIV_ROUND_CLOSEST(fadc * 230, 1024); freq[3] =3D DIV_ROUND_CLOSEST(fadc * 272, 1024); } @@ -665,11 +665,11 @@ static int ad7192_get_3db_filter_freq(struct ad7192_s= tate *st) unsigned int fadc; =20 fadc =3D DIV_ROUND_CLOSEST(st->fclk, - st->f_order * AD7192_MODE_RATE(st->mode)); + st->f_order * FIELD_GET(AD7192_MODE_RATE_MASK, st->mode)); =20 - if (st->conf & AD7192_CONF_CHOP) + if (FIELD_GET(AD7192_CONF_CHOP, st->conf)) return DIV_ROUND_CLOSEST(fadc * 240, 1024); - if (st->mode & AD7192_MODE_SINC3) + if (FIELD_GET(AD7192_MODE_SINC3, st->mode)) return DIV_ROUND_CLOSEST(fadc * 272, 1024); else return DIV_ROUND_CLOSEST(fadc * 230, 1024); @@ -682,7 +682,8 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, long m) { struct ad7192_state *st =3D iio_priv(indio_dev); - bool unipolar =3D !!(st->conf & AD7192_CONF_UNIPOLAR); + bool unipolar =3D !!FIELD_GET(AD7192_CONF_UNIPOLAR, st->conf); + u8 gain =3D FIELD_GET(AD7192_CONF_GAIN_MASK, st->conf); =20 switch (m) { case IIO_CHAN_INFO_RAW: @@ -691,8 +692,8 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, switch (chan->type) { case IIO_VOLTAGE: mutex_lock(&st->lock); - *val =3D st->scale_avail[AD7192_CONF_GAIN(st->conf)][0]; - *val2 =3D st->scale_avail[AD7192_CONF_GAIN(st->conf)][1]; + *val =3D st->scale_avail[gain][0]; + *val2 =3D st->scale_avail[gain][1]; mutex_unlock(&st->lock); return IIO_VAL_INT_PLUS_NANO; case IIO_TEMP: @@ -713,7 +714,7 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case IIO_CHAN_INFO_SAMP_FREQ: *val =3D st->fclk / - (st->f_order * 1024 * AD7192_MODE_RATE(st->mode)); + (st->f_order * 1024 * FIELD_GET(AD7192_MODE_RATE_MASK, st->mode)); return IIO_VAL_INT; case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: *val =3D ad7192_get_3db_filter_freq(st); @@ -746,8 +747,8 @@ static int ad7192_write_raw(struct iio_dev *indio_dev, if (val2 =3D=3D st->scale_avail[i][1]) { ret =3D 0; tmp =3D st->conf; - st->conf &=3D ~AD7192_CONF_GAIN(-1); - st->conf |=3D AD7192_CONF_GAIN(i); + st->conf &=3D ~AD7192_CONF_GAIN_MASK; + st->conf |=3D FIELD_PREP(AD7192_CONF_GAIN_MASK, i); if (tmp =3D=3D st->conf) break; ad_sd_write_reg(&st->sd, AD7192_REG_CONF, @@ -769,8 +770,8 @@ static int ad7192_write_raw(struct iio_dev *indio_dev, break; } =20 - st->mode &=3D ~AD7192_MODE_RATE(-1); - st->mode |=3D AD7192_MODE_RATE(div); + st->mode &=3D ~AD7192_MODE_RATE_MASK; + st->mode |=3D FIELD_PREP(AD7192_MODE_RATE_MASK, div); ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode); break; case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: @@ -830,7 +831,7 @@ static int ad7192_update_scan_mode(struct iio_dev *indi= o_dev, const unsigned lon =20 conf &=3D ~AD7192_CONF_CHAN_MASK; for_each_set_bit(i, scan_mask, 8) - conf |=3D AD7192_CONF_CHAN(i); + conf |=3D FIELD_PREP(AD7192_CONF_CHAN_MASK, i); =20 ret =3D ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, conf); if (ret < 0) --=20 2.34.1 From nobody Fri Feb 13 12:29:17 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1673CE7A8C for ; Sun, 24 Sep 2023 21:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231304AbjIXVwm (ORCPT ); Sun, 24 Sep 2023 17:52:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbjIXVwj (ORCPT ); Sun, 24 Sep 2023 17:52:39 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF19010D; Sun, 24 Sep 2023 14:52:28 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-32003aae100so4368939f8f.0; Sun, 24 Sep 2023 14:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695592347; x=1696197147; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x1mUiu1NbtoOEm28VDfVFWd43xm6wsUmZ3K7SF3CDig=; b=bCPr3Sjc3F09pWHMz9N3XG1qzpkji8AwgJAnviL0JomwH0YxczLw+jo7bTfbN9IId6 a+vy3DmRvrUBirr7/LjyMwUIVHa6DZWK0BeVd56IsfndfQEOAg7nHIOh9Nk4Sr+uCuJg 0gOhMb3t58yvmRpV879YwvbxgoM3sWNHaBUxo4y11/2LwYIIg8Qcpdd71xpwLWmyoW9Y ut/JgekQDhBm9du0q0Fm0EoMNWRb1B3kD4AgL8fz498aARpgjPLOzKymlWaOqFHlSjbq KTIbEvjXZtXXYoa+lzK2LJ/Fmor82aPo8hXOrlK2o7wALABl6hd8dy00hl0PhfMEY96Q cAKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695592347; x=1696197147; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x1mUiu1NbtoOEm28VDfVFWd43xm6wsUmZ3K7SF3CDig=; b=vWkTAGGMu8sS/U3NavdIEe5TPNj7Yi3fsz3po/dacwldq6dl4kaNgG5CSl9AIEtjQI XryFFpJTZVIxZv3sPK0IvqwI043BCkaiYWxzuCe8R4mMa13CVjtHRrXIlN8VrKPW4l71 y4+2PSV/lhnYCJB92pZMqswGi0nWZ4IoawTdiOs3FuGmW1Fz2mjaJPNtq0h3clpky1GN VZxZ713LX/0ujjsQg8RDLqjkjum0qHnwvYKv9KJgTX1jZ6gFD+8gWwTwX1mR9JGzhWUY 2qiz+owmM17G/LYdeaWJNMpG31u2MtGSYmRhDi3U3yRI8coq0zpOeapX3iUmAjNsdk5S /Tqw== X-Gm-Message-State: AOJu0YyX9dc0l0TnMvSEJ5yh3hhNEouX/GG7uPnYbp0df+aAwFNlvFNc FOgCk/t0q/jE3J8x/S2c+s0= X-Google-Smtp-Source: AGHT+IHpEl+lvIf+Tqc9qxedHbLstx3mEYRJvB/o8BKaKtHY726EWq1uOjTKkU35/PYeZ03RFhJuuw== X-Received: by 2002:a5d:5904:0:b0:317:6579:2b9f with SMTP id v4-20020a5d5904000000b0031765792b9fmr3835926wrd.30.1695592347329; Sun, 24 Sep 2023 14:52:27 -0700 (PDT) Received: from spiri.. ([2a02:2f08:a301:7000:1bc9:cab8:e784:6ddb]) by smtp.gmail.com with ESMTPSA id c10-20020a5d4f0a000000b0031f3ad17b2csm10144444wru.52.2023.09.24.14.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 14:52:27 -0700 (PDT) From: alisadariana@gmail.com Cc: Alisa-Dariana Roman , Jonathan Cameron , Lars-Peter Clausen , Alexandru Tachici , Michael Hennerich , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/3] iio: adc: ad7192: Improve f_order computation Date: Mon, 25 Sep 2023 00:51:47 +0300 Message-Id: <20230924215148.102491-3-alisadariana@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230924215148.102491-1-alisadariana@gmail.com> References: <20230924215148.102491-1-alisadariana@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alisa-Dariana Roman Instead of using the f_order member of ad7192_state, a function that computes the f_order coefficient makes more sense. This coefficient is a function of the sinc filter and chop filter states. Remove f_order member of ad7192_state structure. Instead use ad7192_compute_f_order function to compute the f_order coefficient according to the sinc filter and chop filter states passed as parameters. Add ad7192_get_f_order function that returns the current f_order coefficient of the device. Add ad7192_compute_f_adc function that computes the f_adc value according to the sinc filter and chop filter states passed as parameters. Add ad7192_get_f_adc function that returns the current f_adc value of the device. Signed-off-by: Alisa-Dariana Roman --- drivers/iio/adc/ad7192.c | 62 +++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c index d693f2ce8a20..0f9d33002d35 100644 --- a/drivers/iio/adc/ad7192.c +++ b/drivers/iio/adc/ad7192.c @@ -179,7 +179,6 @@ struct ad7192_state { struct clk *mclk; u16 int_vref_mv; u32 fclk; - u32 f_order; u32 mode; u32 conf; u32 scale_avail[8][2]; @@ -419,7 +418,6 @@ static int ad7192_setup(struct iio_dev *indio_dev, stru= ct device_node *np) st->conf |=3D AD7192_CONF_REFSEL; =20 st->conf &=3D ~AD7192_CONF_CHOP; - st->f_order =3D AD7192_NO_SYNC_FILTER; =20 buf_en =3D of_property_read_bool(np, "adi,buffer-enable"); if (buf_en) @@ -530,22 +528,60 @@ static ssize_t ad7192_set(struct device *dev, return ret ? ret : len; } =20 +static int ad7192_compute_f_order(bool sinc3_en, bool chop_en) +{ + if (!chop_en) + return 1; + + if (sinc3_en) + return AD7192_SYNC3_FILTER; + + return AD7192_SYNC4_FILTER; +} + +static int ad7192_get_f_order(struct ad7192_state *st) +{ + bool sinc3_en, chop_en; + + sinc3_en =3D FIELD_GET(AD7192_MODE_SINC3, st->mode); + chop_en =3D FIELD_GET(AD7192_CONF_CHOP, st->conf); + + return ad7192_compute_f_order(sinc3_en, chop_en); +} + +static int ad7192_compute_f_adc(struct ad7192_state *st, bool sinc3_en, + bool chop_en) +{ + unsigned int f_order =3D ad7192_compute_f_order(sinc3_en, chop_en); + + return DIV_ROUND_CLOSEST(st->fclk, + f_order * FIELD_GET(AD7192_MODE_RATE_MASK, st->mode)); +} + +static int ad7192_get_f_adc(struct ad7192_state *st) +{ + unsigned int f_order =3D ad7192_get_f_order(st); + + return DIV_ROUND_CLOSEST(st->fclk, + f_order * FIELD_GET(AD7192_MODE_RATE_MASK, st->mode)); +} + static void ad7192_get_available_filter_freq(struct ad7192_state *st, int *freq) { unsigned int fadc; =20 /* Formulas for filter at page 25 of the datasheet */ - fadc =3D DIV_ROUND_CLOSEST(st->fclk, - AD7192_SYNC4_FILTER * FIELD_GET(AD7192_MODE_RATE_MASK, st->mode)); + fadc =3D ad7192_compute_f_adc(st, false, true); freq[0] =3D DIV_ROUND_CLOSEST(fadc * 240, 1024); =20 - fadc =3D DIV_ROUND_CLOSEST(st->fclk, - AD7192_SYNC3_FILTER * FIELD_GET(AD7192_MODE_RATE_MASK, st->mode)); + fadc =3D ad7192_compute_f_adc(st, true, true); freq[1] =3D DIV_ROUND_CLOSEST(fadc * 240, 1024); =20 - fadc =3D DIV_ROUND_CLOSEST(st->fclk, FIELD_GET(AD7192_MODE_RATE_MASK, st-= >mode)); + fadc =3D ad7192_compute_f_adc(st, false, false); freq[2] =3D DIV_ROUND_CLOSEST(fadc * 230, 1024); + + fadc =3D ad7192_compute_f_adc(st, true, false); freq[3] =3D DIV_ROUND_CLOSEST(fadc * 272, 1024); } =20 @@ -628,25 +664,21 @@ static int ad7192_set_3db_filter_freq(struct ad7192_s= tate *st, =20 switch (idx) { case 0: - st->f_order =3D AD7192_SYNC4_FILTER; st->mode &=3D ~AD7192_MODE_SINC3; =20 st->conf |=3D AD7192_CONF_CHOP; break; case 1: - st->f_order =3D AD7192_SYNC3_FILTER; st->mode |=3D AD7192_MODE_SINC3; =20 st->conf |=3D AD7192_CONF_CHOP; break; case 2: - st->f_order =3D AD7192_NO_SYNC_FILTER; st->mode &=3D ~AD7192_MODE_SINC3; =20 st->conf &=3D ~AD7192_CONF_CHOP; break; case 3: - st->f_order =3D AD7192_NO_SYNC_FILTER; st->mode |=3D AD7192_MODE_SINC3; =20 st->conf &=3D ~AD7192_CONF_CHOP; @@ -664,8 +696,7 @@ static int ad7192_get_3db_filter_freq(struct ad7192_sta= te *st) { unsigned int fadc; =20 - fadc =3D DIV_ROUND_CLOSEST(st->fclk, - st->f_order * FIELD_GET(AD7192_MODE_RATE_MASK, st->mode)); + fadc =3D ad7192_get_f_adc(st); =20 if (FIELD_GET(AD7192_CONF_CHOP, st->conf)) return DIV_ROUND_CLOSEST(fadc * 240, 1024); @@ -713,8 +744,7 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, *val -=3D 273 * ad7192_get_temp_scale(unipolar); return IIO_VAL_INT; case IIO_CHAN_INFO_SAMP_FREQ: - *val =3D st->fclk / - (st->f_order * 1024 * FIELD_GET(AD7192_MODE_RATE_MASK, st->mode)); + *val =3D DIV_ROUND_CLOSEST(ad7192_get_f_adc(st), 1024); return IIO_VAL_INT; case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: *val =3D ad7192_get_3db_filter_freq(st); @@ -764,7 +794,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev, break; } =20 - div =3D st->fclk / (val * st->f_order * 1024); + div =3D st->fclk / (val * ad7192_get_f_order(st) * 1024); if (div < 1 || div > 1023) { ret =3D -EINVAL; break; --=20 2.34.1 From nobody Fri Feb 13 12:29:17 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C1B8CE7A8A for ; Sun, 24 Sep 2023 21:52:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230432AbjIXVwn (ORCPT ); Sun, 24 Sep 2023 17:52:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbjIXVwl (ORCPT ); Sun, 24 Sep 2023 17:52:41 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE06311B; Sun, 24 Sep 2023 14:52:32 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-405524e6769so16681085e9.1; Sun, 24 Sep 2023 14:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695592351; x=1696197151; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Sm3QFQM6KQv6uCCfjkS4IRkehQ2aS8upGUO2t0heBs4=; b=WwgzOtQEIekG3tgsTKR+tkgF+TJ6tlzOzL5qAwc9/RP8I4q9jctuTWrRqLjlrG0RXe +ut2mtgikOHzcUTjCTI2EHiajGA+Yg8Ulh1ET/zrj8ahXgjObpgJM0t2S4XgcR/x8SlT W/u4E2pxoEf/hF6W+Ea9cYb+ZugIRPly9So9ax0g15j+uQ4f4uGWENUhUsG6Pgu6unwm PIC11uVvJrH4eik3AktkQRUVQtI/jPrx/U09VAoRbgefw8RHk2t6Xv0VCa4+DrX/RKz4 Dj0gQS8pJaD4Y8w0dWo3Cj7Tg7PXKqvDLQNrDMeD7+f6o6xijEO6zsA2AHgAJumLNdEJ fYug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695592351; x=1696197151; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Sm3QFQM6KQv6uCCfjkS4IRkehQ2aS8upGUO2t0heBs4=; b=o/yHVbo9AvxPHx+lLhvFBwbqan9FSxX4/jCRj+cdN7xBOTApXU0g3764HLjH+ZmH1d ivedI4p0TUMYo15sCmKPu1ILP0zQGSoA6FQN2j0DwSEMij3ZAbw5T1IRvYFEbDf7MsFx Bm7ZYpytdJwmK6kfWhvZaOYG1LCi0SQh1h2+pPYO+cmLdZ8EyIIrzGJAv7xK2BBDLP6p UGQVw9apBujpiPiGY3RjR2RaC9iLvhhiTvr/o1pqNr14iLafaPb3s5oZYUPAjjTpz0a6 qD88+nEoXuvZhpPIjIIi9y2SZL0BWs/kNSn13gmqBo2FsoS6+5TlOXkgXZnM4qz4qi92 l1nw== X-Gm-Message-State: AOJu0YwLWg10iALJy7UTG253Ci1N+V/LRaF+3xrzXKHkcq34P7Hz7sf2 +5e5RJkbN3tbXuSCZEb+hXg= X-Google-Smtp-Source: AGHT+IGq0fT5+1cE/uaYP23GtnQz3qbYryUhOhtTe6OaAJAaGGs63Pzx7GwJLcAwIOtD8AjY5g2GFQ== X-Received: by 2002:a1c:4b1a:0:b0:3fe:1fd9:bedf with SMTP id y26-20020a1c4b1a000000b003fe1fd9bedfmr3824047wma.11.1695592351142; Sun, 24 Sep 2023 14:52:31 -0700 (PDT) Received: from spiri.. ([2a02:2f08:a301:7000:1bc9:cab8:e784:6ddb]) by smtp.gmail.com with ESMTPSA id c10-20020a5d4f0a000000b0031f3ad17b2csm10144444wru.52.2023.09.24.14.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 14:52:30 -0700 (PDT) From: alisadariana@gmail.com Cc: Alisa-Dariana Roman , Jonathan Cameron , Lars-Peter Clausen , Alexandru Tachici , Michael Hennerich , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/3] iio: adc: ad7192: Add fast settling support Date: Mon, 25 Sep 2023 00:51:48 +0300 Message-Id: <20230924215148.102491-4-alisadariana@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230924215148.102491-1-alisadariana@gmail.com> References: <20230924215148.102491-1-alisadariana@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alisa-Dariana Roman Add fast settling mode support for AD7193. Add fast_settling_average_factor attribute. Expose to user the current value of the fast settling average factor. User can change the value by writing a new one. Add fast_settling_average_factor_available attribute. Expose to user possible values for the fast settling average factor. Signed-off-by: Alisa-Dariana Roman --- .../ABI/testing/sysfs-bus-iio-adc-ad7192 | 18 +++ drivers/iio/adc/ad7192.c | 128 ++++++++++++++++-- 2 files changed, 134 insertions(+), 12 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio-adc-ad7192 b/Documenta= tion/ABI/testing/sysfs-bus-iio-adc-ad7192 index f8315202c8f0..780c6841b0c3 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio-adc-ad7192 +++ b/Documentation/ABI/testing/sysfs-bus-iio-adc-ad7192 @@ -19,6 +19,24 @@ Description: the bridge can be disconnected (when it is not being used using the bridge_switch_en attribute. =20 +What: /sys/bus/iio/devices/iio:deviceX/fast_settling_average_factor +KernelVersion: +Contact: linux-iio@vger.kernel.org +Description: + This attribute, if available, is used to activate or deactivate + fast settling mode and set the value of the average factor to + 1, 2, 8 or 16. If the average factor is set to 1, the fast + settling mode is disabled. The data from the sinc filter is + averaged by chosen value. The averaging reduces the output data + rate for a given FS word, however, the RMS noise improves. + +What: /sys/bus/iio/devices/iio:deviceX/fast_settling_average_factor_avail= able +KernelVersion: +Contact: linux-iio@vger.kernel.org +Description: + Reading returns a list with the possible values for the fast + settling average factor: 1, 2, 8, 16. + What: /sys/bus/iio/devices/iio:deviceX/in_voltagex_sys_calibration KernelVersion: Contact: linux-iio@vger.kernel.org diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c index 0f9d33002d35..3b7de23b024e 100644 --- a/drivers/iio/adc/ad7192.c +++ b/drivers/iio/adc/ad7192.c @@ -60,6 +60,8 @@ #define AD7192_MODE_SEL_MASK GENMASK(23, 21) /* Operation Mode Select Mask= */ #define AD7192_MODE_STA_MASK BIT(20) /* Status Register transmission Mask = */ #define AD7192_MODE_CLKSRC_MASK GENMASK(19, 18) /* Clock Source Select Mas= k */ +#define AD7192_MODE_AVG_MASK GENMASK(17, 16) + /* Fast Settling Filter Average Select Mask (AD7193 only) */ #define AD7192_MODE_SINC3 BIT(15) /* SINC3 Filter Select */ #define AD7192_MODE_ENPAR BIT(13) /* Parity Enable */ #define AD7192_MODE_CLKDIV BIT(12) /* Clock divide by 2 (AD7190/2 only)*/ @@ -182,6 +184,7 @@ struct ad7192_state { u32 mode; u32 conf; u32 scale_avail[8][2]; + u8 avg_avail[4]; u8 gpocon; u8 clock_sel; struct mutex lock; /* protect sensor state */ @@ -459,6 +462,13 @@ static int ad7192_setup(struct iio_dev *indio_dev, str= uct device_node *np) st->scale_avail[i][0] =3D scale_uv; } =20 + if (st->chip_info->chip_id =3D=3D CHIPID_AD7193) { + st->avg_avail[0] =3D 1; + st->avg_avail[1] =3D 2; + st->avg_avail[2] =3D 8; + st->avg_avail[3] =3D 16; + } + return 0; } =20 @@ -483,6 +493,18 @@ static ssize_t ad7192_show_bridge_switch(struct device= *dev, FIELD_GET(AD7192_GPOCON_BPDSW, st->gpocon)); } =20 +static ssize_t ad7192_show_average_factor(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev =3D dev_to_iio_dev(dev); + struct ad7192_state *st =3D iio_priv(indio_dev); + u8 avg_factor_index; + + avg_factor_index =3D FIELD_GET(AD7192_MODE_AVG_MASK, st->mode); + return sysfs_emit(buf, "%d\n", st->avg_avail[avg_factor_index]); +} + static ssize_t ad7192_set(struct device *dev, struct device_attribute *attr, const char *buf, @@ -491,12 +513,10 @@ static ssize_t ad7192_set(struct device *dev, struct iio_dev *indio_dev =3D dev_to_iio_dev(dev); struct ad7192_state *st =3D iio_priv(indio_dev); struct iio_dev_attr *this_attr =3D to_iio_dev_attr(attr); + bool val, ret_einval; + u8 val_avg_factor; + unsigned int i; int ret; - bool val; - - ret =3D kstrtobool(buf, &val); - if (ret < 0) - return ret; =20 ret =3D iio_device_claim_direct_mode(indio_dev); if (ret) @@ -504,6 +524,10 @@ static ssize_t ad7192_set(struct device *dev, =20 switch ((u32)this_attr->address) { case AD7192_REG_GPOCON: + ret =3D kstrtobool(buf, &val); + if (ret < 0) + return ret; + if (val) st->gpocon |=3D AD7192_GPOCON_BPDSW; else @@ -512,6 +536,10 @@ static ssize_t ad7192_set(struct device *dev, ad_sd_write_reg(&st->sd, AD7192_REG_GPOCON, 1, st->gpocon); break; case AD7192_REG_CONF: + ret =3D kstrtobool(buf, &val); + if (ret < 0) + return ret; + if (val) st->conf |=3D AD7192_CONF_ACX; else @@ -519,6 +547,27 @@ static ssize_t ad7192_set(struct device *dev, =20 ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, st->conf); break; + case AD7192_REG_MODE: + ret =3D kstrtou8(buf, 10, &val_avg_factor); + if (ret < 0) + return ret; + + ret_einval =3D true; + for (i =3D 0; i < ARRAY_SIZE(st->avg_avail); i++) { + if (val_avg_factor =3D=3D st->avg_avail[i]) { + st->mode &=3D ~AD7192_MODE_AVG_MASK; + st->mode |=3D FIELD_PREP(AD7192_MODE_AVG_MASK, i); + ret_einval =3D false; + } + } + + if (ret_einval) + return -EINVAL; + + ret =3D ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode); + if (ret) + return ret; + break; default: ret =3D -EINVAL; } @@ -528,15 +577,22 @@ static ssize_t ad7192_set(struct device *dev, return ret ? ret : len; } =20 -static int ad7192_compute_f_order(bool sinc3_en, bool chop_en) +static int ad7192_compute_f_order(struct ad7192_state *st, bool sinc3_en, = bool chop_en) { - if (!chop_en) + u8 avg_factor; + u8 avg_factor_selected; + + avg_factor_selected =3D FIELD_GET(AD7192_MODE_AVG_MASK, st->mode); + + if (!avg_factor_selected && !chop_en) return 1; =20 + avg_factor =3D st->avg_avail[avg_factor_selected]; + if (sinc3_en) - return AD7192_SYNC3_FILTER; + return AD7192_SYNC3_FILTER + avg_factor - 1; =20 - return AD7192_SYNC4_FILTER; + return AD7192_SYNC4_FILTER + avg_factor - 1; } =20 static int ad7192_get_f_order(struct ad7192_state *st) @@ -546,13 +602,13 @@ static int ad7192_get_f_order(struct ad7192_state *st) sinc3_en =3D FIELD_GET(AD7192_MODE_SINC3, st->mode); chop_en =3D FIELD_GET(AD7192_CONF_CHOP, st->conf); =20 - return ad7192_compute_f_order(sinc3_en, chop_en); + return ad7192_compute_f_order(st, sinc3_en, chop_en); } =20 static int ad7192_compute_f_adc(struct ad7192_state *st, bool sinc3_en, bool chop_en) { - unsigned int f_order =3D ad7192_compute_f_order(sinc3_en, chop_en); + unsigned int f_order =3D ad7192_compute_f_order(st, sinc3_en, chop_en); =20 return DIV_ROUND_CLOSEST(st->fclk, f_order * FIELD_GET(AD7192_MODE_RATE_MASK, st->mode)); @@ -605,9 +661,29 @@ static ssize_t ad7192_show_filter_avail(struct device = *dev, return len; } =20 +static ssize_t ad7192_show_avg_factor_avail(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev =3D dev_to_iio_dev(dev); + struct ad7192_state *st =3D iio_priv(indio_dev); + unsigned int i; + size_t len =3D 0; + + for (i =3D 0; i < ARRAY_SIZE(st->avg_avail); i++) + len +=3D sysfs_emit_at(buf, len, "%d ", st->avg_avail[i]); + + buf[len - 1] =3D '\n'; + + return len; +} + static IIO_DEVICE_ATTR(filter_low_pass_3db_frequency_available, 0444, ad7192_show_filter_avail, NULL, 0); =20 +static IIO_DEVICE_ATTR(fast_settling_average_factor_available, + 0444, ad7192_show_avg_factor_avail, NULL, 0); + static IIO_DEVICE_ATTR(bridge_switch_en, 0644, ad7192_show_bridge_switch, ad7192_set, AD7192_REG_GPOCON); @@ -616,6 +692,10 @@ static IIO_DEVICE_ATTR(ac_excitation_en, 0644, ad7192_show_ac_excitation, ad7192_set, AD7192_REG_CONF); =20 +static IIO_DEVICE_ATTR(fast_settling_average_factor, 0644, + ad7192_show_average_factor, ad7192_set, + AD7192_REG_MODE); + static struct attribute *ad7192_attributes[] =3D { &iio_dev_attr_filter_low_pass_3db_frequency_available.dev_attr.attr, &iio_dev_attr_bridge_switch_en.dev_attr.attr, @@ -626,6 +706,18 @@ static const struct attribute_group ad7192_attribute_g= roup =3D { .attrs =3D ad7192_attributes, }; =20 +static struct attribute *ad7193_attributes[] =3D { + &iio_dev_attr_filter_low_pass_3db_frequency_available.dev_attr.attr, + &iio_dev_attr_bridge_switch_en.dev_attr.attr, + &iio_dev_attr_fast_settling_average_factor.dev_attr.attr, + &iio_dev_attr_fast_settling_average_factor_available.dev_attr.attr, + NULL +}; + +static const struct attribute_group ad7193_attribute_group =3D { + .attrs =3D ad7193_attributes, +}; + static struct attribute *ad7195_attributes[] =3D { &iio_dev_attr_filter_low_pass_3db_frequency_available.dev_attr.attr, &iio_dev_attr_bridge_switch_en.dev_attr.attr, @@ -882,6 +974,16 @@ static const struct iio_info ad7192_info =3D { .update_scan_mode =3D ad7192_update_scan_mode, }; =20 +static const struct iio_info ad7193_info =3D { + .read_raw =3D ad7192_read_raw, + .write_raw =3D ad7192_write_raw, + .write_raw_get_fmt =3D ad7192_write_raw_get_fmt, + .read_avail =3D ad7192_read_avail, + .attrs =3D &ad7193_attribute_group, + .validate_trigger =3D ad_sd_validate_trigger, + .update_scan_mode =3D ad7192_update_scan_mode, +}; + static const struct iio_info ad7195_info =3D { .read_raw =3D ad7192_read_raw, .write_raw =3D ad7192_write_raw, @@ -1056,7 +1158,9 @@ static int ad7192_probe(struct spi_device *spi) if (ret < 0) return ret; =20 - if (st->chip_info->chip_id =3D=3D CHIPID_AD7195) + if (st->chip_info->chip_id =3D=3D CHIPID_AD7193) + indio_dev->info =3D &ad7193_info; + else if (st->chip_info->chip_id =3D=3D CHIPID_AD7195) indio_dev->info =3D &ad7195_info; else indio_dev->info =3D &ad7192_info; --=20 2.34.1