Commit b7bbf993 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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
parents 47e624c0 9bde0afb
...@@ -50,8 +50,10 @@ static int __init rtc_hctosys(void) ...@@ -50,8 +50,10 @@ static int __init rtc_hctosys(void)
tv64.tv_sec = rtc_tm_to_time64(&tm); tv64.tv_sec = rtc_tm_to_time64(&tm);
#if BITS_PER_LONG == 32 #if BITS_PER_LONG == 32
if (tv64.tv_sec > INT_MAX) if (tv64.tv_sec > INT_MAX) {
err = -ERANGE;
goto err_read; goto err_read;
}
#endif #endif
err = do_settimeofday64(&tv64); err = do_settimeofday64(&tv64);
......
...@@ -257,6 +257,7 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t) ...@@ -257,6 +257,7 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t)
struct cmos_rtc *cmos = dev_get_drvdata(dev); struct cmos_rtc *cmos = dev_get_drvdata(dev);
unsigned char rtc_control; unsigned char rtc_control;
/* This not only a rtc_op, but also called directly */
if (!is_valid_irq(cmos->irq)) if (!is_valid_irq(cmos->irq))
return -EIO; return -EIO;
...@@ -452,6 +453,7 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) ...@@ -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; unsigned char mon, mday, hrs, min, sec, rtc_control;
int ret; int ret;
/* This not only a rtc_op, but also called directly */
if (!is_valid_irq(cmos->irq)) if (!is_valid_irq(cmos->irq))
return -EIO; return -EIO;
...@@ -516,9 +518,6 @@ static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled) ...@@ -516,9 +518,6 @@ static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled)
struct cmos_rtc *cmos = dev_get_drvdata(dev); struct cmos_rtc *cmos = dev_get_drvdata(dev);
unsigned long flags; unsigned long flags;
if (!is_valid_irq(cmos->irq))
return -EINVAL;
spin_lock_irqsave(&rtc_lock, flags); spin_lock_irqsave(&rtc_lock, flags);
if (enabled) if (enabled)
...@@ -579,6 +578,12 @@ static const struct rtc_class_ops cmos_rtc_ops = { ...@@ -579,6 +578,12 @@ static const struct rtc_class_ops cmos_rtc_ops = {
.alarm_irq_enable = cmos_alarm_irq_enable, .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) ...@@ -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); dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
goto cleanup1; 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; cmos_rtc.rtc->nvram_old_abi = true;
retval = rtc_register_device(cmos_rtc.rtc); retval = rtc_register_device(cmos_rtc.rtc);
if (retval) if (retval)
......
...@@ -303,6 +303,9 @@ static int pcf2127_i2c_gather_write(void *context, ...@@ -303,6 +303,9 @@ static int pcf2127_i2c_gather_write(void *context,
memcpy(buf + 1, val, val_size); memcpy(buf + 1, val, val_size);
ret = i2c_master_send(client, buf, val_size + 1); ret = i2c_master_send(client, buf, val_size + 1);
kfree(buf);
if (ret != val_size + 1) if (ret != val_size + 1)
return ret < 0 ? ret : -EIO; return ret < 0 ? ret : -EIO;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment