From patchwork Mon Sep 25 18:08:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 9970267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AADB560225 for ; Mon, 25 Sep 2017 18:08:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D4B628D30 for ; Mon, 25 Sep 2017 18:08:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 923A328D52; Mon, 25 Sep 2017 18:08:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 909B928D25 for ; Mon, 25 Sep 2017 18:08:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935665AbdIYSIX (ORCPT ); Mon, 25 Sep 2017 14:08:23 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:36790 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935653AbdIYSIV (ORCPT ); Mon, 25 Sep 2017 14:08:21 -0400 Received: by mail-yw0-f194.google.com with SMTP id r85so3837647ywg.3; Mon, 25 Sep 2017 11:08:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U4rJAnibd6rDQX0TPv5V541Q5nqH2DKOQ+HkAOg/c0M=; b=bZfCzgLTGp0XILk5eVrNmbDdxfKfgdPs6BiBc/vULGK4FNLUGFFiRvhuYRguDPvXHY WBKMuQD4gtwc+PTJmo0l62E5VtDueI6LLZZKdcNwp3T/hbNL4JJrQfcaNqbnirlxvX+b iFMcr9HcgtNc9RB2shfsqFvytbLs30HNRr7sucCd35EehPUubjKx81HMVhq+O1BWe8IT lHGitD/9rJ3Mr1vUgXGhbqS0TD7Z/SCLJw2JWsAmNdDnX0CmRo4R9k/uX4Wshj8eYSmV HkWSV/JZMp8P9MMMt05arnCSyGsJXO5j8hFWeJtsWGvn4hPgSdSl6On8kkjvCKGIOZ7t qLJw== 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; bh=U4rJAnibd6rDQX0TPv5V541Q5nqH2DKOQ+HkAOg/c0M=; b=cJEB83gLduMQp+uz80LAmz3J28FYYgK0sPONoMkE+PlT1TlUX1HXUjofCBy7EKyWNx lEB18nkLOcRCTZtt2PKXTjWqFZRkd0MkNS7AeMVKnSrjdmW03T9bFRL6ESmmZGcBGm/P r9ME6bM6wVszF/dyr6PsjN1r+gtuN9G9SxsvFXTNFRZA3wIbJGFXil8isvmi8lK9DKCe N5HTsVGt7bpkj8di/9iTLQ+Z3NTcp+lJ1aw8z6BLoErplWTqXGGj2Dae5qqAVp0jh7yS 2wMr5vIJ05hm6TDatsWk95hC0Jaawd+SI9SLsll7UR7JZpSDA8VoBewf+O8EOxbhdzw1 zDNA== X-Gm-Message-State: AHPjjUjFS+Qig6fPcdL28uchik7w0M31RhzjWvnPOE0O2VGZnn0xeE0B 6uwZqLMAG8L0s/Oe9hUKaO8= X-Google-Smtp-Source: AOwi7QBQeIP0727E5DtrfLG4cFvJz2JgKI/9m97LyzsJf/CDa8IF8wlXdrJXT9I2+HIMQDTBU7yKLQ== X-Received: by 10.129.136.67 with SMTP id y64mr4887639ywf.55.1506362900817; Mon, 25 Sep 2017 11:08:20 -0700 (PDT) Received: from localhost (72-188-97-40.res.bhn.net. [72.188.97.40]) by smtp.gmail.com with ESMTPSA id t206sm2839186ywc.95.2017.09.25.11.08.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Sep 2017 11:08:20 -0700 (PDT) From: William Breathitt Gray To: benjamin.gaignard@linaro.org, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, William Breathitt Gray Subject: [PATCH v2 1/5] iio: Implement counter channel specification and IIO_SIGNAL constant Date: Mon, 25 Sep 2017 14:08:14 -0400 Message-Id: X-Mailer: git-send-email 2.14.1 In-Reply-To: References: Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Counters are IIO devices that are exposed via a generic counter interface consisting of one or more counter signals (IIO_SIGNAL) linked to one or more counter values (IIO_COUNT). This patch introduces the IIO_SIGNAL constant which represents a counter device signal line. Additionally, a new "counter" member is added to struct iio_chan_spec, with relevant support, to indicate that a channel is part of a counter. Signed-off-by: William Breathitt Gray --- drivers/iio/industrialio-core.c | 14 +++++++++++++- include/linux/iio/iio.h | 2 ++ include/uapi/linux/iio/types.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 7a5aa127c52e..ee508f2070a7 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -85,6 +85,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_COUNT] = "count", [IIO_INDEX] = "index", [IIO_GRAVITY] = "gravity", + [IIO_SIGNAL] = "signal", }; static const char * const iio_modifier_names[] = { @@ -989,7 +990,18 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, break; case IIO_SEPARATE: - if (chan->indexed) + if (chan->counter) { + if (!chan->indexed) { + WARN(1, "Counter channels must be indexed\n"); + ret = -EINVAL; + goto error_free_full_postfix; + } + name = kasprintf(GFP_KERNEL, "%s%d-%d_%s", + iio_chan_type_name_spec[chan->type], + chan->channel, + chan->channel2, + full_postfix); + } else if (chan->indexed) name = kasprintf(GFP_KERNEL, "%s_%s%d_%s", iio_direction[chan->output], iio_chan_type_name_spec[chan->type], diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 486ffbb1a926..de4dc2a0e4e3 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -263,6 +263,7 @@ struct iio_event_spec { * attributes but not for event codes. * @output: Channel is output. * @differential: Channel is differential. + * @counter: Channel is part of a counter. */ struct iio_chan_spec { enum iio_chan_type type; @@ -295,6 +296,7 @@ struct iio_chan_spec { unsigned indexed:1; unsigned output:1; unsigned differential:1; + unsigned counter:1; }; diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h index ffafd6c25a48..313899652ca7 100644 --- a/include/uapi/linux/iio/types.h +++ b/include/uapi/linux/iio/types.h @@ -43,6 +43,7 @@ enum iio_chan_type { IIO_COUNT, IIO_INDEX, IIO_GRAVITY, + IIO_SIGNAL, }; enum iio_modifier {