From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB7E6C7EE2A for ; Mon, 22 May 2023 11:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233526AbjEVLu3 (ORCPT ); Mon, 22 May 2023 07:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233567AbjEVLuL (ORCPT ); Mon, 22 May 2023 07:50:11 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E14621B5 for ; Mon, 22 May 2023 04:50:01 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-30781184e78so2401276f8f.0 for ; Mon, 22 May 2023 04:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1684756200; x=1687348200; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sKgwbXDZ93PhOsZpMHYSuhMcEuh5tVlQ5GHAYoAXTTk=; b=oXlZi6dQ+locvnwMb6tXz6Haerq4h2rmMsYNDuyKGsjCLrXuZZ1WoRXsul7Hmffq5V BAL5Xy1fvZBlwHlGAT4Gt9cdnpFuUHC2JYFmRLtAE9y3lQmrh0C+vKG4mtkZbEBMn711 CKts6AS3KF5mRTiEiAI+P31FqY1psc+RKnBht4wKqqVdoaW+l7FwVq9KM4rxq6MEu5Fq Io9rAmmmjXOOwWXFp2Xy8qeX1NwzTdOOwg3ScATZSQ8mzRVx61Q2314f4i1dos2r1GoA cMt8ymh+xftxI78J0hkyTAuZvtfVhvhgUMELKVvy7asFaUmGTrJNEsNXE2Rowf+wWf42 dQww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684756200; x=1687348200; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=sKgwbXDZ93PhOsZpMHYSuhMcEuh5tVlQ5GHAYoAXTTk=; b=VVuE5zY8CRA1npMVocI6WdxJW+CDw+7gw0K3+lKhioLP7ai5Lceo1nSutc22eV/PXg KtNH6rtl3nGXU7LWGZs4cKbgpGdSKxfLJrprrJysPChpRMRv2QZDR26Zfxfbl78IXZG5 Vtlm+iMxg3Z4vNKxnRx0TAgk5SPOryf9JY1aNjnxIuc7t3RlT5VfuO1E30bPygpJiXet PgO01RM44NJPmZqQGGSHzNGWVq5fP6F3FaC6KangrT9IVR6H8bf1CicM83Z2ulTsMSh0 R++Rrx4YwW1gZOes6b228Z0VxalWuJpG1VPSugghFBSnU3al/9YwL2TTnvThjcd+zEHR 1Cmg== X-Gm-Message-State: AC+VfDyE367Hwp0xiKJSFqugUaKzB3KYcRvOGCBP5tFXurqezEcgbKQK vk1ekGjkwaC6le4zUtCNuSm3HA== X-Google-Smtp-Source: ACHHUZ4aNoH0wsH4IeJXzePZtSiXVMs1nKqN0mwAKpV4dgI33pkdm3OAwuaeuaJLSl4OQrhKVI7aag== X-Received: by 2002:adf:f48f:0:b0:307:5091:5b96 with SMTP id l15-20020adff48f000000b0030750915b96mr10113342wro.22.1684756200409; Mon, 22 May 2023 04:50:00 -0700 (PDT) Received: from localhost ([2a01:e0a:28d:66d0:72d:52cc:8221:fcda]) by smtp.gmail.com with ESMTPSA id n16-20020a1c7210000000b003f6042d6d92sm3490280wmc.46.2023.05.22.04.49.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 May 2023 04:49:59 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 22 May 2023 13:49:58 +0200 Message-Id: Cc: , , , , , , , , , , , , Subject: Re: [PATCH v4 1/3] rtc: tps6594: Add driver for TPS6594 RTC From: "Esteban Blanc" To: "Andy Shevchenko" X-Mailer: aerc 0.14.0 References: <20230512141755.1712358-1-eblanc@baylibre.com> <20230512141755.1712358-2-eblanc@baylibre.com> In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On Wed May 17, 2023 at 6:52 PM CEST, Andy Shevchenko wrote: > On Wed, May 17, 2023 at 7:47=E2=80=AFPM Esteban Blanc wrote: > > On Fri May 12, 2023 at 7:22 PM CEST, wrote: > > > Fri, May 12, 2023 at 04:17:53PM +0200, Esteban Blanc kirjoitti: > > ... > > > > > +/* Multiplier for ppb conversions */ > > > > +#define PPB_MULT (1000000000LL) > > > > > > We have something in units.h. Can you use generic macro? > > > > I found GIGA, NANO and NANOHZ_PER_HZ that have the same value in > > units.h. However I'm not sure any of them have the correct meaning in > > this situation. > > MULT[IPLIER] has no units AFAIU, so SI macro can be used, no? NANO or > GIGA depends on what the actual sign of the exponent of the multiplier > is. Write it on paper and check the exponent in the equation(s) and > hence decide which one to use. Thanks. I've checked and it should be NANO. > > > > + if (tmp < 0) > > > > + tmp -=3D TICKS_PER_HOUR / 2LL; > > > > + else > > > > + tmp +=3D TICKS_PER_HOUR / 2LL; > > > > > > Is it guaranteed to have no overflow here? > > > > We know from `tps6594_rtc_set_offset` that the loaded value can't be > > more than 277774 (register default value is 0), So `tmp` can't exceed > > 277774000000000 which is lower than 2^63-1. No overflow here. > > > > TICK_PER_HOUR / 2LL =3D 117964800, so at the end of this computation, > > `tmp` can have a maximum value of 277774117964800 which is still > > inferior to 2^63-1. > > Please add a respective comment. I've reformatted this and put it in a SAFETY comment. Thanks for your help, --=20 Esteban Blanc BayLibre