Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1501333lqz; Mon, 1 Apr 2024 08:10:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmH8RJoOLIJuCufFDfm0zHS4zyP4d9Av5CITS8vj+2wrCWVlsRnAhHTn5cFw0nSaQnSmsbXCV2YwLTwJTEyKFJ7hTeeUifcO+3Yo4BXw== X-Google-Smtp-Source: AGHT+IHhsdjqxyJ3lopX8k/G1MIaFKGCHPfzzVFEp3bg2LRmSIZZXkvXTpGsM0HqK8hykY6o1hRy X-Received: by 2002:a05:620a:127a:b0:78a:2a5f:853d with SMTP id b26-20020a05620a127a00b0078a2a5f853dmr10273509qkl.31.1711984255141; Mon, 01 Apr 2024 08:10:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711984255; cv=pass; d=google.com; s=arc-20160816; b=HNeLszwv74Y4Vikh64UR9mdOJ7gSxkDN1ciWfTdkq97cDsc7VC11245/A3JN7j3DFz pnY/ZFTAkSQHCvzS4HbHpUPHRiDP+PA47+iEZ6dPIr/PSbzVEW76RnHISABbwdKJH8sf T59phf5zmEGZu8fQ2gKkPsnxId+FSdklPsNF81kHU0nJE1Cyz7aT/WRqo7DDsngRAZzA 6WFXjTeqOS0j7kgMamVhCbeikFUyt92J1VVWcDLFds4PhkWypbCl1zaIeeCZ138Y7nXX FGck9cbU5lTfb5n9BdCCUXLKNy78lB5CjOkqcBM5iB/kkoW0C9jc2eUbks2OPjlg96yk Js1w== 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=J18FIAKNuG4DFIVA6yon0f3I5IjDwjmv68VIKJFD66A=; fh=LhdatDguh+IuN1lDyS6rzhx9ubttSYYZpDCGFgekH1E=; b=UylX/vNGs3iF58fO28JbtWv55YhV/D1mI6kC4aLOqzjgE13hGG4yy2FaDAph9Lh7sp Q8oVApbXDHjhecJKjQ6wO94C/xtTwHV7pJk0vJlh50CTwfkwiYFTuKxNU6XV0iz3qPb7 xm4oPB+Ycm3jAp+jd5iany4vYxLKnccG9rlFd9I7kFYAdqGMX8Ub0K7Yb31Bty/d1nSy gU3HQSE6od5zSVFKxqojkoq+WoMqHIHdw7DLj20TneR6Hc7sRKlyxuR/3EJbIhsm/K7l SSgXAAktuO8O/W62Suzjg9kjrgsDy5V2P8i+l/dJtj7YlDRqlx+nrcFQD0DWg5opa+N7 rPaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XqdzuZ0T; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-126780-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126780-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d1-20020a05620a166100b0078a2d215ad3si9526925qko.590.2024.04.01.08.10.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 08:10:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-126780-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XqdzuZ0T; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-126780-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126780-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D82771C20F9E for ; Mon, 1 Apr 2024 15:10:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99931482DF; Mon, 1 Apr 2024 15:10:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XqdzuZ0T" 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 8896045BF9; Mon, 1 Apr 2024 15:10:17 +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=1711984217; cv=none; b=dPKH/FdqjmVxvHC8QhrrM9pTOetdNnYKO1HtXi1VWWith022VC/4N1rV5HqwiMukGTHR/1s/22cQE3n7kO460WE3dYv6gVGpAJmXUkrWdVOiXSOsZVlk+4H1baDXmLm+5yFqjtOiDY+SGfaZK4tRXIoamz4qcsXQis3qn5XwLBQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711984217; c=relaxed/simple; bh=sB4XW2Iy9WrEDv3ZxInXXORojt09vA9WlbAC80dGpys=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=juYhmVwnaTKYSzHbVlvhDl5nOhge6rCrjTxsTTRAOOq76hOKexfYN5P40pyFhpaaCmCF6lAQ4bK40LugCjzpBmtxTle4qLnUBQDTNs9OyeLVlmwb9DhuWmC8VkNzkeM31s6m6+zTgfJ9e1U6WG767fpXff/PEvqOorBX5GISCxc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XqdzuZ0T; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 2CFDCC43399; Mon, 1 Apr 2024 15:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711984217; bh=sB4XW2Iy9WrEDv3ZxInXXORojt09vA9WlbAC80dGpys=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=XqdzuZ0TlU9SV1IQWTipwyCFeQFQXqkWz6PyJIVtrt9+OmKll9rWL1QY8CkKZ3BfH /fOIjjOeszDCLUsXOth8Q6GvcoM2/1Zvm0i/rxTQ46fmCQcgvdPlAYPz1nPtVg8wu2 IMHK2V8E4CUc0JkqQkjq+kaSZtpz52S+b62GeG4YXxbJaU4MLfn+lj81TjKWxw65hb m6du6HCFBiFbvE7QZ/66HFm03jp8VMDhcNBxGI9zz6yov+flZolcSbay89eVfvgHQ0 I4fhJvFE3vRgek+y5qBYd0eek7dNK6FBgsU9cL/8PUjBfSEr1sYjf3GZpVT2MJqchI 4BDSXiMrwkmkw== 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 1EB90CD1292; Mon, 1 Apr 2024 15:10:17 +0000 (UTC) From: Dumitru Ceclan via B4 Relay Date: Mon, 01 Apr 2024 18:32:21 +0300 Subject: [PATCH 3/6] iio: adc: ad7173: refactor channel configuration parsing 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: <20240401-ad4111-v1-3-34618a9cc502@analog.com> References: <20240401-ad4111-v1-0-34618a9cc502@analog.com> In-Reply-To: <20240401-ad4111-v1-0-34618a9cc502@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.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1711985550; l=2160; i=dumitru.ceclan@analog.com; s=20240313; h=from:subject:message-id; bh=LP925hA7l/Zq+jxivGEGAOgI2hBOHLlP0ftz5riKxwA=; b=/RbMwmYnyhC5pKQaInX3g8tTV5ka0OyCWhWopLnpDFY3wgL+e2loPLkV1ldaDbSKtknDIKhsB /+X38d8OzhKC/vKCrDsGYSh0zjHicqefIm2+JfwdgrZGF5a+ELQ9yVs 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 Move configurations regarding number of channels from *_fw_parse_device_config to *_fw_parse_channel_config. Signed-off-by: Dumitru Ceclan --- drivers/iio/adc/ad7173.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c index 8a95b1391826..699bc6970790 100644 --- a/drivers/iio/adc/ad7173.c +++ b/drivers/iio/adc/ad7173.c @@ -917,7 +917,23 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev) struct device *dev = indio_dev->dev.parent; struct iio_chan_spec *chan_arr, *chan; unsigned int ain[2], chan_index = 0; - int ref_sel, ret; + int ref_sel, ret, num_channels; + + num_channels = device_get_child_node_count(dev); + + if (st->info->has_temp) + num_channels++; + + if (num_channels == 0) + return dev_err_probe(dev, -ENODATA, "No channels specified\n"); + + if (num_channels > st->info->num_channels) + return dev_err_probe(dev, -EINVAL, + "Too many channels specified. Maximum is %d, not including temperature channel if supported.\n", + st->info->num_channels); + + indio_dev->num_channels = num_channels; + st->num_channels = num_channels; chan_arr = devm_kcalloc(dev, sizeof(*indio_dev->channels), st->num_channels, GFP_KERNEL); @@ -1012,7 +1028,6 @@ static int ad7173_fw_parse_device_config(struct iio_dev *indio_dev) { struct ad7173_state *st = iio_priv(indio_dev); struct device *dev = indio_dev->dev.parent; - unsigned int num_channels; int ret; st->regulators[0].supply = ad7173_ref_sel_str[AD7173_SETUP_REF_SEL_EXT_REF]; @@ -1071,16 +1086,6 @@ static int ad7173_fw_parse_device_config(struct iio_dev *indio_dev) ad7173_sigma_delta_info.irq_line = ret; - num_channels = device_get_child_node_count(dev); - - if (st->info->has_temp) - num_channels++; - - if (num_channels == 0) - return dev_err_probe(dev, -ENODATA, "No channels specified\n"); - indio_dev->num_channels = num_channels; - st->num_channels = num_channels; - return ad7173_fw_parse_channel_config(indio_dev); } -- 2.43.0