From patchwork Thu Jan 26 14:20:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48715 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp297257wrn; Thu, 26 Jan 2023 06:25:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXsqIPi7EiEkFRzQKZuFqhSYP6xc7nWtbVePTG4CwnCDd+poVZWQRQXh4clYZSJS55bVQchN X-Received: by 2002:a05:6402:5306:b0:49b:b274:b815 with SMTP id eo6-20020a056402530600b0049bb274b815mr40113411edb.39.1674743133220; Thu, 26 Jan 2023 06:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743133; cv=none; d=google.com; s=arc-20160816; b=Q3Aoy8HdAjDQve3o7jSYfIgJEoYOgzyEa+r31WkCRkae1eYj280RpjLUr4D/iSeE0T pfAXgL2BunHGJagDBe5tIHNYsujYQkWr2ufU8GQL4uTkbPOaDdcJOygm6Qulv6YHoabX NZdMrjbct9SuBudmPwQLGIDWE32IGyRYQYehMi+OrR1JCBEPxltN3+4D+hLS3Tz19x6y yp9Pj5VwEO4lc+nwGAr/U5nNkYijVjNzdNuBuJmlN0+wFKhJaC4RuHKwlf4IQnHCRhRm mjA0UO4oqDtcCUUix3VS2dr+MpN+8hVBVUAdUemL2eZilAz4SUcKUrIrDiY+ZcNHxUO3 HUsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r82Uy/4GkwmX4T8zh+mXPpVq4PFwdPiMIZOrJao3JEY=; b=BNTgAJ/8i6tVHXhwkAkzVg7Y0yUf5rNzKzDEQqQ0tq2LkbmJCCWydEIjZ3c/LhqzHx IL6yB6JsFiBSAYenqMNhIM+GqRCrmxQI1kZfPgTQqSMlo8Hjaq+F6ti+pHSQaVSp//Yj SIM0RsEkoaKtEoIcDtIKdmIlXxD1Bs7ZjtllVr3e963S170kYY0qMAZkoH7oPfSQ5xVo nddQMH+VZDCCV7jStC1/wA+ATJVkT1B87uaeNl2NGXmNm4wh8uVV5qpTgTQq4dXPsgNR BxofyXyiQUAy+9QLMHa0U7zjebjXut6AhQjOdGDLxvtexXmjlxL7nLHjQd7/c5+nHECO vWLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DyoqI8A8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 16-20020a170906021000b0086f0864592dsi1644921ejd.321.2023.01.26.06.25.08; Thu, 26 Jan 2023 06:25:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DyoqI8A8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232088AbjAZOXU (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231869AbjAZOXC (ORCPT ); Thu, 26 Jan 2023 09:23:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EC60113D6; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D4D4861851; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 201BBC4333B; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742978; bh=/YRM5Ic3ZY+jzd9X9EDvX7MvH3WHxEA0VUrC4Satfvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DyoqI8A87cJGQXnD7+L7dl3WOCOHfnZatJ9NZucT2o+3XlPYuwqEsthsNQzrp5RGw lUQZA+x9rKmxlIMo4rSbtDQQmJiUjnnsisvnkcVHV3deaxxvCBUTvZt1SNgwYhRgZq vrmElovfH8pmYL8B8rQG04WK1XoP/c0bGPehFRuZS8nJV23IT+XerTKk9z47MdE1rI ebGMSxmN+YkGd/XBDTiCbaZPP3p/Z9Vl/xp8wmgBHKy/9wkibsqPskPnh06F1L/A6N AOlll+fkdsLmGhYM+qGMlbhJIGcbwzMc1syf419fQU7R7lRZVBfWqDpSIQJ+oH7L5y kh4O6yUnTW9BQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006ij-1h; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 12/24] rtc: pm8xxx: use u32 for timestamps Date: Thu, 26 Jan 2023 15:20:45 +0100 Message-Id: <20230126142057.25715-13-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095456035790473?= X-GMAIL-MSGID: =?utf-8?q?1756095456035790473?= The PMIC RTC registers are 32-bit so explicitly use u32 rather than unsigned long for timestamps to reflect the hardware. This will also help avoid unintentional range extensions when adding support for managing an external offset. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 8a94a19e0d14..b1ce246c501a 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -74,7 +74,7 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; u8 value[NUM_8_BIT_RTC_REGS]; bool alarm_enabled; - unsigned long secs; + u32 secs; int rc; if (!rtc_dd->allow_set_time) @@ -83,7 +83,7 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) secs = rtc_tm_to_time64(tm); put_unaligned_le32(secs, value); - dev_dbg(dev, "set time: %ptRd %ptRt (%lu)\n", tm, tm, secs); + dev_dbg(dev, "set time: %ptRd %ptRt (%u)\n", tm, tm, secs); rc = regmap_update_bits_check(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, 0, &alarm_enabled); @@ -131,10 +131,10 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) { int rc; u8 value[NUM_8_BIT_RTC_REGS]; - unsigned long secs; unsigned int reg; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; + u32 secs; rc = regmap_bulk_read(rtc_dd->regmap, regs->read, value, sizeof(value)); if (rc) @@ -158,7 +158,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) secs = get_unaligned_le32(value); rtc_time64_to_tm(secs, tm); - dev_dbg(dev, "read time: %ptRd %ptRt (%lu)\n", tm, tm, secs); + dev_dbg(dev, "read time: %ptRd %ptRt (%u)\n", tm, tm, secs); return 0; } @@ -168,7 +168,7 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) u8 value[NUM_8_BIT_RTC_REGS]; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; - unsigned long secs; + u32 secs; int rc; secs = rtc_tm_to_time64(&alarm->time); @@ -201,9 +201,9 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) int rc; unsigned int ctrl_reg; u8 value[NUM_8_BIT_RTC_REGS]; - unsigned long secs; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; + u32 secs; rc = regmap_bulk_read(rtc_dd->regmap, regs->alarm_rw, value, sizeof(value));