From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.19 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796300208; b=IM7fXe+BmXEfRC29NLRoBLPlWVkVeUy3cD3arFKc6s74UA0kLQGy9mLr/x/OEyd5dp99 hvSttzRUCcnRi8zPaodN1i2Z55Z8BicCANOsQ0oWn+O9O17+uSQvuc7a8SaByZnNRRmfZ ejsRTV7Umsjx0j/5GPdeKId4ttxFC5AwyjNlh1CAerB9Ne4xPpQeoZ++mjGFULpft5hIE HLmlKpIndeDDNx3AXq9k5VUdVHObM0hEXMKl0Wtw62QmCLGNf1HGy2ebx4MYb4mFJNmKZ YKjUpoF9buSVY5xyrROmVyoGEAHyPctfsu1O+iSkV3VnmH1foae3PhW02Pa3itEj1qA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796300208; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To: Organization; bh=cRwhmmEiS5uy9kcraoeUCcWicIx/rQNZJgUfgKr6YSA=; b=PwbJhlN1Ppvrqg48ErxtXadXHrxtSusUCUCP+2/WNflWCC5eynpun4tCwx78bm1wRdO+ 4U3iXqp6prTUhLa+a+L1UtPkNt07GUba0gHBjdIqQ+QAp0MaDxnFS2rdpiDp4aDNQTNNg 0pvi8ihBe7ZcOfNAzDszJO4bVVFihQBwAuQ7bAA3YRfUgBtNi9jO4Plht8ADN59kXfunI xu+BUxOuJKjS2YQGTdgNJm+xrMDvZn/tJKUB0QanNu7Fb3YCJXjDInl/Oer4JXZQJdj9d Ba59Jr9HNMAgbgHL7w2GbI8pUeH8YLrDsr+VYHm7g8TXaWZTJoILTmx7SGMUML3lk5w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=U+9LWGkQ; arc=none smtp.remote-ip=198.175.65.19 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9801D606A689; Thu, 3 Dec 2026 12:16:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9801D606A689 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=U+9LWGkQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796300208; x=1827836208; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=cRwhmmEiS5uy9kcraoeUCcWicIx/rQNZJgUfgKr6YSA=; b=U+9LWGkQdLeKkwiDdOKPlwrtP0VM2PzrPV1HCs9TZbbn9FeVttAKl9wl dZOKCcELxyDb6xiqIFCAC9JKtNa20Mq/IUNWKPYTHZ7i9NO7ZGebHsu+/ 5jchqJpy2iR0RH5jjSGTt4n3T5pDFtW4wV3FRAJMhs70QC9dmOpxR0fCZ soFWid6osGVs9ih/mkxCF8EifTze7nTFDnTimvT0mxztYhondV1TFpXdu dLcj71NCF/ewi7BsI1dTYJZ0EnlKKX/PdsmBbgbT9+k6m7NIBkAJn7oyL 7pW/GmHCXiXKtm7q3UWkzWum+DQKnpRqpEAeWYY95HYvtb+NRIvUR/bas g==; X-CSE-ConnectionGUID: 5LytJDHFTg6LHgU1krefTQ== X-CSE-MsgGUID: DsV1x8PXSNWFNCfmHrwgSA== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5336952" X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="5336952" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 04:16:48 -0800 X-CSE-ConnectionGUID: kYr/TT21R4uas+4ZktdXnA== X-CSE-MsgGUID: rwha28GaTdS9fJO4Wh1ALg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="13620295" Received: from inaky-mobl1.amr.corp.intel.com (HELO localhost) ([10.245.244.115]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 04:16:44 -0800 Date: Thu, 3 Dec 2026 14:16:41 +0200 From: Andy Shevchenko To: Nuno =?iso-8859-1?Q?S=E1?= Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Jonathan Cameron , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Arnd Bergmann , linux@analog.com Subject: Re: [PATCH 03/16] iio: frequency: ad9523: fix the M2 divider selection Message-ID: References: <20261130-iio-ad9523-fw-v1-0-9aee15b7a7a2@analog.com> <20261130-iio-ad9523-fw-v1-3-9aee15b7a7a2@analog.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261130-iio-ad9523-fw-v1-3-9aee15b7a7a2@analog.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Mon, Nov 30, 2026 at 05:37:01PM +0000, Nuno Sá wrote: > For channels 4 to 9, the M2 divider is used if it looks closer to the > requested frequency than M1. However, the comparison is done on the > largest multiple of the requested frequency below each source, which > does not tell how close the resulting output is. For example, with a > 3000 MHz VCO, M1 = 3 and M2 = 4, asking for 500 MHz selects M2 and gives > 750 MHz, while asking for 375 MHz selects M1 and gives 500 MHz. > > Compare the output frequencies each source actually gives instead, and > only use M2 if it gets closer to the requested frequency. ... > +static unsigned long ad9523_chan_freq(struct ad9523_state *st, unsigned int src, > + unsigned long freq) > +{ > + return st->vco_out_freq[src] / > + clamp(st->vco_out_freq[src] / freq, 1, 1024); Better to have a temporary variable for clamped value. Also are 1 and 1024 because of the width of bit field? Maybe BIT(0), BIT(10)? > +} -- With Best Regards, Andy Shevchenko