Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1077500lqj; Mon, 3 Jun 2024 09:27:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWighvHhjE/zcTWS6qU3O9/lGStXDzUDtCby7IY3nTJsFNY1HXYlIYMGYBFgew0IsnUccgyRPojwXM1qk9wF9lo/Ujp7sA0B7cZbt1z3w== X-Google-Smtp-Source: AGHT+IG4Tiu/0gxl0ACVjZ8PeZKrfseNOQ2juTVjjmtO0Stwsg7VaLnQxiGOyK8QThsrLHorgj/w X-Received: by 2002:a05:6e02:1c22:b0:36b:3af2:2349 with SMTP id e9e14a558f8ab-3748b98f465mr105914605ab.15.1717432044232; Mon, 03 Jun 2024 09:27:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717432044; cv=pass; d=google.com; s=arc-20160816; b=vLMGye++/h/le870n1SgpAjGRs75kGsbf80TJSFrK1eNaBNVnXLPoxLRoQjTT0vLkT 4qgUPLFpjq/NRuGez0kN/SIudAyN9lWn8L+yV6z+qJ6ytymcaRnpibOhrRioaXkVEX/r L3U9t1LfmkwFSJ5MlPGZVnNBm2ESmXStKMXxHMkw20ZSNF6OUlplyKZuiLxOqDSK+ceX rXrdwmqaRdKPMCILlmN2j2wZzqQpr++7Yjgrbe6vf6BDxXjYorUNccKk3+YUkGCczQg2 fQ//6OVNp6H2c7alGMKqNzrdvVG63SYLQj/2UP5WHV9JDqvHmVSZ90TT1vRWcPgJGey0 QSCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=G9N+ZIyYMALRMh7t/vPNjAefrf2m78cLoYasa7SSNfc=; fh=LhdatDguh+IuN1lDyS6rzhx9ubttSYYZpDCGFgekH1E=; b=Wd9fGWkcf6XQQ/CvNbJNH1wSWjEEN9FBkrl/XLM1gmLKLGnC+GJCc0KQbEbSfU/LsT g3BEYBZ1Hi4nLeFh+4nXleW55msDwrObLKCAW78cqEEJpvDz70WTbure7XV8AU2QBFyu jFLtxow7qtDXajQHjexkEOV/iYQddrVWGe+G4p7G5GJzxamDVU/+TLVyJ4CsOtfh1pQi S29xW6bntSFBdgSGkIhzLTfYhpBjjzzFLeZjT3EqHD/tLt9iNRjyfqnXc7RPATs84JTI PK6yPJbsj6prIUtle7tF+taqO398ILSFhM2gpYSL0851tEAMc0Mjpyyuy/sUEdjczKCT lVOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i+EftQgc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199439-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199439-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35d59d785si43430a12.816.2024.06.03.09.27.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 09:27:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199439-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i+EftQgc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199439-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199439-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C7CF7B244DA for ; Mon, 3 Jun 2024 16:25:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B42713B2B0; Mon, 3 Jun 2024 16:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i+EftQgc" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A69391369A3; Mon, 3 Jun 2024 16:23:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717431794; cv=none; b=p5CpVbMZ6+cBLsDoaMl8jduX0uw6zLq+MUdbJFYOe4d0ProxlIz7sbvneolyPZEDHcwekCw1EoUvJx+70KjSZLugkm2XQMQv/EOWQ746fbkfZFkxzsGf1V/PlnJRX34i21+nwTptm8iDZw19gOGiTK9TlUxDY7H6OegOjEzhFXA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717431794; c=relaxed/simple; bh=3uoTLGExFhw8T/5yZSVqsReGZtzdIcbvOL1A/cA7iY8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Per0ob1BXZRCtLqTlWCc052ah//FLhiAYjdrw3sx8jVmxm7aITf0aLGsCUlgR8daFpvzBtD+/mmvxSZJQJw9RT90qRaOTjdSq7c31SqRjEDP7fKoFtz1NQmL6w16Dokarv+uq6Rr8yv0J5tVpvtA7hI1EALhu3aUzfrPh2CbCxA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i+EftQgc; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 3EC35C4AF48; Mon, 3 Jun 2024 16:23:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717431794; bh=3uoTLGExFhw8T/5yZSVqsReGZtzdIcbvOL1A/cA7iY8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=i+EftQgcB63QT6H/lN8yGwdIoMir9cy+nb1SLgNlvBI55VWXUXyYF+ksG27YWqCmh 2JL1nuRF/2kGuQhlXWCvR7KS6OihyBFJRRieKDYCsJPYV0voLR9w8jtZfe+w88FUci hlU9Ljjew4qnZ3lfbbO3K7OfipPXcZo5y/NNSo/M1TMkqXM1rBBnFucK/7zbIQRnB1 Toowr2qif1QBycfceuZiw4Ir8yhdwPyFQ2O8EPxqkSy7Z6AWt6z3HJX70KTJKHLaAa 9qicsWqKmsIaWZuu2D8OqnZbwQsqAGcmeWvCJ57mIIRoNisTlYyY0q1NxsGWJHB+vA P1PO2URYkdCtA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 383CEC25B76; Mon, 3 Jun 2024 16:23:14 +0000 (UTC) From: Dumitru Ceclan via B4 Relay Date: Mon, 03 Jun 2024 19:23:05 +0300 Subject: [PATCH v5 7/9] iio: adc: ad7173: refactor device info structs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240603-ad4111-v5-7-9a9c54d9ac78@analog.com> References: <20240603-ad4111-v5-0-9a9c54d9ac78@analog.com> In-Reply-To: <20240603-ad4111-v5-0-9a9c54d9ac78@analog.com> To: Ceclan Dumitru Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , David Lechner , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Dumitru Ceclan X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717431792; l=9509; i=dumitru.ceclan@analog.com; s=20240313; h=from:subject:message-id; bh=xBrHUTTNXev6rrV+QhMZtiU7E27mY9Y4lkspfZHyCHI=; b=5ccEfFfjzjMnoAcPJW2f3S7EiVkt1/Px9jGnYYsijv5+5gZM2nUlYSMkJcB9sWC3G3gsdh7Yp NMe6ICnD7ZFCUIt4le3BMbQnjKSeNJNPChJo5z59KCuG0zbULZN5q6h X-Developer-Key: i=dumitru.ceclan@analog.com; a=ed25519; pk=HdqMlVyrcazwoiai7oN6ghU+Bj1pusGUFRl30jhS7Bo= X-Endpoint-Received: by B4 Relay for dumitru.ceclan@analog.com/20240313 with auth_id=140 X-Original-From: Dumitru Ceclan Reply-To: dumitru.ceclan@analog.com From: Dumitru Ceclan Drop array of device info structs and use individual structs for all; drop models enum as no longer needed. This improves readability as the structs are pointed directly. Signed-off-by: Dumitru Ceclan --- drivers/iio/adc/ad7173.c | 267 ++++++++++++++++++++++------------------------- 1 file changed, 127 insertions(+), 140 deletions(-) diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c index 4cff3eda5a6b..5ade166814d7 100644 --- a/drivers/iio/adc/ad7173.c +++ b/drivers/iio/adc/ad7173.c @@ -134,16 +134,6 @@ #define AD7173_FILTER_ODR0_MASK GENMASK(5, 0) #define AD7173_MAX_CONFIGS 8 -enum ad7173_ids { - ID_AD7172_2, - ID_AD7172_4, - ID_AD7173_8, - ID_AD7175_2, - ID_AD7175_8, - ID_AD7176_2, - ID_AD7177_2, -}; - struct ad7173_device_info { const unsigned int *sinc5_data_rates; unsigned int num_sinc5_data_rates; @@ -216,115 +206,119 @@ static const unsigned int ad7175_sinc5_data_rates[] = { 5000, /* 20 */ }; -static const struct ad7173_device_info ad7173_device_info[] = { - [ID_AD7172_2] = { - .name = "ad7172-2", - .id = AD7172_2_ID, - .num_inputs = 5, - .num_channels = 4, - .num_configs = 4, - .num_gpios = 2, - .has_temp = true, - .has_input_buf = true, - .has_int_ref = true, - .has_common_input = true, - .clock = 2 * HZ_PER_MHZ, - .sinc5_data_rates = ad7173_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), - }, - [ID_AD7172_4] = { - .name = "ad7172-4", - .id = AD7172_4_ID, - .num_inputs = 9, - .num_channels = 8, - .num_configs = 8, - .num_gpios = 4, - .has_temp = false, - .has_input_buf = true, - .has_ref2 = true, - .has_common_input = true, - .clock = 2 * HZ_PER_MHZ, - .sinc5_data_rates = ad7173_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), - }, - [ID_AD7173_8] = { - .name = "ad7173-8", - .id = AD7173_ID, - .num_inputs = 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_common_input = false, - .clock = 2 * HZ_PER_MHZ, - .sinc5_data_rates = ad7173_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates), - }, - [ID_AD7175_2] = { - .name = "ad7175-2", - .id = AD7175_2_ID, - .num_inputs = 5, - .num_channels = 4, - .num_configs = 4, - .num_gpios = 2, - .has_temp = true, - .has_input_buf = true, - .has_int_ref = true, - .has_common_input = true, - .clock = 16 * HZ_PER_MHZ, - .sinc5_data_rates = ad7175_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), - }, - [ID_AD7175_8] = { - .name = "ad7175-8", - .id = AD7175_8_ID, - .num_inputs = 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_common_input = true, - .clock = 16 * HZ_PER_MHZ, - .sinc5_data_rates = ad7175_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), - }, - [ID_AD7176_2] = { - .name = "ad7176-2", - .id = AD7176_ID, - .num_inputs = 5, - .num_channels = 4, - .num_configs = 4, - .num_gpios = 2, - .has_temp = false, - .has_input_buf = false, - .has_int_ref = true, - .has_common_input = false, - .clock = 16 * HZ_PER_MHZ, - .sinc5_data_rates = ad7175_sinc5_data_rates, - .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates), - }, - [ID_AD7177_2] = { - .name = "ad7177-2", - .id = AD7177_ID, - .num_inputs = 5, - .num_channels = 4, - .num_configs = 4, - .num_gpios = 2, - .has_temp = true, - .has_input_buf = true, - .has_int_ref = true, - .has_common_input = 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 struct ad7173_device_info ad7172_2_device_info = { + .name = "ad7172-2", + .id = AD7172_2_ID, + .num_inputs = 5, + .num_channels = 4, + .num_configs = 4, + .num_gpios = 2, + .has_temp = true, + .has_input_buf = true, + .has_int_ref = true, + .has_common_input = 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_inputs = 9, + .num_channels = 8, + .num_configs = 8, + .num_gpios = 4, + .has_temp = false, + .has_input_buf = true, + .has_ref2 = true, + .has_common_input = 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_inputs = 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_common_input = false, + .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_inputs = 5, + .num_channels = 4, + .num_configs = 4, + .num_gpios = 2, + .has_temp = true, + .has_input_buf = true, + .has_int_ref = true, + .has_common_input = 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_inputs = 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_common_input = 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_inputs = 5, + .num_channels = 4, + .num_configs = 4, + .num_gpios = 2, + .has_temp = false, + .has_input_buf = false, + .has_int_ref = true, + .has_common_input = false, + .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_inputs = 5, + .num_channels = 4, + .num_configs = 4, + .num_gpios = 2, + .has_temp = true, + .has_input_buf = true, + .has_int_ref = true, + .has_common_input = 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[] = { @@ -1191,32 +1185,25 @@ static int ad7173_probe(struct spi_device *spi) } static const struct of_device_id ad7173_of_match[] = { - { .compatible = "adi,ad7172-2", - .data = &ad7173_device_info[ID_AD7172_2]}, - { .compatible = "adi,ad7172-4", - .data = &ad7173_device_info[ID_AD7172_4]}, - { .compatible = "adi,ad7173-8", - .data = &ad7173_device_info[ID_AD7173_8]}, - { .compatible = "adi,ad7175-2", - .data = &ad7173_device_info[ID_AD7175_2]}, - { .compatible = "adi,ad7175-8", - .data = &ad7173_device_info[ID_AD7175_8]}, - { .compatible = "adi,ad7176-2", - .data = &ad7173_device_info[ID_AD7176_2]}, - { .compatible = "adi,ad7177-2", - .data = &ad7173_device_info[ID_AD7177_2]}, + { .compatible = "adi,ad7172-2", .data = &ad7172_2_device_info}, + { .compatible = "adi,ad7172-4", .data = &ad7172_4_device_info}, + { .compatible = "adi,ad7173-8", .data = &ad7173_8_device_info}, + { .compatible = "adi,ad7175-2", .data = &ad7175_2_device_info}, + { .compatible = "adi,ad7175-8", .data = &ad7175_8_device_info}, + { .compatible = "adi,ad7176-2", .data = &ad7176_2_device_info}, + { .compatible = "adi,ad7177-2", .data = &ad7177_2_device_info}, { } }; MODULE_DEVICE_TABLE(of, ad7173_of_match); static const struct spi_device_id ad7173_id_table[] = { - { "ad7172-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7172_2]}, - { "ad7172-4", (kernel_ulong_t)&ad7173_device_info[ID_AD7172_4]}, - { "ad7173-8", (kernel_ulong_t)&ad7173_device_info[ID_AD7173_8]}, - { "ad7175-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7175_2]}, - { "ad7175-8", (kernel_ulong_t)&ad7173_device_info[ID_AD7175_8]}, - { "ad7176-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7176_2]}, - { "ad7177-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7177_2]}, + { "ad7172-2", (kernel_ulong_t)&ad7172_2_device_info}, + { "ad7172-4", (kernel_ulong_t)&ad7172_4_device_info}, + { "ad7173-8", (kernel_ulong_t)&ad7173_8_device_info}, + { "ad7175-2", (kernel_ulong_t)&ad7175_2_device_info}, + { "ad7175-8", (kernel_ulong_t)&ad7175_8_device_info}, + { "ad7176-2", (kernel_ulong_t)&ad7176_2_device_info}, + { "ad7177-2", (kernel_ulong_t)&ad7177_2_device_info}, { } }; MODULE_DEVICE_TABLE(spi, ad7173_id_table); -- 2.43.0