Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp82920lqm; Tue, 30 Apr 2024 13:34:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCURJ2r3QvsV7Wmz1fCVHJ2jZcfhz2o+nHKpRHfhEuL7ef1VQQSjQSpbYAiaezC3LTiL75EkVERTHa0AP3R6xZkN8rq6AG/VZS7uc8Xqlg== X-Google-Smtp-Source: AGHT+IHIrtxIRBKdtmUPJizbSPIQghNMbSz5//Xdwv7qcGNq/hxYWTrIz4P9EBI2oJ58w5nQFkY8 X-Received: by 2002:a05:6512:3d24:b0:512:cc50:c3e0 with SMTP id d36-20020a0565123d2400b00512cc50c3e0mr450444lfv.52.1714509244977; Tue, 30 Apr 2024 13:34:04 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gn22-20020a1709070d1600b00a587d60c0f7si9903687ejc.864.2024.04.30.13.34.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 13:34:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164709-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=UW3c+N99; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-164709-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164709-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 87F861F23795 for ; Tue, 30 Apr 2024 20:34:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A64221A0AF1; Tue, 30 Apr 2024 20:33:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UW3c+N99" Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (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 122F150287; Tue, 30 Apr 2024 20:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714509235; cv=none; b=QrKf00EARnLfzC4/EBBKGKqQToesVcj0y6RiSomaL6vZUxdod6nVVzW9ifzd8vP7pVOXygkBrtJX5zQ7yrIu4SZlxwIyW50NJKvyhJ0EB3Ng74cxSC7db17ToAyaEQHW/zXDJkVZycg2yU3IuVIM2jzF11NZck7cIXM+Q+QckhY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714509235; c=relaxed/simple; bh=kcoGDHSpvqAd9PfuCoNtfRvVdf2uMHUY2SdpJjNDwFs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=n16VTRZc6SrDDmP9h9M/kijorEPbTigEePVaN+l/OQfnwmh/PHlflERlMnInbbp6VGcRFXmHBDKaFbxVC61qioD+SehbvS+6oU/HzRxCNqCssUCbU1Ndq6fr3aHWWqYTOGTWMAm1yr2jKSWDTyUKwwb8B4PiJvDE7u4b5cMj7/E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UW3c+N99; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5196fe87775so6881672e87.3; Tue, 30 Apr 2024 13:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714509232; x=1715114032; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=r4iUwetf6OktDd6c6v6370iAXTjd5m8pEJ3+fHMgbhc=; b=UW3c+N99IFpSJqndRE0hRl3e/x09cOUuSsAuyoYe0b07P4EmPfYShbyNt6FO7YBgCU 6bd6NaJOndFdYDOKlKR8dqr/Ck0kKBz5DYTb83mJh+WyuAVa63xRFBO/Dbz2bDS3yNqC kWzhgk7PxesA94WtuZAku9JmjXW1+86h10Cx5vE9WXbNIWG867ymsiT/1eo2SL6Jg6Tk xNDJIscNXPc8ci4btxF7w9jJ9C5gKOFXW9NyqOpq1SVELniangvmcZTKXqlAiqw+l3B/ zyZ0ciAsZCEZyw3+2rNOJZ6ihTGTS1j5rVwON3B/anQTvmHFrex0ihxSuY4iPeSyncMa e3BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714509232; x=1715114032; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r4iUwetf6OktDd6c6v6370iAXTjd5m8pEJ3+fHMgbhc=; b=YHnYJv6G12VPRLoFTUJ3NsxW8ztZ0E+BCe9qElKb5nDk2RPDD6ZL8KP0NRDNHm8pRF tw4YXtwpH6lBpnpwKV1ELK/3nvWO/ds9LAgv/TgL0pq2W0vxiYi+wqjdPSyum13+GRpG S85bE6MMjex9qRNtsova4PcaZ2Sr216Fw62vYDVc1kuACCeCj/D/utWRa0YomeSKmQeN 7xjcMGmGMT8qz3LE81LoEbBW7/8GaQL8Vpv+MOmOTMtk/f0AhLfdv5cqJhS3yt5TCxIU DJRcSCLdezfbNjVsnh9dC0UkEd/GMwz5yQkLJog7jSuyWL0EdF7V3jZeF8BbFRC+u8tk G/Xw== X-Forwarded-Encrypted: i=1; AJvYcCVGGWAEeXsZgNvvTsP3HY/4JSSX342wL7USXNleeERrpTX5K32qNMqFSIM+HsGsG4+M1ibR4eepkkG4crS1ur+BLYcPf920NHUnyRi2/zf0Ml+Gk4l1AKrDEd3Mf08ON5BBRnRVC+wUjNS4B0je/TgDxEOoeOK8JbLIiajQ+pg82/fSiw== X-Gm-Message-State: AOJu0Yz/jpZP8qOsDZapTZ0bhEyWVr3DpUyLIR9qV9ts3rs0gnjUYLro sqNmCxb3cRoWmEOEMUeKeN4hXf42kr/vJ0QlZjTAW734h5qxgrl/S9UvUlMdp3G6PIyy1BcTPh6 bMdlGNWZ+6zRfE0XbX9GIwPDXrVg= X-Received: by 2002:a05:6512:4896:b0:51b:fe4b:da45 with SMTP id eq22-20020a056512489600b0051bfe4bda45mr334480lfb.38.1714509231821; Tue, 30 Apr 2024 13:33:51 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240430162946.589423-1-alisa.roman@analog.com> <20240430162946.589423-7-alisa.roman@analog.com> In-Reply-To: <20240430162946.589423-7-alisa.roman@analog.com> From: Andy Shevchenko Date: Tue, 30 Apr 2024 23:33:15 +0300 Message-ID: Subject: Re: [PATCH v7 6/6] iio: adc: ad7192: Add AD7194 support To: Alisa-Dariana Roman Cc: michael.hennerich@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alexandru.tachici@analog.com, lars@metafoo.de, jic23@kernel.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lgirdwood@gmail.com, broonie@kernel.org, andy@kernel.org, nuno.sa@analog.com, marcelo.schmitt@analog.com, bigunclemax@gmail.com, dlechner@baylibre.com, okan.sahin@analog.com, fr0st61te@gmail.com, alisa.roman@analog.com, marcus.folkesson@gmail.com, schnelle@linux.ibm.com, liambeguin@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 30, 2024 at 7:30=E2=80=AFPM Alisa-Dariana Roman wrote: > > Unlike the other AD719Xs, AD7194 has configurable channels. The user can > dynamically configure them in the devicetree. > > Also modify config AD7192 description for better scaling. .. > +static int ad7194_parse_channels(struct iio_dev *indio_dev) > +{ > + struct device *dev =3D indio_dev->dev.parent; > + struct iio_chan_spec *ad7194_channels; > + struct fwnode_handle *child; > + struct iio_chan_spec ad7194_chan =3D AD7193_CHANNEL(0, 0, 0); > + struct iio_chan_spec ad7194_chan_diff =3D AD7193_DIFF_CHANNEL(0, = 0, 0, 0); > + struct iio_chan_spec ad7194_chan_temp =3D AD719x_TEMP_CHANNEL(0, = 0); > + struct iio_chan_spec ad7194_chan_timestamp =3D IIO_CHAN_SOFT_TIME= STAMP(0); > + unsigned int num_channels, index =3D 0; > + u32 ain[2]; > + int ret; > + > + num_channels =3D device_get_child_node_count(dev); > + if (num_channels > AD7194_CH_MAX_NR) > + return dev_err_probe(dev, -EINVAL, > + "Too many channels: %u\n", num_chann= els); > + > + num_channels +=3D AD7194_CH_BASE_NR; > + > + ad7194_channels =3D devm_kcalloc(dev, num_channels, > + sizeof(*ad7194_channels), GFP_KERN= EL); > + if (!ad7194_channels) > + return -ENOMEM; > + > + indio_dev->channels =3D ad7194_channels; > + indio_dev->num_channels =3D num_channels; > + > + device_for_each_child_node(dev, child) { You wanted _scoped version... > + ret =3D fwnode_property_read_u32_array(child, "diff-chann= els", > + ain, ARRAY_SIZE(ain)= ); > + if (ret =3D=3D 0) { > + ret =3D ad7194_validate_ain_channel(dev, ain[0]); > + if (ret) ..otherwise here is the reference count leakage. > + return ret; > + > + ret =3D ad7194_validate_ain_channel(dev, ain[1]); > + if (ret) Or here. > + return ret; > + > + *ad7194_channels =3D ad7194_chan_diff; > + ad7194_channels->scan_index =3D index++; > + ad7194_channels->channel =3D ain[0]; > + ad7194_channels->channel2 =3D ain[1]; > + ad7194_channels->address =3D AD7194_CH(ain[0], ai= n[1]); > + } else { > + ret =3D fwnode_property_read_u32(child, "single-c= hannel", > + &ain[0]); > + if (ret) { > + fwnode_handle_put(child); > + return ret; > + } > + > + ret =3D ad7194_validate_ain_channel(dev, ain[0]); > + if (ret) Or here. > + return ret; > + > + *ad7194_channels =3D ad7194_chan; > + ad7194_channels->scan_index =3D index++; > + ad7194_channels->channel =3D ain[0]; > + ad7194_channels->address =3D AD7194_CH(ain[0], 0)= ; > + } > + ad7194_channels++; > + } > + > + *ad7194_channels =3D ad7194_chan_temp; > + ad7194_channels->scan_index =3D index++; > + ad7194_channels->address =3D AD7194_CH_TEMP; > + ad7194_channels++; > + > + *ad7194_channels =3D ad7194_chan_timestamp; > + ad7194_channels->scan_index =3D index; > + > + return 0; > +} --=20 With Best Regards, Andy Shevchenko