Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bea9db3d authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Alexandre Belloni
Browse files

rtc: isl12057: let the rtc core interpret the partial alarm



The rtc chip doesn't support triggering on month and year. So just don't
assign the respective fields in .read_alarm and let the rtc core
interpret this accordingly.

Signed-off-by: default avatarUwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
parent 56d86a7e
Loading
Loading
Loading
Loading
+1 −32
Original line number Diff line number Diff line
@@ -245,8 +245,7 @@ static int isl12057_rtc_update_alarm(struct device *dev, int enable)
static int isl12057_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
	struct isl12057_rtc_data *data = dev_get_drvdata(dev);
	struct rtc_time rtc_tm, *alarm_tm = &alarm->time;
	unsigned long rtc_secs, alarm_secs;
	struct rtc_time *alarm_tm = &alarm->time;
	u8 regs[ISL12057_A1_SEC_LEN];
	unsigned int ir;
	int ret;
@@ -264,36 +263,6 @@ static int isl12057_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
	alarm_tm->tm_min  = bcd2bin(regs[1] & 0x7f);
	alarm_tm->tm_hour = bcd2bin(regs[2] & 0x3f);
	alarm_tm->tm_mday = bcd2bin(regs[3] & 0x3f);
	alarm_tm->tm_wday = -1;

	/*
	 * The alarm section does not store year/month. We use the ones in rtc
	 * section as a basis and increment month and then year if needed to get
	 * alarm after current time.
	 */
	ret = _isl12057_rtc_read_time(dev, &rtc_tm);
	if (ret)
		goto err_unlock;

	alarm_tm->tm_year = rtc_tm.tm_year;
	alarm_tm->tm_mon = rtc_tm.tm_mon;

	ret = rtc_tm_to_time(&rtc_tm, &rtc_secs);
	if (ret)
		goto err_unlock;

	ret = rtc_tm_to_time(alarm_tm, &alarm_secs);
	if (ret)
		goto err_unlock;

	if (alarm_secs < rtc_secs) {
		if (alarm_tm->tm_mon == 11) {
			alarm_tm->tm_mon = 0;
			alarm_tm->tm_year += 1;
		} else {
			alarm_tm->tm_mon += 1;
		}
	}

	ret = regmap_read(data->regmap, ISL12057_REG_INT, &ir);
	if (ret) {