Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1035402rdb; Sun, 1 Oct 2023 17:20:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHC83JNdDXR33S2N3oz7bAicyZeE47bs5n04GzIoyJL01e6cdjm7HmAIkgwT8JSO3kOZExO X-Received: by 2002:a05:6a00:2350:b0:68e:496a:7854 with SMTP id j16-20020a056a00235000b0068e496a7854mr9695092pfj.18.1696206045196; Sun, 01 Oct 2023 17:20:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696206045; cv=none; d=google.com; s=arc-20160816; b=X8kugvCfhp/kJfpoBYfdP3XCbTWpP2iSILhnNDEb7lV3BFx1PQ9DhWeWiTTB12c6IY vRX+FJyM3eU/XXubib+msKGvDNHWEpt9KqZlzLoNd6Dj+NJ+qWedhYOpJaKkdQTSYiQv Ub8vYRROc5ccrvePPdkLheO+aFEtrj0WZ5As/ahgq5JbiUYxFa2JDZrEpvO03ZWnAJiw a1Rj++whwaPhuHhk3cB1nx+v6iEFdZoG4dIdtIHgBZYlSiKpKLVt16B0zt6xiNjJl5b/ MCuQEBNteaYYTHB0K2IsZdxHwo375ZFxyMbsAjsuz7t1HvoRVKW0absd+QTe4Tr2HVgP mJdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hwznFwcLGryjA62uDf/A8rrsHVh9Jec8flcbVAK26OQ=; fh=RGO26kp9ciH5m/pds4tGsTuI1EtXcJuXY0h+rzFrVvo=; b=vaP+BofsJhcu9+aKLdaRnDIZA/ZSN/kUysrdJKY9k2RIiNp6xLVR4OI+WlhffY0qk2 MrJcehgCaND3ciYGgOXoz1lSPKtN1hjfmqTgwoB26aCjPSwwXc2y5qEAJxz9AWaY4RR7 A2xTgjqAlteGspvXW5YPoDnC2dW9D6rietZotlrcHmx2E6DUxgma9EBO1g9HSM9sto8c mYgF+Uw5AHYe5/COOTPICV2ClsAv8A5/HArZn7KMqlkwjWz/jl5pt//fPyDbYBy0Bn6s XA5t6SeffO50u9cxh4sMJizQ/T1c4pMpeUbg9xdH5jI7tey4HQ7DoSK+iiZTd5b9nIyk BGXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=AEpfCPll; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id fa25-20020a056a002d1900b00690ce34a02bsi28310814pfb.224.2023.10.01.17.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 17:20:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=AEpfCPll; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 223CE80C9A6D; Sun, 1 Oct 2023 14:21:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235355AbjJAVVF (ORCPT + 99 others); Sun, 1 Oct 2023 17:21:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235161AbjJAVVE (ORCPT ); Sun, 1 Oct 2023 17:21:04 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71BE69B; Sun, 1 Oct 2023 14:21:00 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id E162F240002; Sun, 1 Oct 2023 21:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1696195258; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hwznFwcLGryjA62uDf/A8rrsHVh9Jec8flcbVAK26OQ=; b=AEpfCPllhngkkX3X4yFiOsjUmetJ017fvXJRYRViGeKNTcN6N8bLdmo/vcX9gD1nQ0HWOg 7pQynSgHTCgBKnav76tGajYX7XF3jJ4r+/YGBDO25Hz3S8pEHKpC9PELpL6Rmoxyf7/fnK WUlcmnXCRPsdBV+jnCDZ9Eb54aLovugCORI3XAPHy9sNMcFyipgO6f07l7T+QffQ5g8B5+ imMyJtokanMwYbUALfjrNBuJP3VUJWvOLIDOhSOfevtK7oTBRbqHFWpthvODSLbbJBY/sE Ys1uatyCmre29mwZtMzd8wnSM0MPDjioct0ZTZB5JU5ovHiWfoW7f9nrAxRb7g== Date: Sun, 1 Oct 2023 23:20:49 +0200 From: Alexandre Belloni To: Esteban Blanc Cc: linus.walleij@linaro.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org, jpanis@baylibre.com, jneanne@baylibre.com, aseketeli@baylibre.com, u-kumar1@ti.com Subject: Re: [PATCH v7 1/2] rtc: tps6594: Add driver for TPS6594 RTC Message-ID: <2023100121204914ad7c28@mail.local> References: <20230628133021.500477-1-eblanc@baylibre.com> <20230628133021.500477-2-eblanc@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230628133021.500477-2-eblanc@baylibre.com> X-GND-Sasl: alexandre.belloni@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 01 Oct 2023 14:21:23 -0700 (PDT) Hello, What is the status of this series? On 28/06/2023 15:30:20+0200, Esteban Blanc wrote: > +static int tps6594_rtc_read_offset(struct device *dev, long *offset) > +{ > + int calibration; > + s64 tmp; > + int ret; > + > + ret = tps6594_rtc_get_calibration(dev, &calibration); > + if (ret < 0) > + return ret; > + > + // Convert from RTC calibration register format to ppb format. > + tmp = calibration * PPB_MULT; > + > + if (tmp < 0) > + tmp -= TICKS_PER_HOUR / 2LL; > + else > + tmp += TICKS_PER_HOUR / 2LL; > + tmp = div_s64(tmp, TICKS_PER_HOUR); > + > + /* > + * SAFETY: > + * Compution is the reverse operation of the one done in Small typo -^ > + * `tps6594_rtc_set_offset`. The safety remarks applie here too. > + */ > + > + /* > + * Offset value operates in negative way, so swap sign. > + * See 8.3.10.5, (32768 - COMP_REG). > + */ > + *offset = (long)-tmp; > + > + return 0; > +} > + > +static int tps6594_rtc_set_offset(struct device *dev, long offset) > +{ > + int calibration; > + s64 tmp; > + > + // Make sure offset value is within supported range. > + if (offset < MIN_OFFSET || offset > MAX_OFFSET) > + return -ERANGE; > + > + // Convert from ppb format to RTC calibration register format. > + > + tmp = offset * TICKS_PER_HOUR; > + if (tmp < 0) > + tmp -= PPB_MULT / 2LL; > + else > + tmp += PPB_MULT / 2LL; > + tmp = div_s64(tmp, PPB_MULT); > + > + /* > + * SAFETY: > + * - tmp = offset * TICK_PER_HOUR : > + * `offset` can't be more than 277774, so `tmp` can't exceed 277774000000000 > + * which is lower than the maximum value in an `s64` (2^63-1). No overflow here. > + * > + * - tmp += TICK_PER_HOUR / 2LL : > + * tmp will have a maximum value of 277774117964800 which is still inferior to 2^63-1. > + */ > + > + // Offset value operates in negative way, so swap sign. > + calibration = (int)-tmp; > + > + return tps6594_rtc_set_calibration(dev, calibration); > +} > + > +static irqreturn_t tps6594_rtc_interrupt(int irq, void *rtc) > +{ > + struct device *dev = rtc; > + unsigned long events = 0; > + struct tps6594 *tps = dev_get_drvdata(dev->parent); > + struct rtc_device *rtc_dev = dev_get_drvdata(dev); > + int ret; > + u32 rtc_reg; > + > + ret = regmap_read(tps->regmap, TPS6594_REG_RTC_STATUS, &rtc_reg); > + if (ret) > + return IRQ_NONE; > + > + if (rtc_reg & TPS6594_BIT_ALARM) > + events = RTC_IRQF | RTC_AF; > + > + // Notify RTC core on event. Nit: I don't feel like the events varialbe and the comment are necessary. > + rtc_update_irq(rtc_dev, 1, events); > + > + return IRQ_HANDLED; > +} > + If you resend, you can add: Acked-by: Alexandre Belloni -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com