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 C4FB527F010 for ; Thu, 9 Apr 2026 21:46:13 +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=1775771175; cv=none; b=BFljeVeENqgWGIH1U+5QA/D468PL+M09UNz+gdNlqZh1shSexjYxqqQyKP2bXuX44DN3QUfc9PdCji6m2dJGVcEEMwanenJsSERE2rh1QMpY991VRzaHrRGuMOMm795oMwbjSjCIsPUARKam2qh0Ps1S89E+ZS5dmdpzAJUZLQw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775771175; c=relaxed/simple; bh=aa0Kv53GKsOZPdXhCjjoUJZEwKI82rcoBJpFvZGdXYg=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rrQ/KZtOQlp6erFfvO6x9YH+bkmoszvZR65FXYUwaghxb29x93cs9ZURMGlScm0EfMYlUAJ66dTLARQgWNgeySQRaHR3rFRr3ZpAWf2uoD6hzU9wePwaMYHlqiiqCEyaR9vxKOc3JV0RG0IrXNZb7qQVoS12BDdhvQBx8Bku3C0= 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=KxPvrslU; 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="KxPvrslU" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-488af9fdaa7so8799325e9.1 for ; Thu, 09 Apr 2026 14:46:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775771172; x=1776375972; 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=zKZ97EUNpti69PwZiOZxOsJQ3NBK/kMV901OOo+brBM=; b=KxPvrslUr2IYnhIGg8Q/umkgYuonsZIKpceFeRmxznxwSr9FrR96M4qA3SZrhxOcOV qR+WnHlyeAMv+UMnGCZSen08VwIC05LpT68nJprXuFGld86ox7dbDSK7230aNRSYEHA0 hFbzfIWH2pW0n38X+HJ/rdRW476vS9gIF7mMrw/vGyOxVMkdVuHMui4hi/Kk2OhD6yD0 cu1UVC6wpchDwO85BkSswI3IcH2ZsA5CB6EWxJMpevneYJWvwlKBSFYMHNP2xo2S0oni P8UPAjWiV8Iv0n/B2l7/85rbuzDWOqQ6ApVLtTlKqTIw4GvxClufq+dAegjfgWKNbKpn 3Kfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775771172; x=1776375972; 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=zKZ97EUNpti69PwZiOZxOsJQ3NBK/kMV901OOo+brBM=; b=qrY7qL+j5SiU3nH9LLFQK5rhWAJ6Tzaa3s8tIvGjb4HV/SBQr2NASzjws7nPWyi5a8 LL/3OMnwULhroXvw99IFEenD0wSlPUiIBN1nVKV+dDfRz8i7YFZ6o+6OksO8N54W9AAW 1Z4azX5ckIBV+ugQM4drcBywKmgibT1pW32zR4Yk6fb1i3spc1GsUI64FdlkvccbuPGN /ZHKtCZ/OCPj1pQaDkZzW8bGcal59deKWhUcEJtzr6oZRva0dAhxDLkfQZvuUdiPslZL GABXYrOuisYFdfX3K5Sg+c1t06qO10Ip2ba5fzgUC1nViiAjEu3MO4rv8g0a6G2hvVJt 0TWQ== X-Forwarded-Encrypted: i=1; AJvYcCVGjzKy3ztkLTsISVq99VBcLyPd+1fASao3wIfbJZ7adW4VVVt/1L+RjKsMqnn2/eduFe/N6QdNgON62SE=@vger.kernel.org X-Gm-Message-State: AOJu0YweM41Nu/O7BmikWZDp9cEvoKurokFZttPvNe2uaERJ0PREMFRR HTGjdHnGK2RdDqtiWuLA/zbggj0rhsV524+H5dpJBuYNGIAz6FMqpne5 X-Gm-Gg: AeBDietWvw/it95GNId3dACC0UL+kV6PfpUvJUk/BkNnEoRBLNeXZoxZPEx31WvWj+j QbnAstQ/mQk2TqIhIl81t/j2UFjVo8d2h860xMC7EpNpKIrLgbkcxaM40Uz/uaBd9MJrHbaNNAR MGHVOopxPRXumGa/mToraFPOLAt1BlR6cwexvTvsw43vGqk9dkATa1K97AVYRW/vtTYJhzGkaAS 8LP/05vtI/xDTGUlIGvLut3i+EnpmQAhf0MhOHfdqPm/UR4JZebWUD+6VhHRi5IAFJesaRJI9W+ c5I2fZlrsa4YGLSHAWqTOXfumwRRGHRhzacknQZlKJxT6UgKeDEaHngQvbIGa0zz268aJ486stU X775o7OHojALyN5Bd/vx1L44vtA/gIgxDKI3BJ2Km6f9SJEk6Z9Bn1gr/++Mh7yLOPaxneNN5xi fn5Jyqlspf5DDd+fDL9VteFlZxMKdpuJlPYFBeLdur4xzR2viqMPXVgDGiQcgOWUyMvoqE+Qlty nc= X-Received: by 2002:a05:600c:8591:b0:488:a824:fe04 with SMTP id 5b1f17b1804b1-488d6abe9e4mr3406955e9.26.1775771171966; Thu, 09 Apr 2026 14:46:11 -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-488d5b3cbb2sm22726265e9.13.2026.04.09.14.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2026 14:46:11 -0700 (PDT) Date: Thu, 9 Apr 2026 22:46:09 +0100 From: David Laight To: Joshua Crofts Cc: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, greghk@linuxfoundation.org, dlechner@baylibre.com, nono.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: Re: [PATCH] iio: frequency: ad983x: replace do_div() with div64_ul(). Message-ID: <20260409224609.3e36a208@pumpkin> In-Reply-To: References: <20260409131823.1289-1-joshua.crofts1@gmail.com> <20260409182755.499a419c@pumpkin> 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=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 9 Apr 2026 21:58:20 +0200 Joshua Crofts wrote: > On Thu, 9 Apr 2026 at 19:27, David Laight wrote: > > Except here you have clock frequencies. > > Either they fit in 32bits or they don't. > > So the value shouldn't be 'unsigned long', but either u32 or u64. > > The clk struct in linux/clk.h explicitly uses an unsigned long to represent > the clock value, which is used in this driver. Using an unsigned long > ensures platform independent usage without type mismatching. Not really. I've NFI why the the clock API using 'unsigned long'. It almost certainly predates 64bit and any real idea that a clock might exceed 4.2GHz. It might even come from someone who wrote 16bit windows code and wanted to ensure it was actually 32bit. For 'platform portability' clocks are limited to 32bits so the 32bit divide is fine. If the clock could exceed 4.2G then you'd have to use u64 throughout. > > > You need to check the domain of the values, coccinelle is just looking > > at the types. > > Even with mclk being 'unsigned long' the code is fine provided the > > frequency is below 4.2GHz. > > I agree that we're not dealing with potential truncation problems, however > changing to div64_ul aligns the types with the clk API and scrubs a perfectly > valid cocci error. cocci only does type checking, it doesn't know the domain of the values. So in this case it is almost certainly a false positive. David