Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1661271 > unrolled thread

[PATCH v1 05/25] ds1302: Switch to use %pt

Started byAndy Shevchenko <andriy.shevchenko@linux.intel.com>
First post2017-06-08 16:00 +0200
Last post2017-06-08 16:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v1 05/25] ds1302: Switch to use %pt Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-06-08 16:00 +0200
    Re: [PATCH v1 05/25] ds1302: Switch to use %pt Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-08 16:10 +0200

#1661271 — [PATCH v1 05/25] ds1302: Switch to use %pt

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-06-08 16:00 +0200
Subject[PATCH v1 05/25] ds1302: Switch to use %pt
Message-ID<tQ68H-50i-51@gated-at.bofh.it>
Use %pt instead of open coded variant to print content of
struct rtc_time in human readable format.

Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/char/ds1302.c | 38 ++++++++++----------------------------
 1 file changed, 10 insertions(+), 28 deletions(-)

diff --git a/drivers/char/ds1302.c b/drivers/char/ds1302.c
index c614a56e68cc..7db23a336636 100644
--- a/drivers/char/ds1302.c
+++ b/drivers/char/ds1302.c
@@ -4,7 +4,7 @@
 *!
 *! DESCRIPTION: Implements an interface for the DS1302 RTC
 *!
-*! Functions exported: ds1302_readreg, ds1302_writereg, ds1302_init, get_rtc_status
+*! Functions exported: ds1302_readreg, ds1302_writereg, ds1302_init
 *!
 *! ---------------------------------------------------------------------------
 *!
@@ -257,31 +257,6 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	}
 }
 
-int
-get_rtc_status(char *buf)
-{
-	char *p;
-	struct rtc_time tm;
-
-	p = buf;
-
-	get_rtc_time(&tm);
-
-	/*
-	 * There is no way to tell if the luser has the RTC set for local
-	 * time or for Universal Standard Time (GMT). Probably local though.
-	 */
-
-	p += sprintf(p,
-		"rtc_time\t: %02d:%02d:%02d\n"
-		"rtc_date\t: %04d-%02d-%02d\n",
-		tm.tm_hour, tm.tm_min, tm.tm_sec,
-		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
-
-	return  p - buf;
-}
-
-
 /* The various file operations we support. */
 
 static const struct file_operations rtc_fops = {
@@ -298,6 +273,7 @@ static int __init
 ds1302_probe(void)
 {
 	int retval, res, baur;
+	struct rtc_time tm;
 
 	baur=(boot_cpu_data.bus_clock/(2*1000*1000));
 
@@ -319,8 +295,14 @@ ds1302_probe(void)
 		char buf[100];
 		ds1302_wdisable();
 		printk("%s: RTC found.\n", ds1302_name);
-		get_rtc_status(buf);
-		printk(buf);
+		/*
+		 * There is no way to tell if the luser has the RTC set
+		 * for local time or for Universal Standard Time (GMT).
+		 * Probably local though.
+		 */
+		get_rtc_time(&tm);
+		printk("rtc_time\t: %ptt\n", &tm);
+		printk("rtc_date\t: %ptd\n", &tm);
 		retval = 1;
 	} else {
 		printk("%s: RTC not found.\n", ds1302_name);
-- 
2.11.0

[toc] | [next] | [standalone]


#1661304

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-06-08 16:10 +0200
Message-ID<tQ6in-5iV-55@gated-at.bofh.it>
In reply to#1661271
On Thu, Jun 08, 2017 at 04:47:51PM +0300, Andy Shevchenko wrote:
> Use %pt instead of open coded variant to print content of
> struct rtc_time in human readable format.
> 
> Cc: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web