rtc: simplify implementations of read_alarm
authorUwe Kleine-König <uwe@kleine-koenig.org>
Tue, 28 Jun 2016 08:43:45 +0000 (10:43 +0200)
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>
Sat, 9 Jul 2016 08:24:45 +0000 (10:24 +0200)
Since commit d68778b80dd7 ("rtc: initialize output parameter for read
alarm to "uninitialized"") there is no need to explicitly set
unsupported members to -1. So drop the respective assignments from
drivers.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
16 files changed:
drivers/rtc/rtc-cmos.c
drivers/rtc/rtc-ds1305.c
drivers/rtc/rtc-ds1307.c
drivers/rtc/rtc-ds1343.c
drivers/rtc/rtc-ds1685.c
drivers/rtc/rtc-ds3232.c
drivers/rtc/rtc-hym8563.c
drivers/rtc/rtc-m41t80.c
drivers/rtc/rtc-mrst.c
drivers/rtc/rtc-pcf8563.c
drivers/rtc/rtc-rs5c372.c
drivers/rtc/rtc-rv8803.c
drivers/rtc/rtc-rx8010.c
drivers/rtc/rtc-rx8025.c
drivers/rtc/rtc-s3c.c
drivers/rtc/rtc-tegra.c

index f9fdb6fc641cb12772cbcc5fba3265ff3b7401e2..43745cac0141a4445dda3abe6a31d8ca172355b0 100644 (file)
@@ -220,8 +220,6 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t)
         * Some also support day and month, for alarms up to a year in
         * the future.
         */
-       t->time.tm_mday = -1;
-       t->time.tm_mon = -1;
 
        spin_lock_irq(&rtc_lock);
        t->time.tm_sec = CMOS_READ(RTC_SECONDS_ALARM);
@@ -272,7 +270,6 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t)
                        }
                }
        }
-       t->time.tm_year = -1;
 
        t->enabled = !!(rtc_control & RTC_AIE);
        t->pending = 0;
index 8e41c4613e5135cbd4db573586f85ef60678447e..72b22935eb62a0e9d71da4552ab64d0ace6ccd39 100644 (file)
@@ -313,13 +313,6 @@ static int ds1305_get_alarm(struct device *dev, struct rtc_wkalrm *alm)
        alm->time.tm_sec = bcd2bin(buf[DS1305_SEC]);
        alm->time.tm_min = bcd2bin(buf[DS1305_MIN]);
        alm->time.tm_hour = bcd2hour(buf[DS1305_HOUR]);
-       alm->time.tm_mday = -1;
-       alm->time.tm_mon = -1;
-       alm->time.tm_year = -1;
-       /* next three fields are unused by Linux */
-       alm->time.tm_wday = -1;
-       alm->time.tm_mday = -1;
-       alm->time.tm_isdst = -1;
 
        return 0;
 }
index f25f7dce6e1fb29c51c0e0be734a6337244b8fc1..8e1c5cb6ece6f60619e5cafcea4271e056d96778 100644 (file)
@@ -482,11 +482,6 @@ static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t)
        t->time.tm_min = bcd2bin(ds1307->regs[1] & 0x7f);
        t->time.tm_hour = bcd2bin(ds1307->regs[2] & 0x3f);
        t->time.tm_mday = bcd2bin(ds1307->regs[3] & 0x3f);
-       t->time.tm_mon = -1;
-       t->time.tm_year = -1;
-       t->time.tm_wday = -1;
-       t->time.tm_yday = -1;
-       t->time.tm_isdst = -1;
 
        /* ... and status */
        t->enabled = !!(ds1307->regs[7] & DS1337_BIT_A1IE);
index 23fa9f0cb5e3113f398a468d7c3a941f0bf45a98..895fbeeb47fe1bc78fc79350e6e58b23c50ab64e 100644 (file)
@@ -504,12 +504,6 @@ static int ds1343_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
        alarm->time.tm_hour = priv->alarm_hour < 0 ? 0 : priv->alarm_hour;
        alarm->time.tm_mday = priv->alarm_mday < 0 ? 0 : priv->alarm_mday;
 
