From patchwork Wed Apr 18 06:37:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kim, Milo" X-Patchwork-Id: 153399 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-vx0-f184.google.com (mail-vx0-f184.google.com [209.85.220.184]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 55869B6FC4 for ; Wed, 18 Apr 2012 16:37:08 +1000 (EST) Received: by vcge1 with SMTP id e1sf6595840vcg.11 for ; Tue, 17 Apr 2012 23:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:from:to:cc:date:subject:thread-topic :thread-index:message-id:accept-language:x-ms-has-attach :x-ms-tnef-correlator:acceptlanguage:mime-version:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-language:content-type; bh=tf/lvwoDeGTqe8VbSdTsbZsyhpGKJPthpZI5iu8zBDA=; b=M7OXwT/ZrwTDIoyWhjzPMG1A3shdTwuGPNnOVDDhi6n8huvJZ3DMwlaEE+SjHgU048 I/lLpTT2TuoUMEeqM5/ZFFinLT5WQ+++uTXm/dVcKzG+aObyl1S2k8cNxAshDlW+lDOw opemzrOlnYJ2VL2FdIQhUSjdvgwACK9/g0pcc= Received: by 10.50.57.135 with SMTP id i7mr199479igq.0.1334731026324; Tue, 17 Apr 2012 23:37:06 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.5.174 with SMTP id t14ls602714igt.2.gmail; Tue, 17 Apr 2012 23:37:05 -0700 (PDT) Received: by 10.42.197.137 with SMTP id ek9mr575702icb.5.1334731025913; Tue, 17 Apr 2012 23:37:05 -0700 (PDT) Received: by 10.42.197.137 with SMTP id ek9mr575701icb.5.1334731025901; Tue, 17 Apr 2012 23:37:05 -0700 (PDT) Received: from comal.ext.ti.com (comal.ext.ti.com. [198.47.26.152]) by gmr-mx.google.com with ESMTPS id dd7si8208206igc.0.2012.04.17.23.37.05 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Apr 2012 23:37:05 -0700 (PDT) Received-SPF: pass (google.com: domain of Milo.Kim@ti.com designates 198.47.26.152 as permitted sender) client-ip=198.47.26.152; Received: from nscmmp3.nsc.com ([10.188.143.115]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id q3I6b5jt020571 for ; Wed, 18 Apr 2012 01:37:05 -0500 Received: from excas02.scwf.nsc.com (excas02.nsc.com [10.188.134.106]) by nscmmp3.nsc.com with ESMTPS id BT-MMP-5791845; Tue, 17 Apr 2012 23:37:04 -0700 Received: from exmail04.scwf.nsc.com ([fe80:0000:0000:0000:b9d1:19d6:20.120.47.42]) by excas02.scwf.nsc.com ([10.188.134.106]) with mapi; Tue, 17 Apr 2012 23:37:04 -0700 From: "Kim, Milo" To: "a.zummo@towertech.it" CC: "linux-kernel@vger.kernel.org" , "rtc-linux@googlegroups.com" , "john.stultz@linaro.org" Date: Tue, 17 Apr 2012 23:37:03 -0700 Subject: [rtc-linux] [PATCH] rtc-proc: change the limitation on creating rtc proc data Thread-Topic: [PATCH] rtc-proc: change the limitation on creating rtc proc data Thread-Index: Ac0dLapXX5z4kW1mQKm0jAsJiHh0NA== Message-ID: Accept-Language: ko-KR, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: ko-KR, en-US MIME-Version: 1.0 X-Original-Sender: milo.kim@ti.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of Milo.Kim@ti.com designates 198.47.26.152 as permitted sender) smtp.mail=Milo.Kim@ti.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Language: en-US To get time information via /proc/driver/rtc, only the first device (rtc0) is used. If the rtcN (eg. rtc1 or rtc2) is used for the system clock, there is no way to get information of rtcN via /proc/driver/rtc. With this patch, the time data can be retrieved from the system clock RTC. If the RTC_HCTOSYS_DEVICE is not defined, then rtc0 is used by default. Signed-off-by: Milo(Woogyom) Kim --- Documentation/rtc.txt | 5 +++-- drivers/rtc/Kconfig | 10 ++++++---- drivers/rtc/rtc-proc.c | 24 ++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Documentation/rtc.txt b/Documentation/rtc.txt index 2501604..32aa400 100644 --- a/Documentation/rtc.txt +++ b/Documentation/rtc.txt @@ -119,8 +119,9 @@ three different userspace interfaces: * /sys/class/rtc/rtcN ... sysfs attributes support readonly access to some RTC attributes. - * /proc/driver/rtc ... the first RTC (rtc0) may expose itself - using a procfs interface. More information is (currently) shown + * /proc/driver/rtc ... the system clock RTC may expose itself + using a procfs interface. If there is no RTC for the system clock, + rtc0 is used by default. More information is (currently) shown here than through sysfs. The RTC Class framework supports a wide variety of RTCs, ranging from those diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 8c8377d..d1927f6 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -69,13 +69,15 @@ config RTC_INTF_SYSFS If unsure, say Y. config RTC_INTF_PROC - boolean "/proc/driver/rtc (procfs for rtc0)" + boolean "/proc/driver/rtc (procfs for rtcN)" depends on PROC_FS default RTC_CLASS help - Say yes here if you want to use your first RTC through the proc - interface, /proc/driver/rtc. Other RTCs will not be available - through that API. + Say yes here if you want to use your system clock RTC through + the proc interface, /proc/driver/rtc. + Other RTCs will not be available through that API. + If there is no RTC for the system clock, then the first RTC(rtc0) + is used by default. If unsure, say Y. diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c index 0a59fda..e96236a 100644 --- a/drivers/rtc/rtc-proc.c +++ b/drivers/rtc/rtc-proc.c @@ -18,6 +18,26 @@ #include "rtc-core.h" +#define NAME_SIZE 10 + +#if defined(CONFIG_RTC_HCTOSYS_DEVICE) +static bool is_rtc_hctosys(struct rtc_device *rtc) +{ + int size; + char name[NAME_SIZE]; + + size = scnprintf(name, NAME_SIZE, "rtc%d", rtc->id); + if (size > NAME_SIZE) + return false; + + return !strncmp(name, CONFIG_RTC_HCTOSYS_DEVICE, NAME_SIZE); +} +#else +static bool is_rtc_hctosys(struct rtc_device *rtc) +{ + return (rtc->id == 0); +} +#endif static int rtc_proc_show(struct seq_file *seq, void *offset) { @@ -117,12 +137,12 @@ static const struct file_operations rtc_proc_fops = { void rtc_proc_add_device(struct rtc_device *rtc) { - if (rtc->id == 0) + if (is_rtc_hctosys(rtc)) proc_create_data("driver/rtc", 0, NULL, &rtc_proc_fops, rtc); } void rtc_proc_del_device(struct rtc_device *rtc) { - if (rtc->id == 0) + if (is_rtc_hctosys(rtc)) remove_proc_entry("driver/rtc", NULL); }