These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / rtc / rtc-ds1343.c
index ae9f997..3d389bd 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/rtc.h>
 #include <linux/bcd.h>
 #include <linux/pm.h>
+#include <linux/pm_wakeirq.h>
 #include <linux/slab.h>
 
 #define DS1343_DRV_VERSION     "01.00"
@@ -162,12 +163,6 @@ static ssize_t ds1343_nvram_write(struct file *filp, struct kobject *kobj,
        struct device *dev = kobj_to_dev(kobj);
        struct ds1343_priv *priv = dev_get_drvdata(dev);
 
-       if (unlikely(!count))
-               return count;
-
-       if ((count + off) > DS1343_NVRAM_LEN)
-               count = DS1343_NVRAM_LEN - off;
-
        address = DS1343_NVRAM + off;
 
        ret = regmap_bulk_write(priv->map, address, buf, count);
@@ -187,12 +182,6 @@ static ssize_t ds1343_nvram_read(struct file *filp, struct kobject *kobj,
        struct device *dev = kobj_to_dev(kobj);
        struct ds1343_priv *priv = dev_get_drvdata(dev);
 
-       if (unlikely(!count))
-               return count;
-
-       if ((count + off) > DS1343_NVRAM_LEN)
-               count = DS1343_NVRAM_LEN - off;
-
        address = DS1343_NVRAM + off;
 
        ret = regmap_bulk_read(priv->map, address, buf, count);
@@ -675,15 +664,15 @@ static int ds1343_probe(struct spi_device *spi)
 
        if (priv->irq >= 0) {
                res = devm_request_threaded_irq(&spi->dev, spi->irq, NULL,
-                                               ds1343_thread,
-                                               IRQF_NO_SUSPEND | IRQF_ONESHOT,
+                                               ds1343_thread, IRQF_ONESHOT,
                                                "ds1343", priv);
                if (res) {
                        priv->irq = -1;
                        dev_err(&spi->dev,
                                "unable to request irq for rtc ds1343\n");
                } else {
-                       device_set_wakeup_capable(&spi->dev, 1);
+                       device_init_wakeup(&spi->dev, true);
+                       dev_pm_set_wake_irq(&spi->dev, spi->irq);
                }
        }
 
@@ -704,6 +693,8 @@ static int ds1343_remove(struct spi_device *spi)
                priv->irqen &= ~RTC_AF;
                mutex_unlock(&priv->mutex);
 
+               dev_pm_clear_wake_irq(&spi->dev);
+               device_init_wakeup(&spi->dev, false);
                devm_free_irq(&spi->dev, spi->irq, priv);
        }
 
@@ -743,7 +734,6 @@ static SIMPLE_DEV_PM_OPS(ds1343_pm, ds1343_suspend, ds1343_resume);
 static struct spi_driver ds1343_driver = {
        .driver = {
                .name = "ds1343",
-               .owner = THIS_MODULE,
                .pm = &ds1343_pm,
        },
        .probe = ds1343_probe,