[OPW,kernel,v5] power: ab8500_fg.c: use 64-bit time types
diff mbox

Message ID 1412777386-4428-1-git-send-email-ebru.akagunduz@gmail.com
State New, archived
Headers show

Commit Message

Ebru Akagündüz Oct. 8, 2014, 2:09 p.m. UTC
This patch changes 32-bit time types to 64-bit in
drivers/power/ab8500_fg.c

timespec and time_t can only represent signed 32-bit
dates but the driver should represent dates that are
after January 2038. So used time64.h header file and
its proper types and functions.

Use time64_t type instead of __kernel_time_t for
time_stamps variable of ab8500_fg_avg_cap struct

Signed-off-by: Ebru Akagunduz <ebru.akagunduz@gmail.com>
---
Changes in v5:
 - Move changelog below to "---" line

Changes in v4:
 - Change patch subject line and add additional
   annotations to commit message

Changes in v3:
 - Use time64_t type instead of __kernel_time_t
   for time_stamps variable of ab8500_fg_avg_cap
   struct

Changes in v2:
 - Change ts variable name to ts64

 drivers/power/ab8500_fg.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Comments

Arnd Bergmann Oct. 8, 2014, 3:02 p.m. UTC | #1
On Wednesday 08 October 2014 17:09:46 Ebru Akagunduz wrote:
> This patch changes 32-bit time types to 64-bit in
> drivers/power/ab8500_fg.c
> 
> timespec and time_t can only represent signed 32-bit
> dates but the driver should represent dates that are
> after January 2038. So used time64.h header file and
> its proper types and functions.
> 
> Use time64_t type instead of __kernel_time_t for
> time_stamps variable of ab8500_fg_avg_cap struct
> 
> Signed-off-by: Ebru Akagunduz <ebru.akagunduz@gmail.com>
> 

Acked-by: Arnd Bergmann <arnd@arndb.de>

I assume the drivers/power maintainers are not picking this
patch up during the merge window but will do so after -rc1
is out.

I wonder if I should start a git tree for the patches that
are ready but not applied by maintainers yet.

	Arnd
Sebastian Reichel Oct. 8, 2014, 3:39 p.m. UTC | #2
Hi,

On Wed, Oct 08, 2014 at 05:02:32PM +0200, Arnd Bergmann wrote:
> On Wednesday 08 October 2014 17:09:46 Ebru Akagunduz wrote:
> > This patch changes 32-bit time types to 64-bit in
> > drivers/power/ab8500_fg.c
> > 
> > timespec and time_t can only represent signed 32-bit
> > dates but the driver should represent dates that are
> > after January 2038. So used time64.h header file and
> > its proper types and functions.
> > 
> > Use time64_t type instead of __kernel_time_t for
> > time_stamps variable of ab8500_fg_avg_cap struct
> > 
> > Signed-off-by: Ebru Akagunduz <ebru.akagunduz@gmail.com>
> 
> Acked-by: Arnd Bergmann <arnd@arndb.de>

Thanks for taking care of patch review.

I have one more comment for future patches: Please CC
the related mailing list(s). You can find the correct
ones using ./scripts/get_maintainer.pl.

> I assume the drivers/power maintainers are not picking this patch
> up during the merge window but will do so after -rc1 is out.

correct.

> I wonder if I should start a git tree for the patches that
> are ready but not applied by maintainers yet.

something like next-preview?

-- Sebastian
Arnd Bergmann Oct. 23, 2014, 8:05 p.m. UTC | #3
On Wednesday 08 October 2014 17:39:21 Sebastian Reichel wrote:
> On Wed, Oct 08, 2014 at 05:02:32PM +0200, Arnd Bergmann wrote:
> > On Wednesday 08 October 2014 17:09:46 Ebru Akagunduz wrote:
> 
> > I wonder if I should start a git tree for the patches that
> > are ready but not applied by maintainers yet.
> 
> something like next-preview?
> 

I've started a tree at

git://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git y2038

now and applied this patch. I'm still expecting you to pick it up in the
linux-pm git tree, and will drop it from my tree once it's there.

Thanks,

	Arnd
Sebastian Reichel Oct. 27, 2014, 6:21 p.m. UTC | #4
Hi,

