RTC fixes for 4.20
Drivers: - cmos: stop exporting alarms when not supported - hctosys: correctly report range error - pcf2127: fix a memory leak -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEXx9Viay1+e7J/aM4AyWl4gNJNJIFAlvp+EIACgkQAyWl4gNJ NJJt0w/7BK1Gym0wmzKdLs/yg3LsU7t9HbQk1YeoFrLDwGdPoCNxBG46yKaHQt+1 03qnSDSHrc95+TbL7y4EIpl0ka6gZUSBmpzJlNYHYYPO5k3bnX7aNY6pIwVqKc+r 6TlTFS8VymNR0B7Rn7GcIUFbeCv7keiq2kC3uvE6VLb/221bU/68BPWC6SC4dSrB sD8xqQcyrNwz72nZez8GhdtoMYV8JvMewKhBSSTya8P0VoHJw4PzZ1vEeem13VJl cveDgjM2SVyL8clgXrOofj9mEDI+DqzhUcd3VaK1tcWr+JH3zjWsYdw4yQNg+I6N ivw0Ti6h3KYM7VhFwVIu2hxyHFD35E/zZRw4Wc487decXHHo8CQNxavCt1jW3Xc7 Jyo6JnPsl3gCX2VgbZK0PjWuSaRILI1Sq95fBRnbZOhlcYbHPD19gm+gS/HUA/Ac CMTPJBVNisnEwgDVnkro0yyLT2U/cnVfQTI424TiRfDEZNhHFxlyA34UK1spEew3 P/O59zYhHx8RZfiuS/ZMBp2m/YU24mkN+JMhgdkn3eCAyTBVrzNOhlQSuSvpi+yf JM6Ryfs4LkQ2/swWgRud+N9pI6ceDUj1liHth29lSVnw4qvn6Vvc1+Zshq+55NMQ fHiOlNLWLPGeMhDF3sJp2C1WpZS5meyDswzUKuHPFWuR9LmjH40= =B3f6 -----END PGP SIGNATURE----- Merge tag 'rtc-4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux Pull RTC driver fixes from Alexandre Belloni: - cmos: stop exporting alarms when not supported - hctosys: correctly report range error - pcf2127: fix a memory leak * tag 'rtc-4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: rtc: pcf2127: fix a kmemleak caused in pcf2127_i2c_gather_write rtc: hctosys: Add missing range error reporting rtc: cmos: Do not export alarm rtc_ops when we do not support alarms
This commit is contained in:
commit
b7bbf9935f
|
@ -50,8 +50,10 @@ static int __init rtc_hctosys(void)
|
|||
tv64.tv_sec = rtc_tm_to_time64(&tm);
|
||||
|
||||
#if BITS_PER_LONG == 32
|
||||
if (tv64.tv_sec > INT_MAX)
|
||||
if (tv64.tv_sec > INT_MAX) {
|
||||
err = -ERANGE;
|
||||
goto err_read;
|
||||
}
|
||||
#endif
|
||||
|
||||
err = do_settimeofday64(&tv64);
|
||||
|
|
|
@ -257,6 +257,7 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t)
|
|||
struct cmos_rtc *cmos = dev_get_drvdata(dev);
|
||||
unsigned char rtc_control;
|
||||
|
||||
/* This not only a rtc_op, but also called directly */
|
||||
if (!is_valid_irq(cmos->irq))
|
||||
return -EIO;
|
||||
|
||||
|
@ -452,6 +453,7 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
|
|||
unsigned char mon, mday, hrs, min, sec, rtc_control;
|
||||
int ret;
|
||||
|
||||
/* This not only a rtc_op, but also called directly */
|
||||
if (!is_valid_irq(cmos->irq))
|
||||
return -EIO;
|
||||
|
||||
|
@ -516,9 +518,6 @@ static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled)
|
|||
struct cmos_rtc *cmos = dev_get_drvdata(dev);
|
||||
unsigned long flags;
|
||||
|
||||
if (!is_valid_irq(cmos->irq))
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock_irqsave(&rtc_lock, flags);
|
||||
|
||||
if (enabled)
|
||||
|
@ -579,6 +578,12 @@ static const struct rtc_class_ops cmos_rtc_ops = {
|
|||
.alarm_irq_enable = cmos_alarm_irq_enable,
|
||||
};
|
||||
|
||||
static const struct rtc_class_ops cmos_rtc_ops_no_alarm = {
|
||||
.read_time = cmos_read_time,
|
||||
.set_time = cmos_set_time,
|
||||
.proc = cmos_procfs,
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
|
@ -855,9 +860,12 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
|
|||
dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
|
||||
goto cleanup1;
|
||||
}
|
||||
|
||||
cmos_rtc.rtc->ops = &cmos_rtc_ops;
|
||||
} else {
|
||||
cmos_rtc.rtc->ops = &cmos_rtc_ops_no_alarm;
|
||||
}
|
||||
|
||||
cmos_rtc.rtc->ops = &cmos_rtc_ops;
|
||||
cmos_rtc.rtc->nvram_old_abi = true;
|
||||
retval = rtc_register_device(cmos_rtc.rtc);
|
||||
if (retval)
|
||||
|
|
|
@ -303,6 +303,9 @@ static int pcf2127_i2c_gather_write(void *context,
|
|||
memcpy(buf + 1, val, val_size);
|
||||
|
||||
ret = i2c_master_send(client, buf, val_size + 1);
|
||||
|
||||
kfree(buf);
|
||||
|
||||
if (ret != val_size + 1)
|
||||
return ret < 0 ? ret : -EIO;
|
||||
|
||||
|
|
Loading…
Reference in New Issue