-       alarm->time.tm_mon = -1;
-       alarm->time.tm_year = -1;
-       alarm->time.tm_wday = -1;
-       alarm->time.tm_yday = -1;
-       alarm->time.tm_isdst = -1;
-
 out:
        mutex_unlock(&priv->mutex);
        return res;
index 68197042feb77bab20eb80487f1327d843c7938e..ed43b431166064770c7486498f75a55a10fe5689 100644 (file)
@@ -419,25 +419,19 @@ ds1685_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
         *
         * The Linux RTC system doesn't support the "don't care" capability
         * of this RTC chip.  We check for it anyways in case support is
-        * added in the future.
+        * added in the future and only assign when we care.
         */
-       if (unlikely(seconds >= 0xc0))
-               alrm->time.tm_sec = -1;
-       else
+       if (likely(seconds < 0xc0))
                alrm->time.tm_sec = ds1685_rtc_bcd2bin(rtc, seconds,
                                                       RTC_SECS_BCD_MASK,
                                                       RTC_SECS_BIN_MASK);
 
-       if (unlikely(minutes >= 0xc0))
-               alrm->time.tm_min = -1;
-       else
+       if (likely(minutes < 0xc0))
                alrm->time.tm_min = ds1685_rtc_bcd2bin(rtc, minutes,
                                                       RTC_MINS_BCD_MASK,
                                                       RTC_MINS_BIN_MASK);
 
-       if (unlikely(hours >= 0xc0))
-               alrm->time.tm_hour = -1;
-       else
+       if (likely(hours < 0xc0))
                alrm->time.tm_hour = ds1685_rtc_bcd2bin(rtc, hours,
                                                        RTC_HRS_24_BCD_MASK,
                                                        RTC_HRS_24_BIN_MASK);
@@ -445,11 +439,6 @@ ds1685_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
        /* Write the data to rtc_wkalrm. */
        alrm->time.tm_mday = ds1685_rtc_bcd2bin(rtc, mday, RTC_MDAY_BCD_MASK,
                                                RTC_MDAY_BIN_MASK);
-       alrm->time.tm_mon = -1;
-       alrm->time.tm_year = -1;
-       alrm->time.tm_wday = -1;
-       alrm->time.tm_yday = -1;
-       alrm->time.tm_isdst = -1;
        alrm->enabled = !!(ctrlb & RTC_CTRL_B_AIE);
        alrm->pending = !!(ctrlc & RTC_CTRL_C_AF);
 
index 04fbd7fffd0d8f2af296b35ac3dcb049c5cd8002..b1f20d8c358fd5c2a223563c46e302d221e575e9 100644 (file)
@@ -197,12 +197,6 @@ static int ds3232_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
        alarm->time.tm_hour = bcd2bin(buf[2] & 0x7F);
        alarm->time.tm_mday = bcd2bin(buf[3] & 0x7F);
 
-       alarm->time.tm_mon = -1;
-       alarm->time.tm_year = -1;
-       alarm->time.tm_wday = -1;
-       alarm->time.tm_yday = -1;
-       alarm->time.tm_isdst = -1;
-
        alarm->enabled = !!(control & DS3232_REG_CR_A1IE);
        alarm->pending = !!(stat & DS3232_REG_SR_A1F);
 
index 207270376b552f6013f8cd86022727a0fc07058c..795a3f517cd0610d863c13f79883952a2298ac3e 100644 (file)
@@ -213,9 +213,6 @@ static int hym8563_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
                                        -1 :
                                        bcd2bin(buf[3] & HYM8563_WEEKDAY_MASK);
 
-       alm_tm->tm_mon = -1;
-       alm_tm->tm_year = -1;
-
        ret = i2c_smbus_read_byte_data(client, HYM8563_CTL2);
        if (ret < 0)
                return ret;
index d1bf93a8720027e529b6e51b8dbab304c4155c58..c829bc45a3714855811361663254582e4b7f8192 100644 (file)
@@ -320,10 +320,8 @@ static int m41t80_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
        alrm->time.tm_sec  = bcd2bin(alarmvals[4] & 0x7f);
        alrm->time.tm_min  = bcd2bin(alarmvals[3] & 0x7f);
        alrm->time.tm_hour = bcd2bin(alarmvals[2] & 0x3f);
