From patchwork Wed Nov 27 20:01:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 13887346 Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D91A11537B9 for ; Wed, 27 Nov 2024 20:02:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732737771; cv=none; b=A3u/7NYc+EBWsUFCz/Epa3HOXsfKCBq5Grr6QWROEgZafAeQLzpiYwQqsWHZjIBbFJYL39asR597vw/8DWSuO9MFVpEJkw3n8AGG7bjFltvq1m7b9F16/IYI8C851wHgjDLUj5NOEKpcoiKbGbWinB7bMRAPWr0pmhoLdFFELvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732737771; c=relaxed/simple; bh=zRHRyZj9u8W2LqLLqjrSDlClSWY/ZCi+rinARacbnps=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TlMKFRA2ffBLQ4Cdmm3VozFFfcwsIjWImADAXeQY1fwHPEo2LDEsKz0iH1eh7RbHFRt3WC5cmqvgq5bcGiI3gvS4s8JbR8SJB/iQAajIa49JeFc+mGyUKYZOKHuLP5DIpspcD6bhaV0JN+5vsF0ZPNJ3OmvB1Lwrtgw5r7PlzhQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=EMbr239G; arc=none smtp.client-ip=209.85.160.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="EMbr239G" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-2968322f5feso135343fac.0 for ; Wed, 27 Nov 2024 12:02:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1732737768; x=1733342568; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EUqW/RG6GFljj5n4ZtmSErYGHBX90zPHoNRIF8yvn5Q=; b=EMbr239G+vNOPGVECM2Fu4lTHRRtWZFDABNntHR6JbcqYD+jB6ATXDh51dKcdz93vh qQhqhQOIVI13qJf4C+GkFVsl1hMD/iF5RbH78vC9rzZnWNUcjPr6rAhYRjBHkEISKSkb yiZis+GRD70Nht0zFxCiggqy/wcubl+6ls4G7M65zzUYDQ8lifb95joJvWFMwKgF1uLZ v38F4U1+3o26hT8G4yGaiF+wqFMyRTVBo9T77Mx37S3KrEn7dL1o4BRQ4q8Z41HB8E8G d6YFCR/mijUe+JoHEfriIfBHFNCLK1P9CXDSesqVBtz+ykGlRTQenkBfMucXOEm6GsT2 gRKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732737768; x=1733342568; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EUqW/RG6GFljj5n4ZtmSErYGHBX90zPHoNRIF8yvn5Q=; b=wqoZUiHKFZZE3l6I/CgJ8mt+XR9OLysQ5OHGZk8Xfz9cuUgt+YdH2g9/WUH2GaaLpF P1ITsGQQvyZh1oks/Fti2n3xQP6cH+1reWtBfNtWa26NwNo1X5IfVEN58P4GlNmIVHrj vEEqx38uaZ3ri2CO6IHM9BEsSTbRECenVt57Zh3U79qL3QpkjdlHtqUVcjGhrSDtkvNN JkLCFwtIURt/RAnB5SGnxGC1PZD9+1a3aD1VY2qzVDVIOeFeYsTdqpVPeH/9t5oTxkPx ML/MJFIiRStpVyZuejgNiIsXUcpz9mAerzT3R68rZ3aVP9enoua29oh380Lqsc58GXqK vq+Q== X-Forwarded-Encrypted: i=1; AJvYcCXDrv9Sl53qYpRhoe/V/U/livqFZ4fTGdPf7oDuh/D6nGPfhgEHVIsuUjTaIMmABf6/xUyY8UiJMl4=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7PzCfNKzKolGFhtyKNjPeAh0/kW4z+G/BZt/F8mPp5VXduVeX Ki/273EK0YBByPOQkP8BYMHD6Lk4oAnwdm5Py2YFGaB9+sGFanm9pHUpXV3/ufg= X-Gm-Gg: ASbGnctV88itP6/J8Cgmg2uZqbqGYobPahVU5mUykB4c5D1NTvRi6P46hLUaWYq6Fpp eL8ee/fsfdyK+ERl2b7egrRvfO4JA3E2robu5Yzk9iZcXYjJ7kKz3RIBhNnOReySi4d1lAWkoIG 1BuI95x8vW9fvmP5ivZXq6CstmChcTrFtgkOFchzfLOjvfM0NXMaJHl5zjymONNrzebWspyFfn0 7Wfk31NFuQkcKSE108cmmGQ8HxXgsQFp955+bRX/kNhvA3hyugPCSz/851L+Dhx+2Fl6MbWrLfg zvrGRg== X-Google-Smtp-Source: AGHT+IHeUY/rHu6dEk9u0KJC/fgJM/4Ys4OZzsjFEIvS+qqtGNLwZKanKVMkIm6RVrrtyE4uluGpsA== X-Received: by 2002:a05:6871:728e:b0:287:e3e1:15f2 with SMTP id 586e51a60fabf-29dc41cb355mr4902257fac.25.1732737767948; Wed, 27 Nov 2024 12:02:47 -0800 (PST) Received: from [127.0.1.1] (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2971d6654e9sm5069542fac.24.2024.11.27.12.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2024 12:02:46 -0800 (PST) From: David Lechner Date: Wed, 27 Nov 2024 14:01:53 -0600 Subject: [PATCH v2 1/3] iio: adc: ad7173: fix using shared static info struct Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241127-iio-adc-ad7313-fix-non-const-info-struct-v2-1-b6d7022b7466@baylibre.com> References: <20241127-iio-adc-ad7313-fix-non-const-info-struct-v2-0-b6d7022b7466@baylibre.com> In-Reply-To: <20241127-iio-adc-ad7313-fix-non-const-info-struct-v2-0-b6d7022b7466@baylibre.com> To: Jonathan Cameron , Dumitru Ceclan Cc: Michael Hennerich , Nuno Sa , Michael Walle , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Guillaume Ranquet , David Lechner X-Mailer: b4 0.14.1 Fix a possible race condition during driver probe in the ad7173 driver due to using a shared static info struct. If more that one instance of the driver is probed at the same time, some of the info could be overwritten by the other instance, leading to incorrect operation. To fix this, make the static info struct const so that it is read-only and make a copy of the info struct for each instance of the driver that can be modified. Reported-by: Uwe Kleine-König Fixes: 76a1e6a42802 ("iio: adc: ad7173: add AD7173 driver") Signed-off-by: David Lechner --- drivers/iio/adc/ad7173.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c index 29ff9c7036c0..c83c4c90b090 100644 --- a/drivers/iio/adc/ad7173.c +++ b/drivers/iio/adc/ad7173.c @@ -199,6 +199,7 @@ struct ad7173_channel { struct ad7173_state { struct ad_sigma_delta sd; + struct ad_sigma_delta_info sigma_delta_info; const struct ad7173_device_info *info; struct ad7173_channel *channels; struct regulator_bulk_data regulators[3]; @@ -752,7 +753,7 @@ static int ad7173_disable_one(struct ad_sigma_delta *sd, unsigned int chan) return ad_sd_write_reg(sd, AD7173_REG_CH(chan), 2, 0); } -static struct ad_sigma_delta_info ad7173_sigma_delta_info = { +static const struct ad_sigma_delta_info ad7173_sigma_delta_info = { .set_channel = ad7173_set_channel, .append_status = ad7173_append_status, .disable_all = ad7173_disable_all, @@ -1401,7 +1402,7 @@ static int ad7173_fw_parse_device_config(struct iio_dev *indio_dev) if (ret < 0) return dev_err_probe(dev, ret, "Interrupt 'rdy' is required\n"); - ad7173_sigma_delta_info.irq_line = ret; + st->sigma_delta_info.irq_line = ret; return ad7173_fw_parse_channel_config(indio_dev); } @@ -1434,8 +1435,9 @@ static int ad7173_probe(struct spi_device *spi) spi->mode = SPI_MODE_3; spi_setup(spi); - ad7173_sigma_delta_info.num_slots = st->info->num_configs; - ret = ad_sd_init(&st->sd, indio_dev, spi, &ad7173_sigma_delta_info); + st->sigma_delta_info = ad7173_sigma_delta_info; + st->sigma_delta_info.num_slots = st->info->num_configs; + ret = ad_sd_init(&st->sd, indio_dev, spi, &st->sigma_delta_info); if (ret) return ret; From patchwork Wed Nov 27 20:01:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 13887347 Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B9F8202F9D for ; Wed, 27 Nov 2024 20:02:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732737773; cv=none; b=JaKFnEPjaD7iGWV2HkC7kywOgsL/qv4cqoAsJD6yG99NGHmU44e9822tu3WvhUZPsMXqjzbUezHEmX4/ZZjNPB7cwYVK2xA51a3b9nrm/uFiLQpPWWUWlPk1qiXm2O/YusHSwuWeBFnsJ45oajTe5tBYctxpBSJYKW6R8hw+CdE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732737773; c=relaxed/simple; bh=5TCYTJvP2WZJgf7/Y+kXbTufENMjzuYAF//0sF6enLY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BVd6V3RXj5OoMuCzuH/i6o/nUgjcl27orPyiRCEBHL6BbBnPHAXKVjOPh/UirmMk4YDYk1Nw+dYTrthFXTH4h9W+1cb4wKQozcV4n2ZiApsJKsx4GlQr4FRt8n6YDBbZi86kbwjkr2mfFCI22DR+cxJsEXeWdE7XWVbpbFjYo/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=JGtuk5d4; arc=none smtp.client-ip=209.85.160.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="JGtuk5d4" Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-296994dd3bfso132264fac.0 for ; Wed, 27 Nov 2024 12:02:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1732737771; x=1733342571; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=5JX1ZaR7yBz56VsJHDUjy+OWYMwBynImasSkSTHjxkM=; b=JGtuk5d4iFK+Sozz7rCH96Np0VrQIQJmcLviLpR2InbX/NsbKK6N+ZG08+8p9zSHoC iJm7z3CY+fE1XRcVkIKvNBEdtjXsNdyXAhZA5pBk7Gm00uRlAxSBlFG/gTsZ/4bZ5euU T+TfUVrAmqsQ9Wf2Tw15E+/WUl9/nn5R62GNA1jbJt2AeWR43Frc7UBoeqh5EAieYjLf LGh2tdxkLsGVhvRof84VRoLV9Kq9PGirkdfjAn+Le4hC+dpI2fCLQ6Z1vMHl1rR9Z1/G LF5pfIci0HYM6KFe8kJbfdcaBlrGPjI7HNa6U8IaxVidRujrUah0R2KYVBF2w9cY4qnD k4jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732737771; x=1733342571; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5JX1ZaR7yBz56VsJHDUjy+OWYMwBynImasSkSTHjxkM=; b=lgf+JazwufZGeKCcx2Ail84kOVq9x9QrTotEPmNuBXr+uPMvDtQE74Xir1dZuUjbCN gC+OJewFzN3xwNR2Skg5krtH1rVrVNqSYPWBRSNOoGocUWfSgAWH6iPuT96YmLtNLD0M V4A/m+xHIwq446DViOh5B4JoftGPZSVbSpdY5oUxXJ8ptQGPhDWqO7ken/58LBQQ/cM8 9hBh/38b6NohHl6dI9JAXnSQtQP5btQ0wcJ2rFHMvDxCrVBw1r2bdyRA8KXBI/2EKTKZ lfJJwDoy9F42y2ncahNkvg5N1xNNpsa+G5wTYimSw4A9g7N1DMI4Lkkfd5p5s+QBIw5r 0/6A== X-Forwarded-Encrypted: i=1; AJvYcCVlisan6/VPkJDCE5/HmQnn5UXNzuTU8WwomabTBFzzknPWeaev5nfSrLMPjTbty0I5v1DP55Bm9cY=@vger.kernel.org X-Gm-Message-State: AOJu0YwEzbIaJ144JFmg+PVjNMRXJq+lwHPi/i3ojPAVtdmNwiG0+Tr3 HB3bm4QLK5ib/7a+a6qZCkyxh60Hnrfg2lCuxhKh/OQTOM2eCrayBqfXD41vSmM= X-Gm-Gg: ASbGncuAHJPDO3Xk+NeQVphLO4RPkumzQ4/BRosyN0H7dUIqr4FhGzfZHdBQFnXaeU1 +PnDJIxyyzQjriXNR38dEir33bT6jwfwDJCF24iUjLxkanSopVg48ObrpU15TKJ4E80941T1+or se/vY4FZ0WuLpVwGF0J74j8tM1vSvPS1YtR3vff4oN3K9FOB/mpJSDhwli66D5951tfyhRC4QfP FG0RWi3lB0he5UKFPCgKJw2tgfxm/WJphY4OjD2zQZhpq+yvi0vutF57Tb6br5CEBDGq6l/LQIw +5h9xA== X-Google-Smtp-Source: AGHT+IH3/JMmldWEvDZI/7pQLqFpG5vO7av4PDKLlt8J4dtgADQfNKl2QcIkx/c7rjBem5arpbItkg== X-Received: by 2002:a05:6870:819b:b0:270:205a:4070 with SMTP id 586e51a60fabf-29dc400846dmr4279733fac.14.1732737770743; Wed, 27 Nov 2024 12:02:50 -0800 (PST) Received: from [127.0.1.1] (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2971d6654e9sm5069542fac.24.2024.11.27.12.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2024 12:02:49 -0800 (PST) From: David Lechner Date: Wed, 27 Nov 2024 14:01:54 -0600 Subject: [PATCH v2 2/3] iio: adc: ad7173: remove special handling for irq number Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241127-iio-adc-ad7313-fix-non-const-info-struct-v2-2-b6d7022b7466@baylibre.com> References: <20241127-iio-adc-ad7313-fix-non-const-info-struct-v2-0-b6d7022b7466@baylibre.com> In-Reply-To: <20241127-iio-adc-ad7313-fix-non-const-info-struct-v2-0-b6d7022b7466@baylibre.com> To: Jonathan Cameron , Dumitru Ceclan Cc: Michael Hennerich , Nuno Sa , Michael Walle , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Guillaume Ranquet , David Lechner X-Mailer: b4 0.14.1 Remove the int irq_line field in struct ad_sigma_delta_info and all code that referenced it. This struct is intended to be used as static const data. Currently, the only user that doesn't uses the static const struct directly, namely the ad7173 driver is making a copy of this struct to be able to modify the irq_line field. However, this field is written and never used due to the fact that ad_sd_init() which reads the field is called before ad7173_fw_parse_device_config() which writes it. The runtime behavior does not change since ad_sd_init() was already (unintentionally) being called with irq_line = 0. But, even though this could be considered a bug, the behavior was still correct. The SPI subsystem always uses the first interrupt in the interrupts array from the devicetree and the devicetree bindings for this family of chips specify that the RDY interrupt is always the first interrupt. Therefore, we don't actually need the special call to fwnode_irq_get_byname(), so it is removed in this patch instead of moving it to the correct place. Signed-off-by: David Lechner --- v2 changes: * Fixed chip name is subject line * Uwe's comment made me realize that the special case was actually never being used because of the ordering bug and could safely be removed rather than trying to preserve it. --- drivers/iio/adc/ad7173.c | 8 +------- drivers/iio/adc/ad_sigma_delta.c | 5 +---- include/linux/iio/adc/ad_sigma_delta.h | 2 -- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c index c83c4c90b090..52fce43e4ce1 100644 --- a/drivers/iio/adc/ad7173.c +++ b/drivers/iio/adc/ad7173.c @@ -199,7 +199,7 @@ struct ad7173_channel { struct ad7173_state { struct ad_sigma_delta sd; - struct ad_sigma_delta_info sigma_delta_info; + struct ad_sigma_delta_chip_info sigma_delta_info; const struct ad7173_device_info *info; struct ad7173_channel *channels; struct regulator_bulk_data regulators[3]; @@ -1398,12 +1398,6 @@ static int ad7173_fw_parse_device_config(struct iio_dev *indio_dev) return ret; } - ret = fwnode_irq_get_byname(dev_fwnode(dev), "rdy"); - if (ret < 0) - return dev_err_probe(dev, ret, "Interrupt 'rdy' is required\n"); - - st->sigma_delta_info.irq_line = ret; - return ad7173_fw_parse_channel_config(indio_dev); } diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c index 2f3b61765055..38c48743712e 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -674,10 +674,7 @@ int ad_sd_init(struct ad_sigma_delta *sigma_delta, struct iio_dev *indio_dev, } } - if (info->irq_line) - sigma_delta->irq_line = info->irq_line; - else - sigma_delta->irq_line = spi->irq; + sigma_delta->irq_line = spi->irq; iio_device_set_drvdata(indio_dev, sigma_delta); diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc/ad_sigma_delta.h index f8c1d2505940..44f487323a43 100644 --- a/include/linux/iio/adc/ad_sigma_delta.h +++ b/include/linux/iio/adc/ad_sigma_delta.h @@ -52,7 +52,6 @@ struct iio_dev; * be used. * @irq_flags: flags for the interrupt used by the triggered buffer * @num_slots: Number of sequencer slots - * @irq_line: IRQ for reading conversions. If 0, spi->irq will be used */ struct ad_sigma_delta_info { int (*set_channel)(struct ad_sigma_delta *, unsigned int channel); @@ -68,7 +67,6 @@ struct ad_sigma_delta_info { unsigned int data_reg; unsigned long irq_flags; unsigned int num_slots; - int irq_line; }; /** From patchwork Wed Nov 27 20:01:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 13887348 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CB0420125E for ; Wed, 27 Nov 2024 20:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732737777; cv=none; b=DZISkOE7XAF/Yq7Wn6LP4EoZWCeswBBXat9azplLsJFPwTPsPqwtJNSXULaBmM7fZH24HCiNHmf8HRE4KwtlC6ajq+q6UPZ6iHDmOx3DQ7coIDODMVbN2BCqdD/SDuWDP5l848H0GX43qyk1eg79C3KSH2cUxuXSRl0r1TvgrhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732737777; c=relaxed/simple; bh=4BVmwrO6f4rSKD973mZxI9Fej/ysGUFCFf4JkT7hFMo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kSkybjfEZ0SawRUOfYG9AIoL1euDn6P6Dvd8Tip+kYH18YEGYNz4u9UPZn1h7zM3vn1bA6G6WEy4qE56gFXgOUhO6Jj2bv2vyiWy5LvyOuIJ/WNdbY29JCDfelRECLeXUkNzPzUCNz3VtNM7Uk7IKfPBtvGJxUQVFssvOvBzsA8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=vOwLSy3t; arc=none smtp.client-ip=209.85.160.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="vOwLSy3t" Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-29737adb604so119302fac.1 for ; Wed, 27 Nov 2024 12:02:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1732737773; x=1733342573; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=kbWcnHlTYjWOWnztnkEnNQiK3S2MaaLIm+X0q0D6Zgs=; b=vOwLSy3tt+x/2O78l8wnlizGahL+Jra/WPWfkRurJAQgoWmnv+8itY6XYE0o75DPye 8ecXtbOCQO/SED9CZmewDUWyyYC9U7g6iQ/GQGfWyHMyD2/X19unjIQzZHgZzwhU4qFz inmmkP8W4wX67J58V2hEcEyqLKiHRk46caTy1SsSeBbDVCplBDjXIuS7BMXNiqzcyO6/ DB+pQXccBSXvUKffgfLCZ+jRqD2ufKuen6+8S9n45sahLP/CSUMWC/gSd0MH1QROt1KD KjH49aM2C8QpVom1u4CUWUaUWdMnwUURNUBW8/v552tr0RlC3ThFy0q2He9oQEG3yJKp EHhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732737773; x=1733342573; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kbWcnHlTYjWOWnztnkEnNQiK3S2MaaLIm+X0q0D6Zgs=; b=GUr3pdtSbioYWksMZk0tcmmtyQpIHNZeBRTLxTodLLjQ6lkVDGg1CQdERsC7V9yJPO 0y5YW7ee0RX3dHTdwBh3zx8Md0Ljiq4bomggXgr5djCoVsLkcDOYE/ao6owm35tbCLzK EHGkz49dvzehUnUrAb0FUp/jhZ7l+mQ1J/z53IH1fHK0LHF3gm6JGzU1PjZ03lHO2yfr IgWmQd8XleqmmRFg8bdHPBvGG8NoflCnnuiqRYQrbalnh+aqagrkmzrCZ7nUwqrzBTqV Y76dGigVCde4/JdSR8BHtX2UGMyoUIwsN3debGezqrD7XhFfPszuon7tJojtApHodXVj ZzVA== X-Forwarded-Encrypted: i=1; AJvYcCXWc8FhAQHTzOA3DZ2Nb9/wsVvRDPXnbWuhXL8jCvk2tmRKgZWMCX7qpRZX3i25Nv5YuggHzXwXQyI=@vger.kernel.org X-Gm-Message-State: AOJu0YxmPaJ2CRdhXgz5xuvienxXLGN8aa6rI4BfZ1hqTVQlHTbEnVxs 4nF12FotHBthB6YQhvjblNFwCa7QEYCAajEjslLNuvs0G5ISNnUkNtRAEePIo0k= X-Gm-Gg: ASbGncuMXt/9m7dXMxyq9p4EpgzfgkFeIi4YBRxpHGV16JGmB3SSVyXNxFodh30kWyt C3K31XJUJg7qB9lllf34bCfHLz0u1CySeZHDK6pkjU2j86KehZlUKmX0iNK+XLHXaRJHTEOokmj lOd+u9RePVJIaay4x/7ZkSVbDvAsEoncbkXOSllZNHhmeJ9yu7ohCLl2YN040mEY51KHVPTqeIe NTfSLd4nQBe0NrMSuVMGkt7b6z73pdp7/GWhBNOP4zukFNwKWdqxYNgWt28oLom+lr/FHSmv8n9 SFmxmQ== X-Google-Smtp-Source: AGHT+IFs2ZJ7yEiw0GlEDpEl5+AMqdHl/F1EcpzSZpGEb8Hj0v56W6tbRqGY1fGfcmhSEz/iXK+Kig== X-Received: by 2002:a05:6870:f2a3:b0:27b:55af:ca2b with SMTP id 586e51a60fabf-29dc4019615mr4726485fac.11.1732737773557; Wed, 27 Nov 2024 12:02:53 -0800 (PST) Received: from [127.0.1.1] (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2971d6654e9sm5069542fac.24.2024.11.27.12.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2024 12:02:52 -0800 (PST) From: David Lechner Date: Wed, 27 Nov 2024 14:01:55 -0600 Subject: [PATCH v2 3/3] iio: adc: ad7173: don't make copy of ad_sigma_delta_info struct Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241127-iio-adc-ad7313-fix-non-const-info-struct-v2-3-b6d7022b7466@baylibre.com> References: <20241127-iio-adc-ad7313-fix-non-const-info-struct-v2-0-b6d7022b7466@baylibre.com> In-Reply-To: <20241127-iio-adc-ad7313-fix-non-const-info-struct-v2-0-b6d7022b7466@baylibre.com> To: Jonathan Cameron , Dumitru Ceclan Cc: Michael Hennerich , Nuno Sa , Michael Walle , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Guillaume Ranquet , David Lechner X-Mailer: b4 0.14.1 Use two separate static const struct ad_sigma_delta_info instances instead of making a copy for each driver instance. Typically in the IIO subsystem, we use multiple static const instances of the same struct when there are different variants of the same family of devices as opposed to making a copy for each driver instance and modifying it. Signed-off-by: David Lechner --- Whether this patch is an improvement or not is debatable. It makes things a bit more verbose, but to me it seems more consistent with how such cases are handled in the IIO subsystem. So take this one or leave it. --- drivers/iio/adc/ad7173.c | 470 +++++++++++++++++++++++++---------------------- 1 file changed, 248 insertions(+), 222 deletions(-) diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c index 52fce43e4ce1..04533b37d9ec 100644 --- a/drivers/iio/adc/ad7173.c +++ b/drivers/iio/adc/ad7173.c @@ -166,6 +166,7 @@ struct ad7173_device_info { unsigned int clock; unsigned int id; char *name; + const struct ad_sigma_delta_info *sd_info; bool has_current_inputs; bool has_vincom_input; bool has_temp; @@ -199,7 +200,6 @@ struct ad7173_channel { struct ad7173_state { struct ad_sigma_delta sd; - struct ad_sigma_delta_chip_info sigma_delta_info; const struct ad7173_device_info *info; struct ad7173_channel *channels; struct regulator_bulk_data regulators[3]; @@ -258,223 +258,6 @@ static unsigned int ad4111_current_channel_config[] = { 0x18B, /* 12:IIN3+ 11:IIN3− */ }; -static const struct ad7173_device_info ad4111_device_info = { - .name = "ad4111", - .id = AD4111_ID, - .num_voltage_in_div = 8, - .num_channels = 16, - .num_configs = 8, - .num_voltage_in = 8, - .num_gpios = 2, - .higher_gpio_bits = true, - .has_temp = true, - .has_vincom_input = true, - .has_input_buf = true, - .has_current_inputs = true, - .has_int_ref = true, - .clock = 2 * HZ_PER_MHZ, - .sinc5_data_rates = ad7173_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), -}; - -static const struct ad7173_device_info ad4112_device_info = { - .name = "ad4112", - .id = AD4112_ID, - .num_voltage_in_div = 8, - .num_channels = 16, - .num_configs = 8, - .num_voltage_in = 8, - .num_gpios = 2, - .higher_gpio_bits = true, - .has_vincom_input = true, - .has_temp = true, - .has_input_buf = true, - .has_current_inputs = true, - .has_int_ref = true, - .clock = 2 * HZ_PER_MHZ, - .sinc5_data_rates = ad7173_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), -}; - -static const struct ad7173_device_info ad4113_device_info = { - .name = "ad4113", - .id = AD4113_ID, - .num_voltage_in_div = 8, - .num_channels = 16, - .num_configs = 8, - .num_voltage_in = 8, - .num_gpios = 2, - .data_reg_only_16bit = true, - .higher_gpio_bits = true, - .has_vincom_input = true, - .has_input_buf = true, - .has_int_ref = true, - .clock = 2 * HZ_PER_MHZ, - .sinc5_data_rates = ad7173_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), -}; - -static const struct ad7173_device_info ad4114_device_info = { - .name = "ad4114", - .id = AD4114_ID, - .num_voltage_in_div = 16, - .num_channels = 16, - .num_configs = 8, - .num_voltage_in = 16, - .num_gpios = 4, - .has_vincom_input = true, - .has_temp = true, - .has_input_buf = true, - .has_int_ref = true, - .clock = 2 * HZ_PER_MHZ, - .sinc5_data_rates = ad7173_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), -}; - -static const struct ad7173_device_info ad4115_device_info = { - .name = "ad4115", - .id = AD4115_ID, - .num_voltage_in_div = 16, - .num_channels = 16, - .num_configs = 8, - .num_voltage_in = 16, - .num_gpios = 4, - .has_vincom_input = true, - .has_temp = true, - .has_input_buf = true, - .has_int_ref = true, - .clock = 8 * HZ_PER_MHZ, - .sinc5_data_rates = ad4115_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad4115_sinc5_data_rates), -}; - -static const struct ad7173_device_info ad4116_device_info = { - .name = "ad4116", - .id = AD4116_ID, - .num_voltage_in_div = 11, - .num_channels = 16, - .num_configs = 8, - .num_voltage_in = 16, - .num_gpios = 4, - .has_vincom_input = true, - .has_temp = true, - .has_input_buf = true, - .has_int_ref = true, - .clock = 4 * HZ_PER_MHZ, - .sinc5_data_rates = ad4116_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad4116_sinc5_data_rates), -}; - -static const struct ad7173_device_info ad7172_2_device_info = { - .name = "ad7172-2", - .id = AD7172_2_ID, - .num_voltage_in = 5, - .num_channels = 4, - .num_configs = 4, - .num_gpios = 2, - .has_temp = true, - .has_input_buf = true, - .has_int_ref = true, - .has_pow_supply_monitoring = true, - .clock = 2 * HZ_PER_MHZ, - .sinc5_data_rates = ad7173_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), -}; - -static const struct ad7173_device_info ad7172_4_device_info = { - .name = "ad7172-4", - .id = AD7172_4_ID, - .num_voltage_in = 9, - .num_channels = 8, - .num_configs = 8, - .num_gpios = 4, - .has_input_buf = true, - .has_ref2 = true, - .has_pow_supply_monitoring = true, - .clock = 2 * HZ_PER_MHZ, - .sinc5_data_rates = ad7173_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), -}; - -static const struct ad7173_device_info ad7173_8_device_info = { - .name = "ad7173-8", - .id = AD7173_ID, - .num_voltage_in = 17, - .num_channels = 16, - .num_configs = 8, - .num_gpios = 4, - .has_temp = true, - .has_input_buf = true, - .has_int_ref = true, - .has_ref2 = true, - .clock = 2 * HZ_PER_MHZ, - .sinc5_data_rates = ad7173_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), -}; - -static const struct ad7173_device_info ad7175_2_device_info = { - .name = "ad7175-2", - .id = AD7175_2_ID, - .num_voltage_in = 5, - .num_channels = 4, - .num_configs = 4, - .num_gpios = 2, - .has_temp = true, - .has_input_buf = true, - .has_int_ref = true, - .has_pow_supply_monitoring = true, - .clock = 16 * HZ_PER_MHZ, - .sinc5_data_rates = ad7175_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), -}; - -static const struct ad7173_device_info ad7175_8_device_info = { - .name = "ad7175-8", - .id = AD7175_8_ID, - .num_voltage_in = 17, - .num_channels = 16, - .num_configs = 8, - .num_gpios = 4, - .has_temp = true, - .has_input_buf = true, - .has_int_ref = true, - .has_ref2 = true, - .has_pow_supply_monitoring = true, - .clock = 16 * HZ_PER_MHZ, - .sinc5_data_rates = ad7175_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), -}; - -static const struct ad7173_device_info ad7176_2_device_info = { - .name = "ad7176-2", - .id = AD7176_ID, - .num_voltage_in = 5, - .num_channels = 4, - .num_configs = 4, - .num_gpios = 2, - .has_int_ref = true, - .clock = 16 * HZ_PER_MHZ, - .sinc5_data_rates = ad7175_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), -}; - -static const struct ad7173_device_info ad7177_2_device_info = { - .name = "ad7177-2", - .id = AD7177_ID, - .num_voltage_in = 5, - .num_channels = 4, - .num_configs = 4, - .num_gpios = 2, - .has_temp = true, - .has_input_buf = true, - .has_int_ref = true, - .has_pow_supply_monitoring = true, - .clock = 16 * HZ_PER_MHZ, - .odr_start_value = AD7177_ODR_START_VALUE, - .sinc5_data_rates = ad7175_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), -}; - static const char *const ad7173_ref_sel_str[] = { [AD7173_SETUP_REF_SEL_EXT_REF] = "vref", [AD7173_SETUP_REF_SEL_EXT_REF2] = "vref2", @@ -753,7 +536,21 @@ static int ad7173_disable_one(struct ad_sigma_delta *sd, unsigned int chan) return ad_sd_write_reg(sd, AD7173_REG_CH(chan), 2, 0); } -static const struct ad_sigma_delta_info ad7173_sigma_delta_info = { +static const struct ad_sigma_delta_info ad7173_sigma_delta_info_4_slots = { + .set_channel = ad7173_set_channel, + .append_status = ad7173_append_status, + .disable_all = ad7173_disable_all, + .disable_one = ad7173_disable_one, + .set_mode = ad7173_set_mode, + .has_registers = true, + .addr_shift = 0, + .read_mask = BIT(6), + .status_ch_mask = GENMASK(3, 0), + .data_reg = AD7173_REG_DATA, + .num_slots = 4, +}; + +static const struct ad_sigma_delta_info ad7173_sigma_delta_info_8_slots = { .set_channel = ad7173_set_channel, .append_status = ad7173_append_status, .disable_all = ad7173_disable_all, @@ -764,6 +561,237 @@ static const struct ad_sigma_delta_info ad7173_sigma_delta_info = { .read_mask = BIT(6), .status_ch_mask = GENMASK(3, 0), .data_reg = AD7173_REG_DATA, + .num_slots = 8, +}; + +static const struct ad7173_device_info ad4111_device_info = { + .name = "ad4111", + .id = AD4111_ID, + .sd_info = &ad7173_sigma_delta_info_8_slots, + .num_voltage_in_div = 8, + .num_channels = 16, + .num_configs = 8, + .num_voltage_in = 8, + .num_gpios = 2, + .higher_gpio_bits = true, + .has_temp = true, + .has_vincom_input = true, + .has_input_buf = true, + .has_current_inputs = true, + .has_int_ref = true, + .clock = 2 * HZ_PER_MHZ, + .sinc5_data_rates = ad7173_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), +}; + +static const struct ad7173_device_info ad4112_device_info = { + .name = "ad4112", + .id = AD4112_ID, + .sd_info = &ad7173_sigma_delta_info_8_slots, + .num_voltage_in_div = 8, + .num_channels = 16, + .num_configs = 8, + .num_voltage_in = 8, + .num_gpios = 2, + .higher_gpio_bits = true, + .has_vincom_input = true, + .has_temp = true, + .has_input_buf = true, + .has_current_inputs = true, + .has_int_ref = true, + .clock = 2 * HZ_PER_MHZ, + .sinc5_data_rates = ad7173_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), +}; + +static const struct ad7173_device_info ad4113_device_info = { + .name = "ad4113", + .id = AD4113_ID, + .sd_info = &ad7173_sigma_delta_info_8_slots, + .num_voltage_in_div = 8, + .num_channels = 16, + .num_configs = 8, + .num_voltage_in = 8, + .num_gpios = 2, + .data_reg_only_16bit = true, + .higher_gpio_bits = true, + .has_vincom_input = true, + .has_input_buf = true, + .has_int_ref = true, + .clock = 2 * HZ_PER_MHZ, + .sinc5_data_rates = ad7173_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), +}; + +static const struct ad7173_device_info ad4114_device_info = { + .name = "ad4114", + .id = AD4114_ID, + .sd_info = &ad7173_sigma_delta_info_8_slots, + .num_voltage_in_div = 16, + .num_channels = 16, + .num_configs = 8, + .num_voltage_in = 16, + .num_gpios = 4, + .has_vincom_input = true, + .has_temp = true, + .has_input_buf = true, + .has_int_ref = true, + .clock = 2 * HZ_PER_MHZ, + .sinc5_data_rates = ad7173_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), +}; + +static const struct ad7173_device_info ad4115_device_info = { + .name = "ad4115", + .id = AD4115_ID, + .sd_info = &ad7173_sigma_delta_info_8_slots, + .num_voltage_in_div = 16, + .num_channels = 16, + .num_configs = 8, + .num_voltage_in = 16, + .num_gpios = 4, + .has_vincom_input = true, + .has_temp = true, + .has_input_buf = true, + .has_int_ref = true, + .clock = 8 * HZ_PER_MHZ, + .sinc5_data_rates = ad4115_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad4115_sinc5_data_rates), +}; + +static const struct ad7173_device_info ad4116_device_info = { + .name = "ad4116", + .id = AD4116_ID, + .sd_info = &ad7173_sigma_delta_info_8_slots, + .num_voltage_in_div = 11, + .num_channels = 16, + .num_configs = 8, + .num_voltage_in = 16, + .num_gpios = 4, + .has_vincom_input = true, + .has_temp = true, + .has_input_buf = true, + .has_int_ref = true, + .clock = 4 * HZ_PER_MHZ, + .sinc5_data_rates = ad4116_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad4116_sinc5_data_rates), +}; + +static const struct ad7173_device_info ad7172_2_device_info = { + .name = "ad7172-2", + .id = AD7172_2_ID, + .sd_info = &ad7173_sigma_delta_info_8_slots, + .num_voltage_in = 5, + .num_channels = 4, + .num_configs = 4, + .num_gpios = 2, + .has_temp = true, + .has_input_buf = true, + .has_int_ref = true, + .has_pow_supply_monitoring = true, + .clock = 2 * HZ_PER_MHZ, + .sinc5_data_rates = ad7173_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), +}; + +static const struct ad7173_device_info ad7172_4_device_info = { + .name = "ad7172-4", + .id = AD7172_4_ID, + .sd_info = &ad7173_sigma_delta_info_8_slots, + .num_voltage_in = 9, + .num_channels = 8, + .num_configs = 8, + .num_gpios = 4, + .has_input_buf = true, + .has_ref2 = true, + .has_pow_supply_monitoring = true, + .clock = 2 * HZ_PER_MHZ, + .sinc5_data_rates = ad7173_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), +}; + +static const struct ad7173_device_info ad7173_8_device_info = { + .name = "ad7173-8", + .id = AD7173_ID, + .sd_info = &ad7173_sigma_delta_info_8_slots, + .num_voltage_in = 17, + .num_channels = 16, + .num_configs = 8, + .num_gpios = 4, + .has_temp = true, + .has_input_buf = true, + .has_int_ref = true, + .has_ref2 = true, + .clock = 2 * HZ_PER_MHZ, + .sinc5_data_rates = ad7173_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), +}; + +static const struct ad7173_device_info ad7175_2_device_info = { + .name = "ad7175-2", + .id = AD7175_2_ID, + .sd_info = &ad7173_sigma_delta_info_8_slots, + .num_voltage_in = 5, + .num_channels = 4, + .num_configs = 4, + .num_gpios = 2, + .has_temp = true, + .has_input_buf = true, + .has_int_ref = true, + .has_pow_supply_monitoring = true, + .clock = 16 * HZ_PER_MHZ, + .sinc5_data_rates = ad7175_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), +}; + +static const struct ad7173_device_info ad7175_8_device_info = { + .name = "ad7175-8", + .id = AD7175_8_ID, + .sd_info = &ad7173_sigma_delta_info_8_slots, + .num_voltage_in = 17, + .num_channels = 16, + .num_configs = 8, + .num_gpios = 4, + .has_temp = true, + .has_input_buf = true, + .has_int_ref = true, + .has_ref2 = true, + .has_pow_supply_monitoring = true, + .clock = 16 * HZ_PER_MHZ, + .sinc5_data_rates = ad7175_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), +}; + +static const struct ad7173_device_info ad7176_2_device_info = { + .name = "ad7176-2", + .id = AD7176_ID, + .sd_info = &ad7173_sigma_delta_info_4_slots, + .num_voltage_in = 5, + .num_channels = 4, + .num_configs = 4, + .num_gpios = 2, + .has_int_ref = true, + .clock = 16 * HZ_PER_MHZ, + .sinc5_data_rates = ad7175_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), +}; + +static const struct ad7173_device_info ad7177_2_device_info = { + .name = "ad7177-2", + .id = AD7177_ID, + .sd_info = &ad7173_sigma_delta_info_4_slots, + .num_voltage_in = 5, + .num_channels = 4, + .num_configs = 4, + .num_gpios = 2, + .has_temp = true, + .has_input_buf = true, + .has_int_ref = true, + .has_pow_supply_monitoring = true, + .clock = 16 * HZ_PER_MHZ, + .odr_start_value = AD7177_ODR_START_VALUE, + .sinc5_data_rates = ad7175_sinc5_data_rates, + .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), }; static int ad7173_setup(struct iio_dev *indio_dev) @@ -1429,9 +1457,7 @@ static int ad7173_probe(struct spi_device *spi) spi->mode = SPI_MODE_3; spi_setup(spi); - st->sigma_delta_info = ad7173_sigma_delta_info; - st->sigma_delta_info.num_slots = st->info->num_configs; - ret = ad_sd_init(&st->sd, indio_dev, spi, &st->sigma_delta_info); + ret = ad_sd_init(&st->sd, indio_dev, spi, st->info->sd_info); if (ret) return ret;