From patchwork Wed Jun 8 09:21:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 69619 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2390717qgf; Wed, 8 Jun 2016 02:24:37 -0700 (PDT) X-Received: by 10.107.33.82 with SMTP id h79mr6514189ioh.10.1465377876984; Wed, 08 Jun 2016 02:24:36 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id w2si439348pay.144.2016.06.08.02.24.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jun 2016 02:24:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bAZhs-0000Bp-DR; Wed, 08 Jun 2016 09:23:24 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bAZgS-0007ET-Fd for linux-arm-kernel@lists.infradead.org; Wed, 08 Jun 2016 09:21:58 +0000 Received: by mail-wm0-x232.google.com with SMTP id r5so13971838wmr.0 for ; Wed, 08 Jun 2016 02:21:36 -0700 (PDT) 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; bh=Y21OFUBve9HF+2zozzNuW9juIimzRVydt8TK+AFeROA=; b=XncW2ZuFhLMmpswmuIBrNGWzxo0NNUWgMp2c0bWmnmEysXpbaxP7+ro7t/h78nNHUj ICGYx0pmXfCzxWOx+VF0aOl374meAup3xnGJqXMnxpV0ofQJMGXI/PCIAXaY6k1DcVny a5nqb8c+nZs7Gt84d3UYEx+Vri7jYU3c4HLHc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Y21OFUBve9HF+2zozzNuW9juIimzRVydt8TK+AFeROA=; b=HOsSN4lBg8boUeXeyb29jtq0rby401618EDxBVbQicF/J7FL6gohkzEGrF8ir3G7Fl Q4Wq0V+zyB6xNTaHbJN9Lh+iNpsb7TCV8AqmsLC0naiX2W4dB/3VL/JGm9shg6JSitQb NYxIOaREVuee7IHHsieiw/pXNUUsa/N9AgwtYq7RMTd5fok9QcrjxgOtTyordgds0U92 SkmlF+bQm6Xz2DEavFChNUIsJN+hYauI8qfIWzq6EU0ORTbjmq9iYm99NXwMcofXrNfz lrP5yAoqPJImKlFLuRUkN6XWycaAtgo4mY3VAlOVTtSRyJ+iFNwwmhL/Q++e0ys3z2jr 6ttA== X-Gm-Message-State: ALyK8tKliPYdVgRgWQILCMnxjRCpihQZcd1uU/0L0F6srQXDGkDQ1EFZCsOBtZ6XobFPaxX2 X-Received: by 10.194.221.137 with SMTP id qe9mr3906643wjc.21.1465377694818; Wed, 08 Jun 2016 02:21:34 -0700 (PDT) Received: from localhost.localdomain (host81-129-171-215.range81-129.btcentralplus.com. [81.129.171.215]) by smtp.gmail.com with ESMTPSA id g192sm23694494wme.15.2016.06.08.02.21.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jun 2016 02:21:34 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 10/20] pwm: sysfs: Add PWM Capture support Date: Wed, 8 Jun 2016 10:21:25 +0100 Message-Id: <20160608092135.21184-11-lee.jones@linaro.org> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160608092135.21184-1-lee.jones@linaro.org> References: <20160608092135.21184-1-lee.jones@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160608_022156_797518_E6298D47 X-CRM114-Status: GOOD ( 11.54 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:232 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, kernel@stlinux.com, devicetree@vger.kernel.org, patrice.chotard@st.com, robh+dt@kernel.org, thierry.reding@gmail.com, Lee Jones , maxime.coquelin@st.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Allow a user to read PWM Capture results from /sysfs. To start a capture and read the result, simply read the file: $ cat $PWMCHIP/capture The output format is ":". Signed-off-by: Lee Jones --- drivers/pwm/sysfs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) -- 2.8.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c index d985992..901e647 100644 --- a/drivers/pwm/sysfs.c +++ b/drivers/pwm/sysfs.c @@ -208,16 +208,33 @@ static ssize_t polarity_store(struct device *child, return ret ? : size; } +static ssize_t capture_show(struct device *child, + struct device_attribute *attr, + char *buf) +{ + struct pwm_device *pwm = child_to_pwm_device(child); + struct pwm_capture result; + int ret; + + ret = pwm_capture(pwm, &result, jiffies_to_msecs(HZ)); + if (ret) + return ret; + + return sprintf(buf, "%llu %llu\n", result.period, result.duty_cycle); +} + static DEVICE_ATTR_RW(period); static DEVICE_ATTR_RW(duty_cycle); static DEVICE_ATTR_RW(enable); static DEVICE_ATTR_RW(polarity); +static DEVICE_ATTR_RO(capture); static struct attribute *pwm_attrs[] = { &dev_attr_period.attr, &dev_attr_duty_cycle.attr, &dev_attr_enable.attr, &dev_attr_polarity.attr, + &dev_attr_capture.attr, NULL }; ATTRIBUTE_GROUPS(pwm);