-       alrm->time.tm_wday = -1;
        alrm->time.tm_mday = bcd2bin(alarmvals[1] & 0x3f);
        alrm->time.tm_mon  = bcd2bin(alarmvals[0] & 0x3f);
-       alrm->time.tm_year = -1;
 
        alrm->enabled = !!(alarmvals[0] & M41T80_ALMON_AFE);
        alrm->pending = (flags & M41T80_FLAGS_AF) && alrm->enabled;
index fe840c0edfef5f4d1572f5fef3e6d44cd8ef095a..7334c44fa7c3553d61db84570e2a78733d2e24e6 100644 (file)
@@ -149,14 +149,6 @@ static int mrst_read_alarm(struct device *dev, struct rtc_wkalrm *t)
        if (mrst->irq <= 0)
                return -EIO;
 
-       /* Basic alarms only support hour, minute, and seconds fields.
-        * Some also support day and month, for alarms up to a year in
-        * the future.
-        */
-       t->time.tm_mday = -1;
-       t->time.tm_mon = -1;
-       t->time.tm_year = -1;
-
        /* vRTC only supports binary mode */
        spin_lock_irq(&rtc_lock);
        t->time.tm_sec = vrtc_cmos_read(RTC_SECONDS_ALARM);
index b9ddbb001283e65335026932fdd03af3e55f81b2..26091a48925ffe22b8920a8c5b1da65dd0b12f29 100644 (file)
@@ -345,10 +345,6 @@ static int pcf8563_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *tm)
        tm->time.tm_hour = bcd2bin(buf[1] & 0x3F);
        tm->time.tm_mday = bcd2bin(buf[2] & 0x3F);
        tm->time.tm_wday = bcd2bin(buf[3] & 0x7);
-       tm->time.tm_mon = -1;
-       tm->time.tm_year = -1;
-       tm->time.tm_yday = -1;
-       tm->time.tm_isdst = -1;
 
        err = pcf8563_get_alarm_mode(client, &tm->enabled, &tm->pending);
        if (err < 0)
index ef86229428fc749b6a84a8993ff6fe50a2a92e3f..c8c7574667837522ae4863f743ba978229116fc5 100644 (file)
@@ -341,12 +341,6 @@ static int rs5c_read_alarm(struct device *dev, struct rtc_wkalrm *t)
        t->time.tm_sec = 0;
        t->time.tm_min = bcd2bin(rs5c->regs[RS5C_REG_ALARM_A_MIN] & 0x7f);
        t->time.tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C_REG_ALARM_A_HOURS]);
-       t->time.tm_mday = -1;
-       t->time.tm_mon = -1;
-       t->time.tm_year = -1;
-       t->time.tm_wday = -1;
-       t->time.tm_yday = -1;
-       t->time.tm_isdst = -1;
 
        /* ... and status */
        t->enabled = !!(rs5c->regs[RS5C_REG_CTRL1] & RS5C_CTRL1_AALE);
index 022ef26bef479a5eb96edd07871f9829b896cae5..05c79c38689d29bec5d77003e29b4ffd87e69fe2 100644 (file)
@@ -210,10 +210,7 @@ static int rv8803_get_alarm(struct device *dev, struct rtc_wkalrm *alrm)
        alrm->time.tm_sec  = 0;
        alrm->time.tm_min  = bcd2bin(alarmvals[0] & 0x7f);
        alrm->time.tm_hour = bcd2bin(alarmvals[1] & 0x3f);
-       alrm->time.tm_wday = -1;
        alrm->time.tm_mday = bcd2bin(alarmvals[2] & 0x3f);
-       alrm->time.tm_mon  = -1;
-       alrm->time.tm_year = -1;
 
        alrm->enabled = !!(rv8803->ctrl & RV8803_CTRL_AIE);
        alrm->pending = (flags & RV8803_FLAG_AF) && alrm->enabled;
