From patchwork Tue Nov 21 10:20:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 167614 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp520810vqb; Tue, 21 Nov 2023 02:18:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IG51tr0zE75E1VaholQV9wjIMrDCdADZpFhugOQFlqszEmcP8h+F2Nh8u3ILe/5k+nAPdHz X-Received: by 2002:a05:6a21:6d8a:b0:187:d380:fd98 with SMTP id wl10-20020a056a216d8a00b00187d380fd98mr8835722pzb.44.1700561921382; Tue, 21 Nov 2023 02:18:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700561921; cv=none; d=google.com; s=arc-20160816; b=gZBIGeW+QfwVNmPRpqzD1necxPj3kREbS10oAWP1Ed8lbX1DYVexFOe7RPvMFpA7MC 1cuiz3NDKa+wE3FmNQIp4vBcgQ5CYPBIXLsaIxXVql5SpdXm+0zZd6Gnb2ENdD863i6f FXxQz0Q5QUZkGRkMMQco+ppJWxbzPQM5f1gChm752bdjgvzN0eFTN2rn9Ne7m0B9+5Pv k9SnqXJF9tujqU88gcluLMwVnc4wXQhCWaG4mvQ2bVXbywubYwwKR3bepQkkfYlMC01m jN50k3/1eyf1xM9mA8deebNh//Z5aatrNLeZi/I/QS9ZlQIttFgF5Ddv0oJxMg6xNvtb MwQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ih77yxA4BbrR9sb3xfi7YLBXZFMWFiOsJlTc1SChrMI=; fh=phDggtdq/mZScnogaJFJfeRDE2XPpZpUuxL35p15uks=; b=Awp3CKWuor2njPBWPRGf0smBIPUaVhDtvCGEWHIIAHLOyAjierq8E6g2WFARVxkKRc Jkw5OFZe0NI6L8MeN+z0Q6aJIApPYepOYzjtY7jr4mfxiD3tIdscl77cCJAUP0EdRe59 7V7swpTL6aTeolDfbY3l3pqAv+Y2UsP1kPsvTrkf1S8uqGTuVpvSC7O4CcP9hIB+agMN nYYBi01/yo9p8vgmlpInGFUGvYwAPN7dyKn5BlziuZ9ypLDEWUF3rjLFUyQnP33NO8/R vfXUUQ3v38Amuf2Bis2uUfiiK0pURPqT3ooUEdzmShJUvE12zmh4psv4XCRqKHO+UfvJ aSBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="MG22fP/8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id fy1-20020a17090b020100b0028511adb1acsi6463753pjb.67.2023.11.21.02.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:18:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="MG22fP/8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id B35F98048D8E; Tue, 21 Nov 2023 02:18:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233787AbjKUKSE (ORCPT + 99 others); Tue, 21 Nov 2023 05:18:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233176AbjKUKRZ (ORCPT ); Tue, 21 Nov 2023 05:17:25 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3309B134 for ; Tue, 21 Nov 2023 02:17:21 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPS id BCEAAC433B7; Tue, 21 Nov 2023 10:17:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700561839; bh=3jqcpmMVgRdlV0OZKCqw9abAHNIj6Mrrp0uhYEWv1Tw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=MG22fP/8IbSk4s4y1vLdBrnoBg+zYmS0SAke44UgfmDz21OKuqfGt4MAF3OK+JWLl HSfavn7vxUR1o6bUUTQVNrOujw41oh/yjAV7vmM2OOqtgVHLW+QuM3rayrrUhd5SaX kNB3U5tO65hb5BNIoB0fE6BxIcwtI5y1Q8w7dWwuWM6S+gBGUcrB/Rm+UuClPVPTOX 5aG04NOEmjBYdniXWXzx3pQxCM6H9/ofZFt8cyacAMQYYlsWPVUKKkuwDkN8s8bp0B Wcgehwn7348Unz8ppoiDBevUFpnbzAxM/LCQBLHRPoZRtIQ5kf+40sfvnAuGPVT42n ZdIoBP6JzXmEg== 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 A924DC5ACB3; Tue, 21 Nov 2023 10:17:19 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Tue, 21 Nov 2023 11:20:22 +0100 Subject: [PATCH 09/12] iio: adc: ad9467: use chip_info variables instead of array MIME-Version: 1.0 Message-Id: <20231121-dev-iio-backend-v1-9-6a3d542eba35@analog.com> References: <20231121-dev-iio-backend-v1-0-6a3d542eba35@analog.com> In-Reply-To: <20231121-dev-iio-backend-v1-0-6a3d542eba35@analog.com> To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org Cc: Olivier MOYSAN , Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Nuno Sa X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1700562016; l=4457; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=vkbr36xjXuQW5nYydBocFuU8wGwlSsFvoY57jHRaH1w=; b=He0UNjSCXL2IIli4eBSKtEN63uAMX1iX8sAVvjSjiwnMjnttPr8caWXTQQjkZG7/HQauGJe4v gsLvTYTUJw8AkRva2t7rNxuOc9TIj9MRnodf6mbaPiFcZGIUmpJ591x X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 02:18:16 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783168417298027053 X-GMAIL-MSGID: 1783168417298027053 From: Nuno Sa Instead of having an array and keeping IDs for each entry of the array, just have a chip_info struct per device. Signed-off-by: Nuno Sa --- drivers/iio/adc/ad9467.c | 89 +++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c index f0342c8942ee..5db5690ccee8 100644 --- a/drivers/iio/adc/ad9467.c +++ b/drivers/iio/adc/ad9467.c @@ -101,12 +101,6 @@ #define AD9467_DEF_OUTPUT_MODE 0x08 #define AD9467_REG_VREF_MASK 0x0F -enum { - ID_AD9265, - ID_AD9434, - ID_AD9467, -}; - struct ad9467_chip_info { struct adi_axi_adc_chip_info axi_adc_info; unsigned int default_output_mode; @@ -234,43 +228,46 @@ static const struct iio_chan_spec ad9467_channels[] = { AD9467_CHAN(0, 0, 16, 'S'), }; -static const struct ad9467_chip_info ad9467_chip_tbl[] = { - [ID_AD9265] = { - .axi_adc_info = { - .id = CHIPID_AD9265, - .max_rate = 125000000UL, - .scale_table = ad9265_scale_table, - .num_scales = ARRAY_SIZE(ad9265_scale_table), - .channels = ad9467_channels, - .num_channels = ARRAY_SIZE(ad9467_channels), - }, - .default_output_mode = AD9265_DEF_OUTPUT_MODE, - .vref_mask = AD9265_REG_VREF_MASK, +static const struct ad9467_chip_info ad9467_chip_tbl = { + .axi_adc_info = { + .name = "ad9467", + .id = CHIPID_AD9467, + .max_rate = 250000000UL, + .scale_table = ad9467_scale_table, + .num_scales = ARRAY_SIZE(ad9467_scale_table), + .channels = ad9467_channels, + .num_channels = ARRAY_SIZE(ad9467_channels), }, - [ID_AD9434] = { - .axi_adc_info = { - .id = CHIPID_AD9434, - .max_rate = 500000000UL, - .scale_table = ad9434_scale_table, - .num_scales = ARRAY_SIZE(ad9434_scale_table), - .channels = ad9434_channels, - .num_channels = ARRAY_SIZE(ad9434_channels), - }, - .default_output_mode = AD9434_DEF_OUTPUT_MODE, - .vref_mask = AD9434_REG_VREF_MASK, + .default_output_mode = AD9467_DEF_OUTPUT_MODE, + .vref_mask = AD9467_REG_VREF_MASK, +}; + +static const struct ad9467_chip_info ad9434_chip_tbl = { + .axi_adc_info = { + .name = "ad9434", + .id = CHIPID_AD9434, + .max_rate = 500000000UL, + .scale_table = ad9434_scale_table, + .num_scales = ARRAY_SIZE(ad9434_scale_table), + .channels = ad9434_channels, + .num_channels = ARRAY_SIZE(ad9434_channels), }, - [ID_AD9467] = { - .axi_adc_info = { - .id = CHIPID_AD9467, - .max_rate = 250000000UL, - .scale_table = ad9467_scale_table, - .num_scales = ARRAY_SIZE(ad9467_scale_table), - .channels = ad9467_channels, - .num_channels = ARRAY_SIZE(ad9467_channels), - }, - .default_output_mode = AD9467_DEF_OUTPUT_MODE, - .vref_mask = AD9467_REG_VREF_MASK, + .default_output_mode = AD9434_DEF_OUTPUT_MODE, + .vref_mask = AD9434_REG_VREF_MASK, +}; + +static const struct ad9467_chip_info ad9265_chip_tbl = { + .axi_adc_info = { + .name = "ad9265", + .id = CHIPID_AD9265, + .max_rate = 125000000UL, + .scale_table = ad9265_scale_table, + .num_scales = ARRAY_SIZE(ad9265_scale_table), + .channels = ad9467_channels, + .num_channels = ARRAY_SIZE(ad9467_channels), }, + .default_output_mode = AD9265_DEF_OUTPUT_MODE, + .vref_mask = AD9265_REG_VREF_MASK, }; static int ad9467_get_scale(struct adi_axi_adc_conv *conv, int *val, int *val2) @@ -505,17 +502,17 @@ static int ad9467_probe(struct spi_device *spi) } static const struct of_device_id ad9467_of_match[] = { - { .compatible = "adi,ad9265", .data = &ad9467_chip_tbl[ID_AD9265], }, - { .compatible = "adi,ad9434", .data = &ad9467_chip_tbl[ID_AD9434], }, - { .compatible = "adi,ad9467", .data = &ad9467_chip_tbl[ID_AD9467], }, + { .compatible = "adi,ad9265", .data = &ad9265_chip_tbl, }, + { .compatible = "adi,ad9434", .data = &ad9434_chip_tbl, }, + { .compatible = "adi,ad9467", .data = &ad9467_chip_tbl, }, {} }; MODULE_DEVICE_TABLE(of, ad9467_of_match); static const struct spi_device_id ad9467_ids[] = { - { "ad9265", (kernel_ulong_t)&ad9467_chip_tbl[ID_AD9265] }, - { "ad9434", (kernel_ulong_t)&ad9467_chip_tbl[ID_AD9434] }, - { "ad9467", (kernel_ulong_t)&ad9467_chip_tbl[ID_AD9467] }, + { "ad9265", (kernel_ulong_t)&ad9265_chip_tbl }, + { "ad9434", (kernel_ulong_t)&ad9434_chip_tbl }, + { "ad9467", (kernel_ulong_t)&ad9467_chip_tbl }, {} }; MODULE_DEVICE_TABLE(spi, ad9467_ids);