devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luca Ceresoli <luca@lucaceresoli.net>
To: linux-kernel@vger.kernel.org
Cc: Luca Ceresoli <luca@lucaceresoli.net>,
	Lee Jones <lee.jones@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Wim Van Sebroeck <wim@linux-watchdog.org>,
	Guenter Roeck <linux@roeck-us.net>,
	devicetree@vger.kernel.org, linux-rtc@vger.kernel.org,
	linux-watchdog@vger.kernel.org,
	Chiwoong Byun <woong.byun@samsung.com>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	Randy Dunlap <rdunlap@infradead.org>
Subject: [PATCH v4 3/9] rtc: max77686: remove unused code to read in 12-hour mode
Date: Sat, 20 Nov 2021 16:57:01 +0100	[thread overview]
Message-ID: <20211120155707.4019487-4-luca@lucaceresoli.net> (raw)
In-Reply-To: <20211120155707.4019487-1-luca@lucaceresoli.net>

The MAX77714 RTC chip is explicitly set to 24-hour mode in
max77686_rtc_probe() -> max77686_rtc_init_reg() and never changed back to
12-hour mode. Accordingly info->rtc_24hr_mode is set to 1 in the same place
and never modified later, so it is de facto a constant. Yet there is code
to read 12-hour time, which is unreachable.

Remove the unused variable, the unreachable code to manage 12-hour mode and
the defines that become unused due to the above changes.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

---

Changes in v4: none

Changes in v3: none

Changes in v2:
 - remove the now-unused defines too (Alexandre Belloni)
 - improve the commit message
---
 drivers/rtc/rtc-max77686.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index 7e765207f28e..5c64d08c0732 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -34,9 +34,6 @@
 #define RTC_UDR_MASK			BIT(RTC_UDR_SHIFT)
 #define RTC_RBUDR_SHIFT			4
 #define RTC_RBUDR_MASK			BIT(RTC_RBUDR_SHIFT)
-/* RTC Hour register */
-#define HOUR_PM_SHIFT			6
-#define HOUR_PM_MASK			BIT(HOUR_PM_SHIFT)
 /* RTC Alarm Enable */
 #define ALARM_ENABLE_SHIFT		7
 #define ALARM_ENABLE_MASK		BIT(ALARM_ENABLE_SHIFT)
@@ -99,7 +96,6 @@ struct max77686_rtc_info {
 
 	int rtc_irq;
 	int virq;
-	int rtc_24hr_mode;
 };
 
 enum MAX77686_RTC_OP {
@@ -278,13 +274,7 @@ static void max77686_rtc_data_to_tm(u8 *data, struct rtc_time *tm,
 
 	tm->tm_sec = data[RTC_SEC] & mask;
 	tm->tm_min = data[RTC_MIN] & mask;
-	if (info->rtc_24hr_mode) {
-		tm->tm_hour = data[RTC_HOUR] & 0x1f;
-	} else {
-		tm->tm_hour = data[RTC_HOUR] & 0x0f;
-		if (data[RTC_HOUR] & HOUR_PM_MASK)
-			tm->tm_hour += 12;
-	}
+	tm->tm_hour = data[RTC_HOUR] & 0x1f;
 
 	/* Only a single bit is set in data[], so fls() would be equivalent */
 	tm->tm_wday = ffs(data[RTC_WEEKDAY] & mask) - 1;
@@ -662,8 +652,6 @@ static int max77686_rtc_init_reg(struct max77686_rtc_info *info)
 	data[0] = (1 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT);
 	data[1] = (0 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT);
 
-	info->rtc_24hr_mode = 1;
-
 	ret = regmap_bulk_write(info->rtc_regmap,
 				info->drv_data->map[REG_RTC_CONTROLM],
 				data, ARRAY_SIZE(data));
-- 
2.25.1


  parent reply	other threads:[~2021-11-20 15:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-20 15:56 [PATCH v4 0/9] Add MAX77714 PMIC minimal driver (RTC and watchdog only) Luca Ceresoli
2021-11-20 15:56 ` [PATCH v4 1/9] rtc: max77686: convert comments to kernel-doc format Luca Ceresoli
2021-11-20 15:57 ` [PATCH v4 2/9] rtc: max77686: rename day-of-month defines Luca Ceresoli
2021-11-20 15:57 ` Luca Ceresoli [this message]
2021-11-20 15:57 ` [PATCH v4 4/9] dt-bindings: mfd: add Maxim MAX77714 PMIC Luca Ceresoli
2021-11-21 16:48   ` Krzysztof Kozlowski
2021-11-20 15:57 ` [PATCH v4 5/9] mfd: max77714: Add driver for " Luca Ceresoli
2021-11-21 17:20   ` Krzysztof Kozlowski
2021-11-20 15:57 ` [PATCH v4 6/9] watchdog: Kconfig: fix help text indentation Luca Ceresoli
2021-11-20 15:57 ` [PATCH v4 7/9] watchdog: max77620: add support for the max77714 variant Luca Ceresoli
2021-11-29 15:53   ` Guenter Roeck
2021-11-29 21:24     ` Luca Ceresoli
2021-11-29 21:56       ` Guenter Roeck
2021-11-29 22:14         ` Luca Ceresoli
2021-11-20 15:57 ` [PATCH v4 8/9] watchdog: max77620: add comment to clarify set_timeout procedure Luca Ceresoli
2021-11-29 16:04   ` Guenter Roeck
2021-11-29 16:08     ` Luca Ceresoli
2021-11-29 16:18       ` Guenter Roeck
2021-11-20 15:57 ` [PATCH v4 9/9] rtc: max77686: add MAX77714 support Luca Ceresoli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211120155707.4019487-4-luca@lucaceresoli.net \
    --to=luca@lucaceresoli.net \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=cw00.choi@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski@canonical.com \
    --cc=ldewangan@nvidia.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rdunlap@infradead.org \
    --cc=robh+dt@kernel.org \
    --cc=wim@linux-watchdog.org \
    --cc=woong.byun@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).