index 772d221ec2d9f16fc879787ff2729c3c731a416b..7163b91bb773bd3a8ef0a3be75d9936ffc116f9b 100644 (file)
@@ -272,15 +272,9 @@ static int rx8010_read_alarm(struct device *dev, struct rtc_wkalrm *t)
        t->time.tm_min = bcd2bin(alarmvals[0] & 0x7f);
        t->time.tm_hour = bcd2bin(alarmvals[1] & 0x3f);
 
-       if (alarmvals[2] & RX8010_ALARM_AE)
-               t->time.tm_mday = -1;
-       else
+       if (!(alarmvals[2] & RX8010_ALARM_AE))
                t->time.tm_mday = bcd2bin(alarmvals[2] & 0x7f);
 
-       t->time.tm_wday = -1;
-       t->time.tm_mon = -1;
-       t->time.tm_year = -1;
-
        t->enabled = !!(rx8010->ctrlreg & RX8010_CTRL_AIE);
        t->pending = (flagreg & RX8010_FLAG_AF) && t->enabled;
 
index 9f105efbc5464815717f1a9bf622e947cabebbe2..2b85cc7a24e752c01d1cc16c60d738f7fbfc5983 100644 (file)
@@ -319,11 +319,6 @@ static int rx8025_read_alarm(struct device *dev, struct rtc_wkalrm *t)
                t->time.tm_hour = bcd2bin(ald[1] & 0x1f) % 12
                        + (ald[1] & 0x20 ? 12 : 0);
 
-       t->time.tm_wday = -1;
-       t->time.tm_mday = -1;
-       t->time.tm_mon = -1;
-       t->time.tm_year = -1;
-
        dev_dbg(dev, "%s: date: %ds %dm %dh %dmd %dm %dy\n",
                __func__,
                t->time.tm_sec, t->time.tm_min, t->time.tm_hour,
index d01ad7e8078ed6e44c61fbaa8e4875a96d8cce25..6d25e373e2464f030c95f20d86af39ef7c966689 100644 (file)
@@ -264,35 +264,23 @@ static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm)
        /* decode the alarm enable field */
        if (alm_en & S3C2410_RTCALM_SECEN)
                alm_tm->tm_sec = bcd2bin(alm_tm->tm_sec);
-       else
-               alm_tm->tm_sec = -1;
 
        if (alm_en & S3C2410_RTCALM_MINEN)
                alm_tm->tm_min = bcd2bin(alm_tm->tm_min);
-       else
-               alm_tm->tm_min = -1;
 
        if (alm_en & S3C2410_RTCALM_HOUREN)
                alm_tm->tm_hour = bcd2bin(alm_tm->tm_hour);
-       else
-               alm_tm->tm_hour = -1;
 
        if (alm_en & S3C2410_RTCALM_DAYEN)
                alm_tm->tm_mday = bcd2bin(alm_tm->tm_mday);
-       else
-               alm_tm->tm_mday = -1;
 
        if (alm_en & S3C2410_RTCALM_MONEN) {
                alm_tm->tm_mon = bcd2bin(alm_tm->tm_mon);
                alm_tm->tm_mon -= 1;
-       } else {
-               alm_tm->tm_mon = -1;
        }
 
        if (alm_en & S3C2410_RTCALM_YEAREN)
                alm_tm->tm_year = bcd2bin(alm_tm->tm_year);
-       else
-               alm_tm->tm_year = -1;
 
        return 0;
 }
index 60232bd366ef1499fabaf6d23c8f7538961dcf8e..15ac597d54da20515847ced69d342ae3051f255e 100644 (file)
@@ -179,12 +179,6 @@ static int tegra_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
        if (sec == 0) {
                /* alarm is disabled. */
                alarm->enabled = 0;
-               alarm->time.tm_mon = -1;
-               alarm->time.tm_mday = -1;
-               alarm->time.tm_year = -1;
-               alarm->time.tm_hour = -1;
-               alarm->time.tm_min = -1;
-               alarm->time.tm_sec = -1;
        } else {
                /* alarm is enabled. */
                alarm->enabled = 1;