From patchwork Tue Jan 2 05:10:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 123091 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8567243qgn; Mon, 1 Jan 2018 21:10:50 -0800 (PST) X-Google-Smtp-Source: ACJfBovLzkuXB6Cv9fbbUgapT7Wd7W8vJBh05VYGSSD0riDZ/XP0Yx+4a/e/DEUC+PNdUkhvYMHg X-Received: by 10.99.61.67 with SMTP id k64mr38799763pga.421.1514869850819; Mon, 01 Jan 2018 21:10:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514869850; cv=none; d=google.com; s=arc-20160816; b=cdFJP6k9hU6xRzL2qANG/IFU88BDcT5c9irKVlSTuG2iZb9f5xxGlax9YMHbX0WEx/ hKoXfZHdvVrzjNdOuT0jQMR5JTFnfk/iKTiCtbDT6zanL/c2Kq7bnFowf11h/ebDVrYp cd4rD3wzSEuq/kYKqegbNMQnQJTwY4Ywquql0mf13rE/qw15I+OHthJKdTSZzelf5qGD zlTefvmMip66e31o544fxC3TnPP8Aqekifwiui0mT10c+5XKx+7pcbTDQRnHkkZQjy71 k0+9NTL32Ye6GN2MK1LAhiyDbzTMIIY18xHX3tiOWAdg5eXVeiQ9nugSr8pHgKRTiSrZ XVwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=lTo38F1iaDK9ShkX7uHgWhIP4pdpecg189FrZlfTXUw=; b=lbkqaw9FN/pgASehyM+ZbKb0BIXia6FuuKeggEh24LiL4PpGKJrgZEt6fQr4590T/4 BuoNz95NyEnXu5yucpsPBc8LCKNQDNRW6BlNIj4wwo22k4jgcziRTA46kGlP94E1rFoc Zmb9s9rt5Zv+xwRWQGuOtQGz4R0axBdxr21iyphdrjWJtwhPY1sItBgvUztoXVzgmFAW 9T9RJnsMsjBjA+CQ3P6t7EIIA90/G4VlLCG/lOjeb+d10P1IAWTiDSJ413B+T4yJuQxY XSd9UZuNNMtH/q4/wpP+etYCCzIDZ5dP15ug7CO2mhY/WJtdpovulZs7hcnm2nFlpttY WYCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kI4xeHHg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y11si27541101plg.702.2018.01.01.21.10.50; Mon, 01 Jan 2018 21:10:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kI4xeHHg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751503AbeABFKf (ORCPT + 28 others); Tue, 2 Jan 2018 00:10:35 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:40782 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751435AbeABFKc (ORCPT ); Tue, 2 Jan 2018 00:10:32 -0500 Received: by mail-pg0-f67.google.com with SMTP id q12so6967517pgt.7 for ; Mon, 01 Jan 2018 21:10:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=lTo38F1iaDK9ShkX7uHgWhIP4pdpecg189FrZlfTXUw=; b=kI4xeHHgZZKVofVFE7Qf6QxwymOICx5rA75pMZERuet3CsJ9NvYISvyNFKRwXCFX+3 O285WXeAPP4RajuEVWLNHdN7IE+VULsjCrGM91v+X3XdcZ9UaIBC0IdNXjeK5JyhVKIQ RWoezQwWDk31s4aX0pW81GfV4bn+kNoRKowJA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=lTo38F1iaDK9ShkX7uHgWhIP4pdpecg189FrZlfTXUw=; b=PI9uKqofCMYwOhwbuxArxd4MCEqRLI1ds6ZcELAQIXGrzr9BYd16uHF6ZLuOtBbW/r hcNSwz61XLlHTQBWsa1yJ9bC10TLt39NOMYEIyIByyeFOxaCi1U3ehZmRQ0N5TdiP5RJ ClYd3R+S0Wk4yNXSdwAZVe9JDgCeZ+zWurdA6RJLkrqXHV0cdK1iNbUe6sXqRE2Z2lmT rvrfpwllSBnUwcvrPTY8ZZg9VK5htmelku4mrt6T5YRXnrFtJa0YJM5KFp2hCHZm4YNp IQrTLwCOdoKrKALq21ZBt1udY99xJZWXjSS7olpUvseiHXXNgOMSlj4dBk9iUfAMaNkX BvLQ== X-Gm-Message-State: AKGB3mIwbnnX804fiH1ixUgaN0bHv2abyuPJt2SXW8Gqe6UX2iuzXj5o X///zRVFCqM1w4DmF0Y9xQL0YQ== X-Received: by 10.101.88.206 with SMTP id e14mr26460102pgu.216.1514869831533; Mon, 01 Jan 2018 21:10:31 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 6sm63989675pgf.54.2018.01.01.21.10.29 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jan 2018 21:10:31 -0800 (PST) From: Baolin Wang To: a.zummo@towertech.it, alexandre.belloni@free-electrons.com, corbet@lwn.net Cc: arnd@arndb.de, broonie@kernel.org, linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, baolin.wang@linaro.org Subject: [RFC PATCH 2/4] rtc: sysfs: Export the valid range supported by RTC hardware Date: Tue, 2 Jan 2018 13:10:06 +0800 Message-Id: <2f0fb91c39534ecc2e94148a1a6998ba32ab90cf.1514869622.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <9ab56bdcaeb52241e22b738d6babe7b01728f64c.1514869621.git.baolin.wang@linaro.org> References: <9ab56bdcaeb52241e22b738d6babe7b01728f64c.1514869621.git.baolin.wang@linaro.org> In-Reply-To: <9ab56bdcaeb52241e22b738d6babe7b01728f64c.1514869621.git.baolin.wang@linaro.org> References: <9ab56bdcaeb52241e22b738d6babe7b01728f64c.1514869621.git.baolin.wang@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We have introduced one interface to get the RTC range, so this patch exports the valid range supported by RTC hardware to userspace. Signed-off-by: Baolin Wang --- Documentation/rtc.txt | 2 ++ drivers/rtc/rtc-sysfs.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) -- 1.7.9.5 diff --git a/Documentation/rtc.txt b/Documentation/rtc.txt index c0c9774..4fe437b 100644 --- a/Documentation/rtc.txt +++ b/Documentation/rtc.txt @@ -164,6 +164,8 @@ offset The amount which the rtc clock has been adjusted in firmware. which are added to or removed from the rtc's base clock per billion ticks. A positive value makes a day pass more slowly, longer, and a negative value makes a day pass more quickly. +range_max The maximum time values in seconds supported by RTC hardware. +range_min The minimum time values in seconds supported by RTC hardware. */nvmem The non volatile storage exported as a raw file, as described in Documentation/nvmem/nvmem.txt ================ ============================================================== diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c index 92ff2ed..60e1f6c 100644 --- a/drivers/rtc/rtc-sysfs.c +++ b/drivers/rtc/rtc-sysfs.c @@ -248,6 +248,34 @@ } static DEVICE_ATTR_RW(offset); +static ssize_t +range_max_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + ssize_t retval; + time64_t max_hw_secs, min_hw_secs; + + retval = rtc_read_range(to_rtc_device(dev), &max_hw_secs, &min_hw_secs); + if (retval == 0) + retval = sprintf(buf, "%lld\n", max_hw_secs); + + return retval; +} +static DEVICE_ATTR_RO(range_max); + +static ssize_t +range_min_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + ssize_t retval; + time64_t max_hw_secs, min_hw_secs; + + retval = rtc_read_range(to_rtc_device(dev), &max_hw_secs, &min_hw_secs); + if (retval == 0) + retval = sprintf(buf, "%lld\n", min_hw_secs); + + return retval; +} +static DEVICE_ATTR_RO(range_min); + static struct attribute *rtc_attrs[] = { &dev_attr_name.attr, &dev_attr_date.attr, @@ -257,6 +285,8 @@ &dev_attr_hctosys.attr, &dev_attr_wakealarm.attr, &dev_attr_offset.attr, + &dev_attr_range_max.attr, + &dev_attr_range_min.attr, NULL, };