Patchwork Re: mfd: tps6586x: add RTC driver for TI TPS6586x

login
register
mail settings
Submitter lightning314
Date March 9, 2011, 2:21 a.m.
Message ID <c11e254f-d50e-4d37-9c94-987765e35293@o21g2000prh.googlegroups.com>
Download mbox | patch
Permalink /patch/86054/
State New
Headers show

Comments

lightning314 - March 9, 2011, 2:21 a.m.
I use "diff -u" to generate diff patch again.
Please check it.


Thanks
Wei.

Patch

--- rtc-tps6586x.c-orig	2011-03-08 15:58:40.000000000 +0800
+++ rtc-tps6586x.c	2011-03-09 10:15:27.310598802 +0800
@@ -90,14 +90,6 @@ 
 		dev_err(dev, "requested time unsupported\n");
 		return -EINVAL;
 	}
-
-	if (alrm->enabled && !rtc->irq_en) {
-		enable_irq(rtc->irq);
-		rtc->irq_en = true;
-	} else if (!alrm->enabled && rtc->irq_en) {
-		disable_irq(rtc->irq);
-		rtc->irq_en = false;
-	}

 	seconds -= rtc->epoch_start;

@@ -147,6 +139,11 @@ 
 		dev_err(dev, "can't set alarm to requested time\n");
 		return -EINVAL;
 	}
+
+	if (rtc->irq_en && rtc->irq_en && (rtc->irq != -1)) {
+		disable_irq(rtc->irq);
+		rtc->irq_en = false;
+	}

 	seconds -= rtc->epoch_start;
 	ticks = (unsigned long long)seconds << 10;
@@ -156,8 +153,15 @@ 
 	buff[2] = ticks & 0xff;

 	err = tps6586x_writes(tps_dev, RTC_ALARM1_HI, sizeof(buff), buff);
-	if (err)
+	if (err) {
 		dev_err(tps_dev, "unable to program alarm\n");
+		return err;
+	}
+
+	if (alrm->enabled && (rtc->irq != -1)) {
+		enable_irq(rtc->irq);
+		rtc->irq_en = true;
+	}

 	return err;
 }
@@ -272,6 +276,9 @@ 

 	epoch = &pdata->start;

+	epoch->year = 2009;
+	epoch->month = 1;
+	epoch->day = 1;
 	rtc->epoch_start = mktime(epoch->year, epoch->month, epoch->day,
 				epoch->hour, epoch->min, epoch->sec);