From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 3A3E646C856 for ; Mon, 7 Sep 2026 11:18:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788779883; cv=none; b=AzhGci2byg4zjgPhisHqbbSn/O+cdRWdQU3Has45JRxB2YSHUhamwAkgb+awDT2phM+nQsxcG5xm4g+Y3dVtsoevWiWk2mser+fqZ+RFQSBGJ28uqhNjsTbWOH1GWYvhfZwFBcYT+0N++V7M6b77Bwv366YbwhovXpocyylKNM0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788779883; c=relaxed/simple; bh=vc/u2+6K3u9duPkyjAm1VSzu2f/ZyL4eiCIH6p0kCCM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=buWD3Y8AQmieodQVOJ7nKdkKZHpET8HnBUp/VBPcWQOBd93DZX1UuNep4HsohToctHGdNff3RLMpaWjUShgS4ZnvWPpOBaG79Ki7t2xlQjzD+qV8U+kdf1/EFi3pDKJIADHSbAsVd8fJTXtWwMCVdPgfri2YXa6cufS8PMzMMZc= 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=de2MEp7Q; arc=none smtp.client-ip=209.85.128.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="de2MEp7Q" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4998b5a63e2so41333255e9.1 for ; Mon, 07 Sep 2026 04:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788779879; x=1789384679; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=kZeKG88pQvz+t3Gm/KrMtRBK71hTluhBWfm1A4t1QXw=; b=de2MEp7QCbYxhT5Uaog3gIdpkYeUO0mVMVQtiCMgH5BJo4MLMu0GREGhdFYPLS2Fua cxA/Pdft+yc3I+Zr3i3LCX/V9CDxAURVLJKTpP0pEGp7/pUJ2Zia5amibAXFRo7GNTIn bbgNa6YiKBYgCOOx7JHcYR3sFNer6TirsXmCrtfmL1iPQx5qelkve5peqcyZ4HITw6Dw QROMDiYlC8mkzpX8RO59w4qY5GWHM91SKo4XPP258xs0JXB5J+AwGxhKErj/qTtsqHKP ihyTQ2cqlwiXs3QUOsRHJVWEqTRsbBPFs+VpgL9lu2dTBq+akrYPKlUZpnkEnKkvEeBT 4nVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788779879; x=1789384679; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=kZeKG88pQvz+t3Gm/KrMtRBK71hTluhBWfm1A4t1QXw=; b=XfAW1bqdhbmVkRJ+KyfdJOG1ckSvAq2JsH45xKRmzKhJw27BhsBIcNgRdMrWqvznWX X1DbfteP4DFKPcayU7OIFJ+4+dAQ2s1VFjPY5pMlZxMBZ6qzYEUTGgTEFuZZTP+YnLIl Rxo9IqLIJNR32R5e8cD4s0VUgQFGCGdwOfsgioOTS3NHy5olNQlfskLF7upkdQ+0c1s8 pFyiFj5qIwlzTd3+6L0fggjnpYcnPvdusTe6wI8dZA+GEQ9Lxoa15PkSTH1npAqmtnI+ 3sUJ2fiyeThM/cCKAB9J7sdC8gkfY1mbn1jMbRjrifdq0axvvNlJA7+ulWxOSLyd0Tjk DgKw== X-Forwarded-Encrypted: i=1; AKwUvBxacsRp7dm2TQLOpjxFjhrD7GgKDN1agSgjOi7W75wXNb69ZDE2xL/bZmFY3FDFGhgUX/esF9KblCc=@vger.kernel.org X-Gm-Message-State: AFuF++l0u/m8HR93pOhsuiGSRGQDxvp4Id+1q1fX0h6zobqLxo09EHVX XYpYGcf2fnFEQDKdOHkaA/z7JVty/Dn/0yDYtU5K+USww45wS6twKvOo X-Gm-Gg: AYBFou0S+wZsh1l+agWMvZLLiJmsJPULUNb/BJqzSmA5wckOVo3FCMg9ceuS/JRz9Wb aoijXldjvazSvjREJukx6IWV3i9GDrO6FuuJBYrm2bAFo09lZB54LsHIgvM72J+r1vLW9Y/Tmcw 78NlcdFSP7lFNwx64n2qZGV6xN6ok+sQeq6okZAeji2iPmLHOQ/+cvxDEbVXkszbXH4k30RU6XJ 6n4H4ahyWPwOqmr/T3EjBsu6Y5yVYPFXgnZgzBTLO/muRpeUHMuPtDVZD5o90uE7Leor18dPCfA H5JPcEYH5C/z+8IlSFBRkbY0VOqFzZ3qPldcwtJUAu9B7mnhLZ4Y7ujrKo/bXnVkT59kZZ4cHZX sc21aPDSnSqRl4uZhabHvdwyOcufwup7KLNu8fEH0nsLUAmJiceXvngErkNsTXCLSZCDvZY4n1u fYP6+bHD/0rfQIEvU4yNkDaCbTKnptTqpQscPZChy2rFiCQUz7DkQFkfk4AXPqkH6JB4tFQUPQ X-Received: by 2002:a05:600c:3e06:b0:49c:fc6c:be1b with SMTP id 5b1f17b1804b1-49cfc6cc0e9mr176101505e9.33.1788779878713; Mon, 07 Sep 2026 04:17:58 -0700 (PDT) Received: from [172.24.138.145] ([137.71.226.102]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49cf7736132sm296957105e9.12.2026.09.07.04.17.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Sep 2026 04:17:58 -0700 (PDT) Message-ID: <4056ce28-cbf6-46cc-8bcf-a3db35410275@gmail.com> Date: Mon, 7 Sep 2026 13:17:55 +0200 Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 05/17] iio: adc: Add AD7768 and AD7768-4 core support To: Andy Shevchenko , Janani Sunil Cc: =?UTF-8?Q?Nuno_S=C3=A1?= , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Olivier Moysan , Philipp Zabel , Linus Walleij , Bartosz Golaszewski , Jonathan Corbet , Shuah Khan , Michael Walle , Randy Dunlap , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= References: <20260904-ad7768-driver-v6-0-e4378f946bfb@analog.com> <20260904-ad7768-driver-v6-5-e4378f946bfb@analog.com> Content-Language: en-US From: Janani Sunil In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 9/6/26 10:34, Andy Shevchenko wrote: > On Fri, Sep 04, 2026 at 04:14:57PM +0200, Janani Sunil wrote: >> Add core support for the AD7768 and AD7768-4 simultaneous sampling ADCs. >> Configure supplies, clock and reset, use a custom regmap bus for the SPI >> protocol, and parse the enabled channels and input buffer settings from >> devicetree. >> >> Connect the converter to an IIO backend for buffered capture with CRC, >> provide a fixed safe wideband sampling configuration and add runtime >> power management. > ... > >> + /* >> + * DCLK(min) is ODR * channels per DOUTx * 32. With fast mode >> + * (fMOD = MCLK / 4) and x64 decimation, this gives: >> + * MCLK / DCLK = 8 * data lines / channels. >> + */ >> + dclk_div = 8 * st->datalines / st->chip_info->num_channels; >> + dclk_div_reg = AD7768_INTERFACE_CFG_DCLK_DIV(dclk_div); > So, this one is (4 - ffs(dclk_div)). If num_channels == 1, this will always give 0. > If num_channels == 2, this might give 0, 8, ... Since ffs(0) implementation is defined > to return 0, this will return... 0! So, tell me how this code may return > anything than 0? The st->chip_info->num_channels is fixed at either 8 (AD7768) or 4 (AD7768-4) and not the number of channels described in the firmware. The supported dataline configurations produce dclk_div of 1, 2 or 8 and register values of 3, 2 or 0. However, I agree that using the ffs() obscures this mapping, so I will replace it with an explicit switch over the supported divider values. Regards, Jan