Skip to contentSkip to conversation

rtc: ps3: switch to rtc_time64_to_tm/rtc_tm_to_time64

PATCH In review Alexandre Belloni 3 participants 6 messages Mar 20, 2019 – Apr 1, 2019

Subsystems (3)
lore
Share & tools
lore

Alexandre Belloni

author maintainer
#0 lore raw

PATCH 1/4 rtc: ps3: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion as the PS3 handles 64bit values.

---
 drivers/rtc/rtc-ps3.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/rtc/rtc-ps3.c +2 -5
index 347288bff438..bffc5713e16f 100644
@@ -40,16 +40,13 @@ static u64 read_rtc(void)
 
 static int ps3_get_time(struct device *dev, struct rtc_time *tm)
 {
-	rtc_time_to_tm(read_rtc() + ps3_os_area_get_rtc_diff(), tm);
+	rtc_time64_to_tm(read_rtc() + ps3_os_area_get_rtc_diff(), tm);
 	return 0;
 }
 
 static int ps3_set_time(struct device *dev, struct rtc_time *tm)
 {
-	unsigned long now;
-
-	rtc_tm_to_time(tm, &now);
-	ps3_os_area_set_rtc_diff(now - read_rtc());
+	ps3_os_area_set_rtc_diff(rtc_tm_to_time64(tm) - read_rtc());
 	return 0;
 }
 
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

PATCH 2/4 rtc: ps3: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

The original text refers to version 2 so also update MODULE_LICENSE() to "GPL v2" instead of "GPL".

---
 drivers/rtc/rtc-ps3.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/rtc/rtc-ps3.c +2 -14
index bffc5713e16f..7e2a941a195b 100644
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * PS3 RTC Driver
  *
  * Copyright 2009 Sony Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.
- * If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <linux/kernel.h>
@@ -77,6 +65,6 @@ static struct platform_driver ps3_rtc_driver = {
 module_platform_driver_probe(ps3_rtc_driver, ps3_rtc_probe);
 
 MODULE_AUTHOR("Sony Corporation");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("ps3 RTC driver");
 MODULE_ALIAS("platform:rtc-ps3");
Signature · 1 line
2.20.1
Reviewed-by on v1 2/4
#2 lore raw

Re: [PATCH 2/4] rtc: ps3: convert to SPDX identifier

Quoted 6 lines · Alexandre Belloni

Use SPDX-License-Identifier instead of a verbose license text.

The original text refers to version 2 so also update MODULE_LICENSE() to "GPL v2" instead of "GPL".

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#3 lore raw

Re: [PATCH 2/4] rtc: ps3: convert to SPDX identifier

In reply to Alexandre Belloni
Quoted 15 lines · Alexandre Belloni

Use SPDX-License-Identifier instead of a verbose license text.

The original text refers to version 2 so also update MODULE_LICENSE() to "GPL v2" instead of "GPL".

---
  drivers/rtc/rtc-ps3.c | 16 ++--------------
  1 file changed, 2 insertions(+), 14 deletions(-)
drivers/rtc/rtc-ps3.c +0 -0
index bffc5713e16f..7e2a941a195b 100644

drivers/rtc/rtc-ps3.c line 1

Quoted 1 line
drivers/rtc/rtc-ps3.c +1 -0
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0

Should we not keep it like.
https://lkml.org/lkml/2019/2/13/570

Cheers,
Mukesh

Quoted 28 lines
drivers/rtc/rtc-ps3.c +1 -14
  /*
   * PS3 RTC Driver
   *
   * Copyright 2009 Sony Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.
- * If not, see <http://www.gnu.org/licenses/>.
   */
 
  #include <linux/kernel.h>
@@ -77,6 +65,6 @@ static struct platform_driver ps3_rtc_driver = {
  module_platform_driver_probe(ps3_rtc_driver, ps3_rtc_probe);
 
  MODULE_AUTHOR("Sony Corporation");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
  MODULE_DESCRIPTION("ps3 RTC driver");
  MODULE_ALIAS("platform:rtc-ps3");
author maintainer
#4 lore raw

PATCH 3/4 rtc: ps3: convert to devm_rtc_allocate_device

In reply to Alexandre Belloni

This allows further improvement of the driver.

---
 drivers/rtc/rtc-ps3.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/rtc/rtc-ps3.c +5 -3
index 7e2a941a195b..f8b56f3b2529 100644
@@ -47,13 +47,15 @@ static int __init ps3_rtc_probe(struct platform_device *dev)
 {
 	struct rtc_device *rtc;
 
-	rtc = devm_rtc_device_register(&dev->dev, "rtc-ps3", &ps3_rtc_ops,
-				  THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&dev->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &ps3_rtc_ops;
+
 	platform_set_drvdata(dev, rtc);
-	return 0;
+
+	return rtc_register_device(rtc);
 }
 
 static struct platform_driver ps3_rtc_driver = {
Signature · 1 line
2.20.1
author maintainer
#5 lore raw

PATCH 4/4 rtc: ps3: set range

In reply to Alexandre Belloni

The PS3 has a 64bit second counter from 2000. While this exceeds the 64bit UNIX timestamp, there is not doubt that non of them will still be working by then.

---
 drivers/rtc/rtc-ps3.c | 1 +
 1 file changed, 1 insertion(+)
drivers/rtc/rtc-ps3.c +1 -0
index f8b56f3b2529..3ee80693f141 100644
@@ -52,6 +52,7 @@ static int __init ps3_rtc_probe(struct platform_device *dev)
 		return PTR_ERR(rtc);
 
 	rtc->ops = &ps3_rtc_ops;
+	rtc->range_max = U64_MAX;
 
 	platform_set_drvdata(dev, rtc);
 
Signature · 1 line
2.20.1