From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 24B0A1A38F9 for ; Mon, 23 Mar 2026 13:31:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774272704; cv=none; b=lNaQw3nO5buxIYiEWmPwUOHgPXt9VIDPpkjOYBMCAxFSxVP3vRzeBa9rVUrOePayFB+dKAVUti1PFOXYI6+13H65LyAcKL5/uL81IrkNqDAihrnTeRC2mMI1ssRu0ODrVJUY/8oldxEmPoCwZ6Mx49LG0r0VUc0DZaoTrWhajl8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774272704; c=relaxed/simple; bh=kNmTTrYjByOMzpg68PhBXByP+zmN2Fvtyn6F/3UNESY=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mdaVDAim3F5VAU2wZuv8WRErQ4M0QdAcpo+AzC0ssMFEJ9mF0Npg9w4HJTJN2K6Kf395QiTaOqmjJaafEJN8mkOAPrrcqJn1inDtPEfHkl1xamgLmLYS+KI2aYokpE3hA82IeCZHeZXhaZFzHFofFwd6h9MVISKUbj6DPFwhWDg= 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=cruZhiVy; arc=none smtp.client-ip=209.85.128.54 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="cruZhiVy" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-486b96760easo1271455e9.2 for ; Mon, 23 Mar 2026 06:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774272701; x=1774877501; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=guTmxpVu1G0axBh/5OR9i2kXvhmBwdLlWA3HNxxLfLs=; b=cruZhiVycnsyYIoG2IGxmmUojuVejuYDdy+aZuWERd3xQCUlPdBLMgqnWLB98cHWDY +uethRWZ3wVXw6Wyw2HDz83nJLa5UOKrA8zkRR76/Icj2+QmLWlLLXJLP8I3oDjWMcfm 12Yr+Zggf7ftSvzlk1+MsWOUv4NIoTu2rOX9dZY1xWspwtAkNBn5nIBm2uO1jVhgUG6z 6THu4Dd8t9PF5YOJ/twmNEC1YI23aYBR1G0PS5OYE8dnln5TD8DUSffgP7Xrp1VbQVd2 TBC5VlPEbb9/AiKyLpQrJnOl8d6B+7ABCEGxrkmRdHDTuMier7z7bSlRHqg/zEwZGMok igYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774272701; x=1774877501; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=guTmxpVu1G0axBh/5OR9i2kXvhmBwdLlWA3HNxxLfLs=; b=aMv0Md3IgXSrF0b6wY0gIqxWmbbAMB4sHluHTetCdn0PRYeDugBPe3cS92RxZWDNWz BDksI6q1JQ4RCYDHfhmbmFNwwW0tfqjjAo8Plkbj8fGmtL2mIqad28jySKVFMl/tvmbl wSAl2HbsW1W8Fvin4iGnijJ6l/ioa5wW1FQ/UYBmZXX8LsivKjGEb2hMt7J7OBQbsWyK zY6t8+GXyH/ueMA4267VyxH+EzamKvS+H1+PVzHimFxz1ufNDgb1+EfBIPcRyH3Ndhio xHCUHtQfIgdBY2FEhAf30kmQcpTDrgXGKotJnYB8PFVZXVyRvlBxwTxRuzZ1EFubjSWf GTIw== X-Forwarded-Encrypted: i=1; AJvYcCUFPo+I5fwHQch8WpK77XvHrs5vvaB4HIiMs3igS2n8jDYTY2luPf3L6+MeA2tZS+lnvKmhIsitnZv2ZeQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yxj/NUAtB07LGmRpOUwWguxtDLlE4l3MsubitD3R1sHrMMZYagT w9lNmkZO8LzYWOxJ231mFipEjY6JrmZLh/vhUU89nwY0E/lFUenXUlBU X-Gm-Gg: ATEYQzx58GQV0Vy5i10sgcvU8P9fjKZP5XLMvooZMzhEk4XOCxy1nx3/7e9kqsMOrOz 6JgsKVFDbYjZ4TX8C7AI0tUB4zwZDWT5f8n1Gp75qzLmAOnMraswKRmsTCbzsPvtbwH+06zq1e0 pYXunZHtEgvph2kI2YFz0n4hzpA7Q/ZvBhRFdrtTjg+OHUMd9I/FS6Qon6PL/IeSkUq0pRxwYMH MUDFFgb65Uv0cDuPt4cY94aFZRB0/3t7rZYxdghb7lbdHDnTk2EUHGJfc99wzcwg0N7JiX5z0Q5 sk+5d39+iuEYMDPp9xIDMOay+zX1MMm0eeEY74VoJbDjsCnbDOBD0ZNBkTXITJIMcEGurfT+ZwL zhuf/hfJzxYQyE63TbHMe1aUlPBo1ApSZaWoPo1PRun8qpSH1yB/cWE7Vg7O/HW2pEt+og8xpJX skDK9wFTe6mc5O5urlXD6tFb0JeO9/xkEyzA+/Rc/kgBcJ7X+5cw0yKKTqcgxdy+9J X-Received: by 2002:a05:600c:47ca:b0:487:169:9f64 with SMTP id 5b1f17b1804b1-4870169a1eemr88718715e9.12.1774272701146; Mon, 23 Mar 2026 06:31:41 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-486f8b949e1sm582451115e9.9.2026.03.23.06.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 06:31:40 -0700 (PDT) Date: Mon, 23 Mar 2026 13:31:39 +0000 From: David Laight To: Nuno =?UTF-8?B?U8Oh?= Cc: Andy Shevchenko , Neel Bullywon , lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] iio: frequency: adf4350: replace loop with fls_long() Message-ID: <20260323133139.6ba140c4@pumpkin> In-Reply-To: <920aba2275ff1da033214293a603ef1e215d3dcb.camel@gmail.com> References: <20260311020115.56321-1-neelb2403@gmail.com> <20260314172006.69744-1-neelb2403@gmail.com> <20260316135151.309207ae@pumpkin> <920aba2275ff1da033214293a603ef1e215d3dcb.camel@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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: quoted-printable On Mon, 23 Mar 2026 11:08:15 +0000 Nuno S=C3=A1 wrote: > On Mon, 2026-03-16 at 16:07 +0200, Andy Shevchenko wrote: > > On Mon, Mar 16, 2026 at 01:51:51PM +0000, David Laight wrote: =20 > > > On Sat, 14 Mar 2026 13:20:06 -0400 > > > Neel Bullywon wrote: > > > =20 > > > > Address the TODO in adf4350_set_freq() by replacing the iterative > > > > power-of-2 shift loop with a constant-time bitwise calculation. > > > >=20 > > > > By comparing the highest set bits of the target constant and freq > > > > using fls_long(), we can calculate the required RF divider selection > > > > in a single step without relying on expensive 64-bit division. =20 > > >=20 > > > Where is the 64bit division? > > > (apart from in v1) > > > Indeed where are the 64bit values at all. > > > If this code is used on 32bit it has to work with a 32bit long. > > > Which makes be think that the 'freq' variable should be u32 (or possi= bly u64 > > > if frequencies above 4GHz are likely - which I doubt). =20 > >=20 > > I don't know about _this_ device, but before looking into datasheet I w= ouldn't > > put a low probability on the frequencies higher than 4.3GHz. We have (o= r going > > to have) devices that work with up to 26GHz frequencies in this folder.= =20 >=20 > Yes, it goes up to 4.4GHz. In which case all the 'long' need to be u64. David >=20 > - Nuno S=C3=A1 >=20 > > =20 > > > In any case this looks like initialisation code and the existing loop > > > has the advantage of being 'obviously correct' and small. =20