From patchwork Mon Jul 7 11:50:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Fietze X-Patchwork-Id: 367854 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-lb0-x23b.google.com (mail-lb0-x23b.google.com [IPv6:2a00:1450:4010:c04::23b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9890614010F for ; Tue, 8 Jul 2014 20:14:34 +1000 (EST) Received: by mail-lb0-f187.google.com with SMTP id n15sf669466lbi.24 for ; Tue, 08 Jul 2014 03:14:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=from:to:subject:date:message-id:organization:user-agent:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=vQrNTkuJeifVnqE/v+l7JMmueoEp9jZbgO5D0FS0PTA=; b=yTXIEdyhA7srgLv24+6Zj+A0kYjIzQhiyZ7N2/iyOlfL6Z4ooYYW/4x3EI4wMkH7Px GEjH536fGUN0EIoww7QFWgHCRIEbwEqJpznvfsCm1gJ0GTIr2X9kPRAuNXyB9jZdmWoj YhuTmbuyB8/IBgFJz+uz17okf84coyYCAIezTojxEVlGJo+A1VfY6TuIHhDRTsgTTmZp +//p9ZQj5kAHmTMtbtkL/TUZ78iv6L4nx11Jpf3nBiTmzjmtIBwB6peQdujWl3MXlUcj cxR49ays9i6r+3kq6VyPKIr2tF3rvWV5KRhLx8NggkTmvrExd2V7/RWtgDkWRPOHZVyj irIg== X-Received: by 10.152.10.35 with SMTP id f3mr9296lab.6.1404814470503; Tue, 08 Jul 2014 03:14:30 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.152.27.168 with SMTP id u8ls377160lag.50.gmail; Tue, 08 Jul 2014 03:14:30 -0700 (PDT) X-Received: by 10.152.42.129 with SMTP id o1mr936166lal.7.1404814470071; Tue, 08 Jul 2014 03:14:30 -0700 (PDT) Received: from coyote.quickmin.net (coyote.quickmin.net. [217.14.112.24]) by gmr-mx.google.com with ESMTPS id gc5si112150wic.1.2014.07.08.03.14.29 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 08 Jul 2014 03:14:30 -0700 (PDT) Received-SPF: none (google.com: roman.fietze@telemotive.de does not designate permitted sender hosts) client-ip=217.14.112.24; Received: (qmail 87536 invoked from network); 7 Jul 2014 13:50:12 +0200 Received: by simscan 1.4.0 ppid: 87528, pid: 87529, t: 0.0730s scanners: clamav: 0.98.1/m:55/d:19167 Received: from h-213.61.108.26.host.de.colt.net (HELO mail.telemotive.de) (213.61.108.26) by coyote.quickmin.net with SMTP; 7 Jul 2014 13:50:12 +0200 Received: from alderan.mit.telemotive.de ([10.96.96.15]) by mail.telemotive.de (Lotus Domino Release 8.5.3FP6HF107) with ESMTP id 2014070713501144-21012 ; Mon, 7 Jul 2014 13:50:11 +0200 Received: from rfietze.mit.telemotive.de (rfietze.mit.telemotive.de [10.96.97.33]) by alderan.mit.telemotive.de (Postfix) with ESMTP id 39114E7C08; Mon, 7 Jul 2014 13:50:12 +0200 (CEST) Received: by rfietze.mit.telemotive.de (Postfix, from userid 10062) id 2FA404F4; Mon, 7 Jul 2014 13:50:12 +0200 (CEST) From: Roman Fietze To: linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, Alessandro Zummo Subject: [rtc-linux] [PATCH 2/2] Allow to override the hctosys RTC using a kernel parameter Date: Mon, 07 Jul 2014 13:50:12 +0200 Message-ID: <2398890.hEQ05gdLB8@rfietze> Organization: Telemotive AG User-Agent: KMail/4.13.2 (Linux/3.11.10-17-default; KDE/4.13.2; x86_64; ; ) In-Reply-To: <5132579.sMfE4ssjXf@rfietze> References: <5132579.sMfE4ssjXf@rfietze> MIME-Version: 1.0 X-MIMETrack: Itemize by SMTP Server on muc/Telemotive(Release 8.5.3FP6HF107 | January 23, 2014) at 07.07.2014 13:50:11, Serialize by Router on muc/Telemotive(Release 8.5.3FP6HF107 | January 23, 2014) at 07.07.2014 13:50:11, Serialize complete at 07.07.2014 13:50:11 X-TNEFEvaluated: 1 X-Original-Sender: roman.fietze@telemotive.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: roman.fietze@telemotive.de does not designate permitted sender hosts) smtp.mail=roman.fietze@telemotive.de 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: , Hello list members, And here the second part. From e523006a34db26c274d3b71de5b914f476fb029e Mon Sep 17 00:00:00 2001 From: Roman Fietze Date: Fri, 4 Jul 2014 10:05:08 +0200 Subject: [PATCH 2/2] rtc: add kernel parameter hctosys, use it instead of CONFIG_RTC_HCTOSYS_DEVICE This change allows to overwrite the default of the hctosys RTC specified in the kernnel configuration by using a kernel parameter in the form of hctosys=rtc Signed-off-by: Roman Fietze --- Documentation/kernel-parameters.txt | 2 ++ drivers/rtc/class.c | 23 +++++++++++++++++++++-- drivers/rtc/hctosys.c | 4 ++-- drivers/rtc/rtc-sysfs.c | 2 +- drivers/rtc/systohc.c | 2 +- include/linux/rtc.h | 1 + 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 30a8ad0d..ab1672f 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -1110,6 +1110,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. hcl= [IA-64] SGI's Hardware Graph compatibility layer + hctosys= [RTC_HCTOSYS_DEVICE] Sets the hctosys RTC + hd= [EIDE] (E)IDE hard drive subsystem geometry Format: ,, diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 589351e..b39434d 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -34,7 +34,26 @@ static void rtc_device_release(struct device *dev) kfree(rtc); } + #ifdef CONFIG_RTC_HCTOSYS_DEVICE + +char rtc_hctosys_device[RTC_HCTOSYS_DEVICE_SIZE] = CONFIG_RTC_HCTOSYS_DEVICE; + +static int __init parse_hctosys(char *str) +{ + if (!str) + return -EINVAL; + + if (strlen(str) >= RTC_HCTOSYS_DEVICE_SIZE) + return -ENOMEM; + + strcpy(rtc_hctosys_device, str); + + return 0; +} + +__setup("hctosys=", parse_hctosys); + /* Result of the last RTC to system clock attempt. */ int rtc_hctosys_ret = -ENODEV; #endif @@ -57,7 +76,7 @@ static int rtc_suspend(struct device *dev) if (has_persistent_clock()) return 0; - if (strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE) != 0) + if (strcmp(dev_name(&rtc->dev), rtc_hctosys_device) != 0) return 0; /* snapshot the current RTC and system time at suspend*/ @@ -99,7 +118,7 @@ static int rtc_resume(struct device *dev) return 0; rtc_hctosys_ret = -ENODEV; - if (strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE) != 0) + if (strcmp(dev_name(&rtc->dev), rtc_hctosys_device) != 0) return 0; /* snapshot the current rtc and system time at resume */ diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c index 4aa60d7..ea79018 100644 --- a/drivers/rtc/hctosys.c +++ b/drivers/rtc/hctosys.c @@ -29,11 +29,11 @@ static int __init rtc_hctosys(void) struct timespec tv = { .tv_nsec = NSEC_PER_SEC >> 1, }; - struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); + struct rtc_device *rtc = rtc_class_open(rtc_hctosys_device); if (rtc == NULL) { pr_err("%s: unable to open rtc device (%s)\n", - __FILE__, CONFIG_RTC_HCTOSYS_DEVICE); + __FILE__, rtc_hctosys_device); goto err_open; } diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c index babd43b..69c6a9f 100644 --- a/drivers/rtc/rtc-sysfs.c +++ b/drivers/rtc/rtc-sysfs.c @@ -114,7 +114,7 @@ hctosys_show(struct device *dev, struct device_attribute *attr, char *buf) #ifdef CONFIG_RTC_HCTOSYS_DEVICE if (rtc_hctosys_ret == 0 && strcmp(dev_name(&to_rtc_device(dev)->dev), - CONFIG_RTC_HCTOSYS_DEVICE) == 0) + rtc_hctosys_device) == 0) return sprintf(buf, "1\n"); else #endif diff --git a/drivers/rtc/systohc.c b/drivers/rtc/systohc.c index bf3e242..db9e74a 100644 --- a/drivers/rtc/systohc.c +++ b/drivers/rtc/systohc.c @@ -31,7 +31,7 @@ int rtc_set_ntp_time(struct timespec now) else rtc_time_to_tm(now.tv_sec + 1, &tm); - rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); + rtc = rtc_class_open(rtc_hctosys_device); if (rtc) { /* rtc_hctosys exclusively uses UTC, so we call set_time here, * not set_mmss. */ diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 0a115b5..6feb68a 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -194,6 +194,7 @@ static inline bool is_leap_year(unsigned int year) #ifdef CONFIG_RTC_HCTOSYS_DEVICE #define RTC_HCTOSYS_DEVICE_SIZE 10 extern int rtc_hctosys_ret; +extern char rtc_hctosys_device[RTC_HCTOSYS_DEVICE_SIZE]; #else #define rtc_hctosys_ret -ENODEV #endif