On Wed, Oct 08, 2014 at 05:09:46PM +0300, Ebru Akagunduz wrote:
> This patch changes 32-bit time types to 64-bit in
> drivers/power/ab8500_fg.c
> 
> timespec and time_t can only represent signed 32-bit
> dates but the driver should represent dates that are
> after January 2038. So used time64.h header file and
> its proper types and functions.
> 
> Use time64_t type instead of __kernel_time_t for
> time_stamps variable of ab8500_fg_avg_cap struct

It's in the next branch of the power supply git tree now.
I will send it to torvalds in a 3.18-rc pull request.

-- Sebastian
Arnd Bergmann Oct. 27, 2014, 6:27 p.m. UTC | #5
On Monday 27 October 2014 19:21:37 Sebastian Reichel wrote:
> Hi,
> 
> On Wed, Oct 08, 2014 at 05:09:46PM +0300, Ebru Akagunduz wrote:
> > This patch changes 32-bit time types to 64-bit in
> > drivers/power/ab8500_fg.c
> > 
> > timespec and time_t can only represent signed 32-bit
> > dates but the driver should represent dates that are
> > after January 2038. So used time64.h header file and
> > its proper types and functions.
> > 
> > Use time64_t type instead of __kernel_time_t for
> > time_stamps variable of ab8500_fg_avg_cap struct
> 
> It's in the next branch of the power supply git tree now.
> I will send it to torvalds in a 3.18-rc pull request.

I guess you mean 3.19? The patch is important, but it's not
urgent by any definition, so it can certainly wait for the
next merge window.

	Arnd

Patch
diff mbox

diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c
index 3cb4178..84b4466 100644
--- a/drivers/power/ab8500_fg.c
+++ b/drivers/power/ab8500_fg.c
@@ -25,6 +25,7 @@ 
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/time.h>
+#include <linux/time64.h>
 #include <linux/of.h>
 #include <linux/completion.h>
 #include <linux/mfd/core.h>
@@ -108,7 +109,7 @@  enum ab8500_fg_calibration_state {
 struct ab8500_fg_avg_cap {
 	int avg;
 	int samples[NBR_AVG_SAMPLES];
-	__kernel_time_t time_stamps[NBR_AVG_SAMPLES];
+	time64_t time_stamps[NBR_AVG_SAMPLES];
 	int pos;
 	int nbr_samples;
 	int sum;
@@ -386,15 +387,15 @@  static int ab8500_fg_is_low_curr(struct ab8500_fg *di, int curr)
  */
 static int ab8500_fg_add_cap_sample(struct ab8500_fg *di, int sample)
 {
-	struct timespec ts;
+	struct timespec64 ts64;
 	struct ab8500_fg_avg_cap *avg = &di->avg_cap;
 
-	getnstimeofday(&ts);
+	getnstimeofday64(&ts64);
 
 	do {
 		avg->sum += sample - avg->samples[avg->pos];
 		avg->samples[avg->pos] = sample;
-		avg->time_stamps[avg->pos] = ts.tv_sec;
+		avg->time_stamps[avg->pos] = ts64.tv_sec;
 		avg->pos++;
 
 		if (avg->pos == NBR_AVG_SAMPLES)
@@ -407,7 +408,7 @@  static int ab8500_fg_add_cap_sample(struct ab8500_fg *di, int sample)
 		 * Check the time stamp for each sample. If too old,
 		 * replace with latest sample
 		 */
-	} while (ts.tv_sec - VALID_CAPACITY_SEC > avg->time_stamps[avg->pos]);
+	} while (ts64.tv_sec - VALID_CAPACITY_SEC > avg->time_stamps[avg->pos]);
 
 	avg->avg = avg->sum / avg->nbr_samples;
 
@@ -446,14 +447,14 @@  static void ab8500_fg_clear_cap_samples(struct ab8500_fg *di)
 static void ab8500_fg_fill_cap_sample(struct ab8500_fg *di, int sample)
 {
 	int i;
-	struct timespec ts;
+	struct timespec64 ts64;
 	struct ab8500_fg_avg_cap *avg = &di->avg_cap;
 
-	getnstimeofday(&ts);
+	getnstimeofday64(&ts64);
 
 	for (i = 0; i < NBR_AVG_SAMPLES; i++) {
 		avg->samples[i] = sample;
-		avg->time_stamps[i] = ts.tv_sec;
+		avg->time_stamps[i] = ts64.tv_sec;
 	}
 
 	avg->pos = 0;