From nobody Thu Apr 2 19:54:59 2026 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 0BE64ECAAD8 for ; Wed, 21 Sep 2022 11:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230015AbiIULqs (ORCPT ); Wed, 21 Sep 2022 07:46:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbiIULqg (ORCPT ); Wed, 21 Sep 2022 07:46:36 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 065FA923FE for ; Wed, 21 Sep 2022 04:46:34 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id x29so6680495ljq.2 for ; Wed, 21 Sep 2022 04:46:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=lP4IkEyc6NQgR5/fjvStSKdnasa2RR9aagLo80bh+wQ=; b=MPI/QeQUdshERgTnwLtRSk5quf7LAJzsftQ1mPmIdNedAIcthsmN9PRc5w2X28K42j XGKsYtELeqKNGAZrCb4qsLxkG/i44/u9ZyfllmSj5uW7CFV/MRRrvIbeU9wVJaQi/pYI eKVubX7NU0Vy0rVYbsWOiFEwz2t6GHKvLyJ0c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=lP4IkEyc6NQgR5/fjvStSKdnasa2RR9aagLo80bh+wQ=; b=UB//yryaQL1ZBTL6Fe+nltYBFJ6MyDsPOaLAMi00y+L8Kg99IpXJSNp+Cdo+T10u2Z 9Wqa3chG+HLlb88DZOM6czSD4/xB6XoErAUxK2AL4MMlailI4AoWTSdRho9iIr+61wgT yRjTFL4VSRWFIygL83wUdAPuU/4tuudjDc52zGpuGrrpv28cooXmlTTvwBO640ABC/5A IpqlAS1ur4/kGTOhovRPs/8Shovezx4M79ueltJBlgQkFZ+YiT4MkD1nvwnPUTCUvWgj v7OW1Gtds4SdCSd/Wtiz5nrUkj8y0qouSzP1CIzHiUcZrwI+BZdsn0xm9p260tlVnBMP jJVg== X-Gm-Message-State: ACrzQf0GwAN8LwesPL01to20vzad/Wp3jZOejspGM8otunFSVbwj03pZ vsifMFQOXROED57m5EaYIHanbjOMhaLGqybH X-Google-Smtp-Source: AMsMyM732ZUNotQGUDNxF21frMfuDbk4ozqj74BrluY9t9deQILNLqwUs1Z8aYhVn5H+pf9gPFRwtg== X-Received: by 2002:a2e:a4d3:0:b0:26a:cc7d:d50b with SMTP id p19-20020a2ea4d3000000b0026acc7dd50bmr9336996ljm.77.1663760792217; Wed, 21 Sep 2022 04:46:32 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g4-20020a056512118400b00494618889c0sm405713lfr.42.2022.09.21.04.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 04:46:31 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Rasmus Villemoes , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/9] rtc: isl12022: stop using deprecated devm_rtc_device_register() Date: Wed, 21 Sep 2022 13:46:16 +0200 Message-Id: <20220921114624.3250848-2-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220921114624.3250848-1-linux@rasmusvillemoes.dk> References: <20220830100152.698506-1-linux@rasmusvillemoes.dk> <20220921114624.3250848-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The comments say that devm_rtc_device_register() is deprecated and that one should instead use devm_rtc_allocate_device() and [devm_]rtc_register_device. So do that. Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index 79461ded1a48..2dc19061cf5f 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -246,10 +246,13 @@ static int isl12022_probe(struct i2c_client *client) =20 i2c_set_clientdata(client, isl12022); =20 - isl12022->rtc =3D devm_rtc_device_register(&client->dev, - isl12022_driver.driver.name, - &isl12022_rtc_ops, THIS_MODULE); - return PTR_ERR_OR_ZERO(isl12022->rtc); + isl12022->rtc =3D devm_rtc_allocate_device(&client->dev); + if (IS_ERR(isl12022->rtc)) + return PTR_ERR(isl12022->rtc); + + isl12022->rtc->ops =3D &isl12022_rtc_ops; + + return devm_rtc_register_device(isl12022->rtc); } =20 #ifdef CONFIG_OF --=20 2.37.2 From nobody Thu Apr 2 19:54:59 2026 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 7D7BBECAAD8 for ; Wed, 21 Sep 2022 11:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230079AbiIULq5 (ORCPT ); Wed, 21 Sep 2022 07:46:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbiIULqi (ORCPT ); Wed, 21 Sep 2022 07:46:38 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 530B793208 for ; Wed, 21 Sep 2022 04:46:35 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id b24so6655991ljk.6 for ; Wed, 21 Sep 2022 04:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=mD9phxocXdXyOqXWSnmMDQ/BNPyFycCPprwFbHh4Wp4=; b=KwuINMx+JpKTHKMPBgstiZdj3zgwHsg3WUjCFrqyrMvHRBB/ecHcVilqlgy7wen8VR mUI2ZYRFrFxj/NSdmcljTzt/DEYtuR23a8V3wvjFlkyI5UFkyx+TRbecubLQxaWFg1bn mBZNESVeVaJLBBRnF+LccgjuRtBAmXbPxmY/w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=mD9phxocXdXyOqXWSnmMDQ/BNPyFycCPprwFbHh4Wp4=; b=HQ3W9JJ+XkEoSKoOtXIqCjnKTC54p03Qr2KuRmUM3nccMyN95I2Z4WFl7QzVzvGtO/ p5m6ysB2i0/7iKR/dPOV5mNYciJL7h20RajZinIDj/uh/SnYYCHvcqudqEPu4RqnTA8D 1okqcuAH/1yR898ZxQlE+3IU7yNheIlfV6byugHewfHyj+1nEpZhRkMDwuMBagqWplTI lQjjoDdKZXrpqCtLCOivNWXrDdyjuB9hN86EfguqvWZVBgcXlvSFsoR8akaP6QT8ILQy 4LD8+4h9GH07LqmZjHqw4W7jYEjBSaK0oub911lQyVNy5xksp6SZIYbgEWLbk2JGFC+g 2bbg== X-Gm-Message-State: ACrzQf1FmXNUBYLSgLFy9N/4fxrToDVu1UmvfRGACbQQ5rEIoLYaHD+j 0XU5V7P0SyyO9zBSyGb+jB6jKQ== X-Google-Smtp-Source: AMsMyM78B2H20doAj1jTsRpSbKiXOoKQ+iq2H6mux7sSC15WXXOoAKpz3lUE8Kh4w8Zu0IZUjI0Obg== X-Received: by 2002:a2e:bd0e:0:b0:268:c03b:cf56 with SMTP id n14-20020a2ebd0e000000b00268c03bcf56mr9196763ljq.393.1663760793627; Wed, 21 Sep 2022 04:46:33 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g4-20020a056512118400b00494618889c0sm405713lfr.42.2022.09.21.04.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 04:46:33 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Rasmus Villemoes , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/9] rtc: isl12022: specify range_min and range_max Date: Wed, 21 Sep 2022 13:46:17 +0200 Message-Id: <20220921114624.3250848-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220921114624.3250848-1-linux@rasmusvillemoes.dk> References: <20220830100152.698506-1-linux@rasmusvillemoes.dk> <20220921114624.3250848-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The isl12022 can (only) keep track of times in the range 2000-2099. The data sheet says The calendar registers track date, month, year, and day of the week and are accurate through 2099, with automatic leap year correction. The lower bound of 2000 is obtained by simply observing that its YR register only counts from 00 through 99. Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index 2dc19061cf5f..3bc197f5548f 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -251,6 +251,8 @@ static int isl12022_probe(struct i2c_client *client) return PTR_ERR(isl12022->rtc); =20 isl12022->rtc->ops =3D &isl12022_rtc_ops; + isl12022->rtc->range_min =3D RTC_TIMESTAMP_BEGIN_2000; + isl12022->rtc->range_max =3D RTC_TIMESTAMP_END_2099; =20 return devm_rtc_register_device(isl12022->rtc); } --=20 2.37.2 From nobody Thu Apr 2 19:54:59 2026 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 E6427ECAAD8 for ; Wed, 21 Sep 2022 11:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230177AbiIULrM (ORCPT ); Wed, 21 Sep 2022 07:47:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230042AbiIULqz (ORCPT ); Wed, 21 Sep 2022 07:46:55 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18D3892F6B for ; Wed, 21 Sep 2022 04:46:36 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id b24so6656050ljk.6 for ; Wed, 21 Sep 2022 04:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=EAInJKBXs0Zsg9lyW67Me/bO0k2ovFhxbq0RK9ZHPG4=; b=U7k4PDrgtnD9mkByXaU59dw5vZ+z0ZwXtpyveeaxMMTSRSxNMggNXjcm+8Fo1D46Rr fhL8taymIW+fMj/jSCEK3zZL9JHZgVjt5951E8x5y/7bBUddH4DqpA+KDctfv8WI541i CuIR69fv0bHqjnhvbCU4wvRGM+EILuMLjQM6A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=EAInJKBXs0Zsg9lyW67Me/bO0k2ovFhxbq0RK9ZHPG4=; b=geEOORfYdFpK5egyEadvVZgewlW4aQBP7yE7LLbVJcduuSFE2Xrmej+EfjHtqd2oCF UPKbmpX79v1CJbASfCBVvIsMQ1O3KZrzsvYj/brnVcjwlsV5sIJUrRElPieguWoEf0lf JnWhhjMYO2hlgZGUjs++6N/KsfNXiijBTvM6gQ1CqFEWc4yVBdaMKSGmyIyLF04oLinS ydz/hSQL7xAYH3Tc35BNLgyy3Zx5S3n4Opc1QLMXyXhQPcoVQm7SOb7aevQb75l0SCbn RR7Y4LrOzso8w+YwmcH/ZLOYeK3PCQte4s+ybuo1lsO2kDwecZziiyt/YMZVITui4+61 pong== X-Gm-Message-State: ACrzQf1FhYxznygNWKba3w75gZ7F8rMG0HThYtmgpCnZ88vLvJqdIpyo WBSKbGU+CmyuEyl3KQq4KqFlbjyKuR+r/fPRJuM= X-Google-Smtp-Source: AMsMyM6Gy2DAbTMhuH8lK+D5wVaE/ThDFhiOEHUDKjfxL28TzzZNc0tXIXUK+Qqi7q1y5LWnSEqPSQ== X-Received: by 2002:a2e:944a:0:b0:24f:10bd:b7e8 with SMTP id o10-20020a2e944a000000b0024f10bdb7e8mr9295233ljh.238.1663760794828; Wed, 21 Sep 2022 04:46:34 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g4-20020a056512118400b00494618889c0sm405713lfr.42.2022.09.21.04.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 04:46:34 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Rasmus Villemoes , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/9] rtc: isl12022: drop a dev_info() Date: Wed, 21 Sep 2022 13:46:18 +0200 Message-Id: <20220921114624.3250848-4-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220921114624.3250848-1-linux@rasmusvillemoes.dk> References: <20220830100152.698506-1-linux@rasmusvillemoes.dk> <20220921114624.3250848-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This dev_info() seems to be a debug leftover, and it would only get printed once (or, once per battery change). Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index 3bc197f5548f..2fc9fbefc6fc 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -173,9 +173,6 @@ static int isl12022_rtc_set_time(struct device *dev, st= ruct rtc_time *tm) /* Check if WRTC (write rtc enable) is set factory default is * 0 (not set) */ if (!(buf[0] & ISL12022_INT_WRTC)) { - dev_info(&client->dev, - "init write enable and 24 hour format\n"); - /* Set the write enable bit. */ ret =3D isl12022_write_reg(client, ISL12022_REG_INT, --=20 2.37.2 From nobody Thu Apr 2 19:54:59 2026 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 0FCDAECAAD8 for ; Wed, 21 Sep 2022 11:47:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230101AbiIULrR (ORCPT ); Wed, 21 Sep 2022 07:47:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230054AbiIULqz (ORCPT ); Wed, 21 Sep 2022 07:46:55 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FE7195685 for ; Wed, 21 Sep 2022 04:46:38 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id k10so8749495lfm.4 for ; Wed, 21 Sep 2022 04:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=QO312a6i8/S0aAmV9/OT7vjMYqyfCVVJUdmei7UzN2U=; b=gKaCJJdnysMw/QnYhM4mDpp7ZBiEtYpfJD6Fm72t+uaTa/am/neW+LfJw41250lcFy F9DsW1UIpgYqQy0g2wicbjByKCtZV9h2/aI9r2c6eiidfxbYzujeeJkBwYIyfGq2rc// yjXEuiId3qfhhxJQMe0m/aLjkQ8bAZbiIIGOk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=QO312a6i8/S0aAmV9/OT7vjMYqyfCVVJUdmei7UzN2U=; b=v/JQgDP0EzOAAMxM7jsnj6ZjYDSE+EnZ0k+FynfQbkT8tPzzbNNlqtU769BA870LS4 f1cNO2X6AMY3S6D3v+46+gi2HXpI2u59NSETzoFvgWccGefcZEgruOkSL4JpnMu1mSut zTEyuw4pSTrWsNIVB9iNvSIV8gd18s8FjFSb7cRmtqvMQ0h5ZXCnXS3wIeREmLo2PZ/L ZVOXJrXUrYR3I6XbZYXn6IbTMPxyAqMmH3hHNP0fQrDamlkWE6O9bcwoYpzCtd+uGd39 JRU/vwYPcL5DnafCoEUBSgxfgVUFU4zcNrdKq9mHdO5EShYlmSnnUCHX9yyAHH0DFDP1 Cafg== X-Gm-Message-State: ACrzQf3SKPmRSR780n9gaM6qJtdu5C0U56AvU3DwF/P1OPoQy7jNN0D9 Xqa/zqSqyXAbEnWac62ogZx4nw== X-Google-Smtp-Source: AMsMyM4ZCHEZvmafIThhaRckJxaQl9iR7FM4INrk8+otkBUCCz/oPbnh7t9S0ef70WsekBjEy4UuFw== X-Received: by 2002:a05:6512:128d:b0:49f:4b31:90ed with SMTP id u13-20020a056512128d00b0049f4b3190edmr10352424lfs.118.1663760796100; Wed, 21 Sep 2022 04:46:36 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g4-20020a056512118400b00494618889c0sm405713lfr.42.2022.09.21.04.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 04:46:35 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Rasmus Villemoes , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/9] rtc: isl12022: simplify some expressions Date: Wed, 21 Sep 2022 13:46:19 +0200 Message-Id: <20220921114624.3250848-5-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220921114624.3250848-1-linux@rasmusvillemoes.dk> References: <20220830100152.698506-1-linux@rasmusvillemoes.dk> <20220921114624.3250848-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" These instances of '&client->dev' might as well be spelled 'dev', since 'client' has been computed from 'dev' via 'client =3D to_i2c_client(dev)'. Later patches will get rid of that local variable 'client', so remove these unnecessary references so those later patches become easier to read. Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index 2fc9fbefc6fc..7efe23fa74df 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -112,13 +112,13 @@ static int isl12022_rtc_read_time(struct device *dev,= struct rtc_time *tm) return ret; =20 if (buf[ISL12022_REG_SR] & (ISL12022_SR_LBAT85 | ISL12022_SR_LBAT75)) { - dev_warn(&client->dev, + dev_warn(dev, "voltage dropped below %u%%, " "date and time is not reliable.\n", buf[ISL12022_REG_SR] & ISL12022_SR_LBAT85 ? 85 : 75); } =20 - dev_dbg(&client->dev, + dev_dbg(dev, "%s: raw data is sec=3D%02x, min=3D%02x, hr=3D%02x, " "mday=3D%02x, mon=3D%02x, year=3D%02x, wday=3D%02x, " "sr=3D%02x, int=3D%02x", @@ -141,7 +141,7 @@ static int isl12022_rtc_read_time(struct device *dev, s= truct rtc_time *tm) tm->tm_mon =3D bcd2bin(buf[ISL12022_REG_MO] & 0x1F) - 1; tm->tm_year =3D bcd2bin(buf[ISL12022_REG_YR]) + 100; =20 - dev_dbg(&client->dev, "%s: secs=3D%d, mins=3D%d, hours=3D%d, " + dev_dbg(dev, "%s: secs=3D%d, mins=3D%d, hours=3D%d, " "mday=3D%d, mon=3D%d, year=3D%d, wday=3D%d\n", __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, @@ -158,7 +158,7 @@ static int isl12022_rtc_set_time(struct device *dev, st= ruct rtc_time *tm) int ret; uint8_t buf[ISL12022_REG_DW + 1]; =20 - dev_dbg(&client->dev, "%s: secs=3D%d, mins=3D%d, hours=3D%d, " + dev_dbg(dev, "%s: secs=3D%d, mins=3D%d, hours=3D%d, " "mday=3D%d, mon=3D%d, year=3D%d, wday=3D%d\n", __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, --=20 2.37.2 From nobody Thu Apr 2 19:54:59 2026 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 965FCC6FA8E for ; Wed, 21 Sep 2022 11:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230267AbiIULrV (ORCPT ); Wed, 21 Sep 2022 07:47:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229945AbiIULqz (ORCPT ); Wed, 21 Sep 2022 07:46:55 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 522F595690 for ; Wed, 21 Sep 2022 04:46:39 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id j24so6154037lja.4 for ; Wed, 21 Sep 2022 04:46:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=KBC4n7oWzkTEp7l49syMVK2MtMfoljE2pLWVkSUsJt0=; b=cLI04QQDrnEii5mcgBRkJD92HGxTm/c57U5vILXvr/Ay3GzZv5d3PH5AQgA5g7MkjX rGdtSXZz+j14nbM1bNwyfi/JwR98MQ984Ul/eDrnPrhDSd3I+S4ugUUqc2Uwi5IJEP8O +EAAyLhe/V3O7hMwtruzO3dGKpHYkUmysY5iM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KBC4n7oWzkTEp7l49syMVK2MtMfoljE2pLWVkSUsJt0=; b=TI6qAJigP/mTOouAXkgYYpBXJYjyiM5f7bbFdoShUWTe3r1iGGUrgw6aaPUZzgtKcl OL1egExUjS9TbFwUN1aUYzu04+GS0KC1r6sJqCJcO9fTda4cCJt2A0GBZprbw8e3NrXL jFJoMHoI9E9V9iqwGdhc3TUNecuvluOa0xbExL+8goXIh5ovHypVcWJdafIFr5TZZ4gW QAyulQ12OpzMQCjiZEEj8F46eFu0LtIKZ7fIWHwV++9ztbHMygV11jzFfdV6VdorviBO gbL7RtzwgEX9+oC8ilCo3ZrdTDXmTmH8GZPlbRU64feN11d84OZTfq3ztpOHNLTXIA7b VNHw== X-Gm-Message-State: ACrzQf2SWs6Z9sE6CmTUZLFaKmFDaVqqaTScT5aF9zXfHumsCqxBayUR L/uPiP9SBM+P/kQj4ei08Xo3/SNlBpnIrW3Q X-Google-Smtp-Source: AMsMyM7zz6magFFPeGZp4KTAakylZUbXWhn84Q39/+/bKO6XAJqwjbfS0xoLJG9fwNE30HDFlpBKww== X-Received: by 2002:a2e:8349:0:b0:26c:4311:9b84 with SMTP id l9-20020a2e8349000000b0026c43119b84mr7168500ljh.152.1663760797228; Wed, 21 Sep 2022 04:46:37 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g4-20020a056512118400b00494618889c0sm405713lfr.42.2022.09.21.04.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 04:46:36 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Rasmus Villemoes , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/9] rtc: isl12022: use %ptR Date: Wed, 21 Sep 2022 13:46:20 +0200 Message-Id: <20220921114624.3250848-6-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220921114624.3250848-1-linux@rasmusvillemoes.dk> References: <20220830100152.698506-1-linux@rasmusvillemoes.dk> <20220921114624.3250848-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Simplify the code and make the output format consistent with other RTC drivers by standardizing on using the %ptR printf extension. Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index 7efe23fa74df..d396d6076db5 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -141,11 +141,7 @@ static int isl12022_rtc_read_time(struct device *dev, = struct rtc_time *tm) tm->tm_mon =3D bcd2bin(buf[ISL12022_REG_MO] & 0x1F) - 1; tm->tm_year =3D bcd2bin(buf[ISL12022_REG_YR]) + 100; =20 - dev_dbg(dev, "%s: secs=3D%d, mins=3D%d, hours=3D%d, " - "mday=3D%d, mon=3D%d, year=3D%d, wday=3D%d\n", - __func__, - tm->tm_sec, tm->tm_min, tm->tm_hour, - tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); + dev_dbg(dev, "%s: %ptR\n", __func__, tm); =20 return 0; } @@ -158,11 +154,7 @@ static int isl12022_rtc_set_time(struct device *dev, s= truct rtc_time *tm) int ret; uint8_t buf[ISL12022_REG_DW + 1]; =20 - dev_dbg(dev, "%s: secs=3D%d, mins=3D%d, hours=3D%d, " - "mday=3D%d, mon=3D%d, year=3D%d, wday=3D%d\n", - __func__, - tm->tm_sec, tm->tm_min, tm->tm_hour, - tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); + dev_dbg(dev, "%s: %ptR\n", __func__, tm); =20 if (!isl12022->write_enabled) { =20 --=20 2.37.2 From nobody Thu Apr 2 19:54:59 2026 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 C9B38C32771 for ; Wed, 21 Sep 2022 11:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230133AbiIULr2 (ORCPT ); Wed, 21 Sep 2022 07:47:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbiIULq6 (ORCPT ); Wed, 21 Sep 2022 07:46:58 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89493956A0 for ; Wed, 21 Sep 2022 04:46:40 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id o2so8718435lfc.10 for ; Wed, 21 Sep 2022 04:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Z9Ue5DS5Cga8o/w2e+6VqkFN/cO/eMoPZweW6fx+Axk=; b=evlmInS7BghmrM8Z0zAIKp53bvbv2IpVwbmqJkDXMdyLGUoMR/TI3ZH3McmfIjqUaz 50+7sDhtQFGJhoRxO2h2HH7jkaWu3+nf6lXPQhHrTPCh9aaRSG6Pbl61EoUmBanMPnx4 6J5fZqeYmXz8I7eVoOaS62kfUstAuBDIFmzbk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Z9Ue5DS5Cga8o/w2e+6VqkFN/cO/eMoPZweW6fx+Axk=; b=chJeUWrnlZsnY9O4vl37lWmIaVHWpWokM2BqdH3xNeWYq4CymAn9KApOzfHGun+NAa qClUjfjiqBtCTT7SDuG0g4UvSqq5/9bx+jpVAWirixvi7sVnU3b4aa3fDMNnUNPr6bCk 7OzQHwO/FgQVlu/3LKHLua5/xltlVfh2t9JeOTROi+5Ar4kM7sXSBIgoDtGtzI+FNeWx c40tG7yQM9Dtz+BEp6Tzsw98Ybg7BRcZOQSmR+hxJ8zWj1QKm6QVWDmR8HY/g+ArCswW rlK4JksY8RXtSr1vlPOOGO9EaWYcEUscqPZpW2Q03WLhkKm91ZjsgKi5fR5zdfP3Q2iC H01g== X-Gm-Message-State: ACrzQf3FCYXPiwhDXyu6KCR/7XE9AB9x9ZNiRJneWH3e31NuVG0bj6s7 ce9GqTtWWXOMktpWNaIiVeFpYA== X-Google-Smtp-Source: AMsMyM5WhXsNX6XVZJGeBmRacLDjdOlwrLy/r5SegrTbMy4w/i5inYO8mQreICTZZ/Lr6BpLgc0xww== X-Received: by 2002:ac2:454a:0:b0:49c:6212:c44d with SMTP id j10-20020ac2454a000000b0049c6212c44dmr10742580lfm.430.1663760798387; Wed, 21 Sep 2022 04:46:38 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g4-20020a056512118400b00494618889c0sm405713lfr.42.2022.09.21.04.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 04:46:38 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Rasmus Villemoes , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/9] rtc: isl12022: use dev_set_drvdata() instead of i2c_set_clientdata() Date: Wed, 21 Sep 2022 13:46:21 +0200 Message-Id: <20220921114624.3250848-7-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220921114624.3250848-1-linux@rasmusvillemoes.dk> References: <20220830100152.698506-1-linux@rasmusvillemoes.dk> <20220921114624.3250848-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As another preparation for removing direct references to the i2c_client in the helper functions, stash a pointer to the private data via dev_set_drvdata() instead of i2c_set_clientdata(). Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index d396d6076db5..df6d91f4e8f3 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -149,7 +149,7 @@ static int isl12022_rtc_read_time(struct device *dev, s= truct rtc_time *tm) static int isl12022_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct i2c_client *client =3D to_i2c_client(dev); - struct isl12022 *isl12022 =3D i2c_get_clientdata(client); + struct isl12022 *isl12022 =3D dev_get_drvdata(dev); size_t i; int ret; uint8_t buf[ISL12022_REG_DW + 1]; @@ -232,8 +232,7 @@ static int isl12022_probe(struct i2c_client *client) GFP_KERNEL); if (!isl12022) return -ENOMEM; - - i2c_set_clientdata(client, isl12022); + dev_set_drvdata(&client->dev, isl12022); =20 isl12022->rtc =3D devm_rtc_allocate_device(&client->dev); if (IS_ERR(isl12022->rtc)) --=20 2.37.2 From nobody Thu Apr 2 19:54:59 2026 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 2FBA5ECAAD8 for ; Wed, 21 Sep 2022 11:47:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229691AbiIULrZ (ORCPT ); Wed, 21 Sep 2022 07:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbiIULrA (ORCPT ); Wed, 21 Sep 2022 07:47:00 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D2CC90C5F for ; Wed, 21 Sep 2022 04:46:41 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id p5so6609599ljc.13 for ; Wed, 21 Sep 2022 04:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=m9+Zmy++ta7sMSatXKhKoM2rtE1PAA0b2u/bqTy/9Yo=; b=hY7GTvbSgNOU09X0DCba8ho6mZShPG9k3hNdmr2t1K3aOuagsPyICR6YM/Guhur5Zi Hxxspf+em6oL8GsG0v8hQh0lLBfv0/45h5GwU6B/38kmuhk0d4c7k0noV/IiWRI+vlBK 1tVcjPW7Y1k575XuJStd/o/SranxSgOj3LT10= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=m9+Zmy++ta7sMSatXKhKoM2rtE1PAA0b2u/bqTy/9Yo=; b=z6ogDYOssOeRjdfsitUDDiwZFXpY+NFDKrUjSaCMHnkMH9uB1dy4YxcGhTJ4WyyDnv PKa2qaG95QDpeLkBc02KaQ5VnUZGuzGrxr85pJzy7VbIFgBOWsJfosJUPn+EpEYEKOqc bFf4Ze66t7Xb+A88OkhG+e04axdjLxQ4S9HX6ynmxugprbpqDiVKjAWfKmetrRjGuH4G FLCVWMn+FIiijLIlqMoip9qu6kDwcA7avQpgPyPbyHKE1B+Dg6PVyE8P5d8X9fCXy+Xu w0jHlOkkMtT45o/RuylrSp2XTCLmuAPXgakiunn0E9qAzFOavcmXibMmoSrxl0BepxpJ mn6A== X-Gm-Message-State: ACrzQf1a5kKcJPoaN3k1Ce4DM7wf0yb+nf0pHz2L1ulYv0xJLkzHrgd8 XXZJTtBBsr5TU5459lPYkXA0bw== X-Google-Smtp-Source: AMsMyM7qN5dEJxOUF9bSZZtyudDeKm4BTi/9npAp2ELjfLp7ivsmOvQQT71JKcXCUwyUhWVDNnU81A== X-Received: by 2002:a2e:90da:0:b0:26c:8dc:3c52 with SMTP id o26-20020a2e90da000000b0026c08dc3c52mr8886029ljg.474.1663760799695; Wed, 21 Sep 2022 04:46:39 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g4-20020a056512118400b00494618889c0sm405713lfr.42.2022.09.21.04.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 04:46:39 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Rasmus Villemoes , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/9] rtc: isl12022: drop redundant write to HR register Date: Wed, 21 Sep 2022 13:46:22 +0200 Message-Id: <20220921114624.3250848-8-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220921114624.3250848-1-linux@rasmusvillemoes.dk> References: <20220830100152.698506-1-linux@rasmusvillemoes.dk> <20220921114624.3250848-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There's nothing in the data sheet that says writing to one of the time keeping registers is necessary to start the RTC. It does so at the stop condition of the i2c transfer setting the WRTC bit: Upon initialization or power-up, the WRTC must be set to "1" to enable the RTC. Upon the completion of a valid write (STOP), the RTC starts counting. Moreover, even if such a write to one of the timekeeping registers was necessary, that's exactly what we do anyway just below when we actually write the given struct rtc_time to the device. Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index df6d91f4e8f3..6fb13a5d17f1 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -171,20 +171,6 @@ static int isl12022_rtc_set_time(struct device *dev, s= truct rtc_time *tm) buf[0] | ISL12022_INT_WRTC); if (ret) return ret; - - /* Write to any RTC register to start RTC, we use the - * HR register, setting the MIL bit to use the 24 hour - * format. */ - ret =3D isl12022_read_regs(client, ISL12022_REG_HR, - buf, 1); - if (ret) - return ret; - - ret =3D isl12022_write_reg(client, - ISL12022_REG_HR, - buf[0] | ISL12022_HR_MIL); - if (ret) - return ret; } =20 isl12022->write_enabled =3D true; --=20 2.37.2 From nobody Thu Apr 2 19:54:59 2026 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 4CE0DECAAD8 for ; Wed, 21 Sep 2022 11:47:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230322AbiIULrb (ORCPT ); Wed, 21 Sep 2022 07:47:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbiIULrD (ORCPT ); Wed, 21 Sep 2022 07:47:03 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1A0890803 for ; Wed, 21 Sep 2022 04:46:41 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id u18so8731941lfo.8 for ; Wed, 21 Sep 2022 04:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=LLcoUfGxhi8reQQCpbbwos0jhsx1cQA+/9CD5zQKs0M=; b=ZvYzaoWIkLHxaHgb1owNhrW5mvjGeCP30MWPHhKZencsYNmoiCgM/qIN1b3Sdnav/8 /y4mBwi/DT7YQX2WTYe370rl7zqprzYbjwebu7S4GjV2CkSMoFBlXKLm5Mu0WCbBJBVH ZRoRjLqlQrkKzsw4ErQmUUb6WAEuV7msR5NWk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=LLcoUfGxhi8reQQCpbbwos0jhsx1cQA+/9CD5zQKs0M=; b=jz/ENVa+X/N8tccz8l7EvpupsYKmu5ZLK8ZgDinVeklfWbiHYTxvHef75DTPqaT0tg RVuBOwGhjIMAB4n7Dsi3uZdTUhSakiI+7viZqBCPrdcdYUPQ6QsAHsTnxhWqXfzFz7Eh 41+gbqEm30tJ3QD7GC67q/3H+Kt1MUDvi1lC12wW9SvH7pFTFSoycyDAXip+HY68ThOg UmD+BxSFAQcsZw4b2MUjLcCEEcS9hNRRQKVkPfYJnpq9T4FaVhF7bSYYBX1GbV20VxgZ fxGzaZLToeNHdjEy3aawp1KwPR5VOQ/E1As+e9qwM3/sY4HrkFBEeOaBhLZFdMhBCZiF k7Gw== X-Gm-Message-State: ACrzQf1qEadajUF3QQTpmEDwKHa4kdkQxl0gzQHwMY4emBn/CmYjKFdo E0bgW4HvDl35Dbk7JW97gN5QCJuEUT72RM7wVzI= X-Google-Smtp-Source: AMsMyM42zVJ/5O/dK+uV1a8A97tuD+lBAW/Jsfjfyc7+cyT/DkNvqZ89pb+KQYVTWfx54lzf7He9+Q== X-Received: by 2002:a05:6512:3d2a:b0:49a:92d:cddd with SMTP id d42-20020a0565123d2a00b0049a092dcdddmr10220106lfv.590.1663760801021; Wed, 21 Sep 2022 04:46:41 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g4-20020a056512118400b00494618889c0sm405713lfr.42.2022.09.21.04.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 04:46:40 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Rasmus Villemoes , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8/9] rtc: isl12022: switch to using regmap API Date: Wed, 21 Sep 2022 13:46:23 +0200 Message-Id: <20220921114624.3250848-9-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220921114624.3250848-1-linux@rasmusvillemoes.dk> References: <20220830100152.698506-1-linux@rasmusvillemoes.dk> <20220921114624.3250848-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The regmap abstraction allows us to avoid the private i2c transfer helpers, and also offers some nice utility functions such as the regmap_update_bits family. While at it, simplify the code even more by not keeping track of ->write_enabled: rtc_set_time is not a hot path, so one extra i2c read doesn't hurt (regmap_update_bits elides the write when the bits are already as desired). Signed-off-by: Rasmus Villemoes --- drivers/rtc/Kconfig | 1 + drivers/rtc/rtc-isl12022.c | 110 +++++++++---------------------------- 2 files changed, 26 insertions(+), 85 deletions(-) diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index b8de25118ad0..bb63edb507da 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -423,6 +423,7 @@ config RTC_DRV_ISL1208 =20 config RTC_DRV_ISL12022 tristate "Intersil ISL12022" + select REGMAP_I2C help If you say yes here you get support for the Intersil ISL12022 RTC chip. diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index 6fb13a5d17f1..ca677c4265e6 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 /* ISL register offsets */ #define ISL12022_REG_SC 0x00 @@ -42,72 +43,21 @@ static struct i2c_driver isl12022_driver; =20 struct isl12022 { struct rtc_device *rtc; - - bool write_enabled; /* true if write enable is set */ + struct regmap *regmap; }; =20 - -static int isl12022_read_regs(struct i2c_client *client, uint8_t reg, - uint8_t *data, size_t n) -{ - struct i2c_msg msgs[] =3D { - { - .addr =3D client->addr, - .flags =3D 0, - .len =3D 1, - .buf =3D data - }, /* setup read ptr */ - { - .addr =3D client->addr, - .flags =3D I2C_M_RD, - .len =3D n, - .buf =3D data - } - }; - - int ret; - - data[0] =3D reg; - ret =3D i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); - if (ret !=3D ARRAY_SIZE(msgs)) { - dev_err(&client->dev, "%s: read error, ret=3D%d\n", - __func__, ret); - return -EIO; - } - - return 0; -} - - -static int isl12022_write_reg(struct i2c_client *client, - uint8_t reg, uint8_t val) -{ - uint8_t data[2] =3D { reg, val }; - int err; - - err =3D i2c_master_send(client, data, sizeof(data)); - if (err !=3D sizeof(data)) { - dev_err(&client->dev, - "%s: err=3D%d addr=3D%02x, data=3D%02x\n", - __func__, err, data[0], data[1]); - return -EIO; - } - - return 0; -} - - /* * In the routines that deal directly with the isl12022 hardware, we use * rtc_time -- month 0-11, hour 0-23, yr =3D calendar year-epoch. */ static int isl12022_rtc_read_time(struct device *dev, struct rtc_time *tm) { - struct i2c_client *client =3D to_i2c_client(dev); + struct isl12022 *isl12022 =3D dev_get_drvdata(dev); + struct regmap *regmap =3D isl12022->regmap; uint8_t buf[ISL12022_REG_INT + 1]; int ret; =20 - ret =3D isl12022_read_regs(client, ISL12022_REG_SC, buf, sizeof(buf)); + ret =3D regmap_bulk_read(regmap, ISL12022_REG_SC, buf, sizeof(buf)); if (ret) return ret; =20 @@ -148,33 +98,18 @@ static int isl12022_rtc_read_time(struct device *dev, = struct rtc_time *tm) =20 static int isl12022_rtc_set_time(struct device *dev, struct rtc_time *tm) { - struct i2c_client *client =3D to_i2c_client(dev); struct isl12022 *isl12022 =3D dev_get_drvdata(dev); - size_t i; + struct regmap *regmap =3D isl12022->regmap; int ret; uint8_t buf[ISL12022_REG_DW + 1]; =20 dev_dbg(dev, "%s: %ptR\n", __func__, tm); =20 - if (!isl12022->write_enabled) { - - ret =3D isl12022_read_regs(client, ISL12022_REG_INT, buf, 1); - if (ret) - return ret; - - /* Check if WRTC (write rtc enable) is set factory default is - * 0 (not set) */ - if (!(buf[0] & ISL12022_INT_WRTC)) { - /* Set the write enable bit. */ - ret =3D isl12022_write_reg(client, - ISL12022_REG_INT, - buf[0] | ISL12022_INT_WRTC); - if (ret) - return ret; - } - - isl12022->write_enabled =3D true; - } + /* Ensure the write enable bit is set. */ + ret =3D regmap_update_bits(regmap, ISL12022_REG_INT, + ISL12022_INT_WRTC, ISL12022_INT_WRTC); + if (ret) + return ret; =20 /* hours, minutes and seconds */ buf[ISL12022_REG_SC] =3D bin2bcd(tm->tm_sec); @@ -191,15 +126,8 @@ static int isl12022_rtc_set_time(struct device *dev, s= truct rtc_time *tm) =20 buf[ISL12022_REG_DW] =3D tm->tm_wday & 0x07; =20 - /* write register's data */ - for (i =3D 0; i < ARRAY_SIZE(buf); i++) { - ret =3D isl12022_write_reg(client, ISL12022_REG_SC + i, - buf[ISL12022_REG_SC + i]); - if (ret) - return -EIO; - } - - return 0; + return regmap_bulk_write(isl12022->regmap, ISL12022_REG_SC, + buf, sizeof(buf)); } =20 static const struct rtc_class_ops isl12022_rtc_ops =3D { @@ -207,6 +135,12 @@ static const struct rtc_class_ops isl12022_rtc_ops =3D= { .set_time =3D isl12022_rtc_set_time, }; =20 +static const struct regmap_config regmap_config =3D { + .reg_bits =3D 8, + .val_bits =3D 8, + .use_single_write =3D true, +}; + static int isl12022_probe(struct i2c_client *client) { struct isl12022 *isl12022; @@ -220,6 +154,12 @@ static int isl12022_probe(struct i2c_client *client) return -ENOMEM; dev_set_drvdata(&client->dev, isl12022); =20 + isl12022->regmap =3D devm_regmap_init_i2c(client, ®map_config); + if (IS_ERR(isl12022->regmap)) { + dev_err(&client->dev, "regmap allocation failed\n"); + return PTR_ERR(isl12022->regmap); + } + isl12022->rtc =3D devm_rtc_allocate_device(&client->dev); if (IS_ERR(isl12022->rtc)) return PTR_ERR(isl12022->rtc); --=20 2.37.2 From nobody Thu Apr 2 19:54:59 2026 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 4A4FCC6FA8E for ; Wed, 21 Sep 2022 11:47:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbiIULre (ORCPT ); Wed, 21 Sep 2022 07:47:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbiIULrJ (ORCPT ); Wed, 21 Sep 2022 07:47:09 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 044B495AD1 for ; Wed, 21 Sep 2022 04:46:44 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id i26so8695560lfp.11 for ; Wed, 21 Sep 2022 04:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=4RHBks34HLeSc7CjE4OmjukDfKagdpXGucbBixwNsEk=; b=jQeVjUORFQkiQ1g9rO+9flDQjaKQBkQ58OKNbg2hDBLmKKGKgJ4L5yez2cceTckKYe YHdskTdMi6WVQRp0B7UCGXXqOrFIisNJGrJWAMAg4h8yXHZvzh66qffsY6IPfeLqxo/C UnPSIarg7PpHukqYs4xn0IMMzp5Z5BxP3t/nQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=4RHBks34HLeSc7CjE4OmjukDfKagdpXGucbBixwNsEk=; b=ZzEaXxnUc1qRMnmbaaWudCHxo2kg6Tmn0Y1tgbf3Jas4QnwPZSPjoW4I077EZrwAr/ wM+b8OGaTOQ0SlZLTzopjtIIsUTfMiG3ui/yKvIGODnRGjJlHz82bZvtACiS/y35rNZF NqkPpBZwVz4tnjzEQhdfDcYiXvwfDwjtqJFyKQQQ5E1mbCq9sa4gK2/rfbx3gg0D9BPp BneMDL0KohZpT7GuqkneS/42cRzIgwHpET6xIRWDqTxIQONCzOwyW/2Uu9v3IK9D/KQB nACQS04q5Ks9rTj3cu8LBUfHp490IycmE17xHlAKbmGAFfjEo2bQ9IpqHr0qNpQTNYPh 2SGw== X-Gm-Message-State: ACrzQf3txpAMKnAwxL2L7si4pP0Tl9psZWRT3LquoMDAsYM8OMdw/Ga/ lFZ0p7mEdCIcM1jG4gELK+ODBQKr+p1iZj+cWSo= X-Google-Smtp-Source: AMsMyM52W5QkNicQxybqR3JQJBjbfbZjuNryoCgR13QN8MU4YXQYZfAW7ByhW4Z9KqzDiEXFoFVX6w== X-Received: by 2002:a19:f60f:0:b0:49f:4ec7:21ed with SMTP id x15-20020a19f60f000000b0049f4ec721edmr10608737lfe.77.1663760802540; Wed, 21 Sep 2022 04:46:42 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g4-20020a056512118400b00494618889c0sm405713lfr.42.2022.09.21.04.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 04:46:41 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni , Jean Delvare , Guenter Roeck Cc: Rasmus Villemoes , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org Subject: [PATCH v2 9/9] rtc: isl12022: add support for temperature sensor Date: Wed, 21 Sep 2022 13:46:24 +0200 Message-Id: <20220921114624.3250848-10-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220921114624.3250848-1-linux@rasmusvillemoes.dk> References: <20220830100152.698506-1-linux@rasmusvillemoes.dk> <20220921114624.3250848-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 104 +++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index ca677c4265e6..f3efe61c81e5 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -17,6 +17,7 @@ #include #include #include +#include =20 /* ISL register offsets */ #define ISL12022_REG_SC 0x00 @@ -30,6 +31,9 @@ #define ISL12022_REG_SR 0x07 #define ISL12022_REG_INT 0x08 =20 +#define ISL12022_REG_BETA 0x0d +#define ISL12022_REG_TEMP_L 0x28 + /* ISL register bits */ #define ISL12022_HR_MIL (1 << 7) /* military or 24 hour time */ =20 @@ -38,6 +42,7 @@ =20 #define ISL12022_INT_WRTC (1 << 6) =20 +#define ISL12022_BETA_TSE (1 << 7) =20 static struct i2c_driver isl12022_driver; =20 @@ -46,6 +51,103 @@ struct isl12022 { struct regmap *regmap; }; =20 +static umode_t isl12022_hwmon_is_visible(const void *data, + enum hwmon_sensor_types type, + u32 attr, int channel) +{ + if (type =3D=3D hwmon_chip && attr =3D=3D hwmon_chip_update_interval) + return 0444; + + if (type =3D=3D hwmon_temp && attr =3D=3D hwmon_temp_input) + return 0444; + + return 0; +} + +/* + * A user-initiated temperature conversion is not started by this function, + * so the temperature is updated once every ~60 seconds. + */ +static int isl12022_hwmon_read_temp(struct device *dev, long *mC) +{ + struct isl12022 *isl12022 =3D dev_get_drvdata(dev); + struct regmap *regmap =3D isl12022->regmap; + u8 temp_buf[2]; + int temp, ret; + + ret =3D regmap_bulk_read(regmap, ISL12022_REG_TEMP_L, + temp_buf, sizeof(temp_buf)); + if (ret) + return ret; + /* + * Temperature is represented as a 10-bit number, unit half-Kelvins. + */ + temp =3D (temp_buf[1] << 8) | temp_buf[0]; + temp *=3D 500; + temp -=3D 273000; + + *mC =3D temp; + + return 0; +} + +static int isl12022_hwmon_read(struct device *dev, + enum hwmon_sensor_types type, + u32 attr, int channel, long *val) +{ + if (type =3D=3D hwmon_chip && attr =3D=3D hwmon_chip_update_interval) { + *val =3D 60000; + return 0; + } + + if (type =3D=3D hwmon_temp && attr =3D=3D hwmon_temp_input) { + return isl12022_hwmon_read_temp(dev, val); + } + + return -EOPNOTSUPP; +} + +static const struct hwmon_channel_info *isl12022_hwmon_info[] =3D { + HWMON_CHANNEL_INFO(chip, HWMON_C_UPDATE_INTERVAL), + HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), + NULL +}; + +static const struct hwmon_ops isl12022_hwmon_ops =3D { + .is_visible =3D isl12022_hwmon_is_visible, + .read =3D isl12022_hwmon_read, +}; + +static const struct hwmon_chip_info isl12022_hwmon_chip_info =3D { + .ops =3D &isl12022_hwmon_ops, + .info =3D isl12022_hwmon_info, +}; + +static void isl12022_hwmon_register(struct device *dev) +{ + struct isl12022 *isl12022; + struct device *hwmon; + int ret; + + if (!IS_REACHABLE(CONFIG_HWMON)) + return; + + isl12022 =3D dev_get_drvdata(dev); + + ret =3D regmap_update_bits(isl12022->regmap, ISL12022_REG_BETA, + ISL12022_BETA_TSE, ISL12022_BETA_TSE); + if (ret) { + dev_warn(dev, "unable to enable temperature sensor\n"); + return; + } + + hwmon =3D devm_hwmon_device_register_with_info(dev, "isl12022", isl12022, + &isl12022_hwmon_chip_info, + NULL); + if (IS_ERR(hwmon)) + dev_warn(dev, "unable to register hwmon device: %pe\n", hwmon); +} + /* * In the routines that deal directly with the isl12022 hardware, we use * rtc_time -- month 0-11, hour 0-23, yr =3D calendar year-epoch. @@ -160,6 +262,8 @@ static int isl12022_probe(struct i2c_client *client) return PTR_ERR(isl12022->regmap); } =20 + isl12022_hwmon_register(&client->dev); + isl12022->rtc =3D devm_rtc_allocate_device(&client->dev); if (IS_ERR(isl12022->rtc)) return PTR_ERR(isl12022->rtc); --=20 2.37.2