From patchwork Thu Oct 5 18:13:30 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: 9987699 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 69DD2602B8 for ; Thu, 5 Oct 2017 18:13:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59D8628D26 for ; Thu, 5 Oct 2017 18:13:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DFD328D25; Thu, 5 Oct 2017 18:13:54 +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=unavailable 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 E179528D25 for ; Thu, 5 Oct 2017 18:13:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751906AbdJESNi (ORCPT ); Thu, 5 Oct 2017 14:13:38 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:38874 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751395AbdJESNh (ORCPT ); Thu, 5 Oct 2017 14:13:37 -0400 Received: by mail-qt0-f196.google.com with SMTP id o3so6275652qte.5; Thu, 05 Oct 2017 11:13:36 -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=ueDyf/rtYhGCAhWlZH6V8uh0pmAythFAP5hOCn2VZFs=; b=IdBm25OsE/1dXr988mB4SXlfbKCtompaOtxBGOYtrF1lFzobHNBO3Q112MMj4YcZaY YzhxhWzMDQdnaQJRrdFRQfoKh3BXLbQvfFqppcNXH2gdZEbS604UgzlnvIQcNgWYZgaK xj65T/Zz7tnK8vBPZC/Myj/hRUIsfuXMNRMTFqdjx+pkI77WgylvpksKs1SBOIhY032m EefD/dBsM/ofd8LlxrPW42J+PZIK0PYARu/Bdv0hKZBIMu+UnuUMRNIPbcotnLgjCmTD XAnpWybrcUpKb4kSsMDZ4ZevCFXUSJwRfszZOMAibgmzw3nqJ6OihiiOFX7lwVDpqSR+ FQsA== 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=ueDyf/rtYhGCAhWlZH6V8uh0pmAythFAP5hOCn2VZFs=; b=Li9mfpRisBnGxN7SPzN7vAX2MyQeg1OF0e6BL5Te0gsnoA382nOAOl4I90rsrQbSlx WUXc/d6yu05X15hvLlqtl9wOViOjpGMxICseXty1LQXdrkVFiPUoEU91GelRKaQcWWge t9E4DXBU07h8bQzj4+zx9zWyeIyWtPwVWO7C6XwCBk0BXrinFSjmgDWihHtuzbu8Q72g o1R5MUeWyiYXijTEfon2sXArNRTSNUe8uputiInaWJpJLw4USMTwQywFeDmthK1R5hGu jYIcN0ebo0lExCi05tu/3lByrme+up3k9Npv2iewEZ3ipNTcKtDXsXZu9FNQZaNGsI/p rzPQ== X-Gm-Message-State: AMCzsaUoNSMEuCP/msclbNrUzCsHNjpTEDWDVwwe4KdZjoCND4H4I7Yf q+CmvPwXEvkzHrYu5+ArG+4= X-Google-Smtp-Source: AOwi7QD2cMsfi8sQwU03kEqjKLIE2NmBFhDiMYMrQziAJD5M86M6VS17SRP/2MWPi1GXYEVTw9947w== X-Received: by 10.37.132.73 with SMTP id r9mr7345596ybm.165.1507227216402; Thu, 05 Oct 2017 11:13:36 -0700 (PDT) Received: from localhost (72-188-97-40.res.bhn.net. [72.188.97.40]) by smtp.gmail.com with ESMTPSA id a6sm389744ywe.47.2017.10.05.11.13.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 11:13:35 -0700 (PDT) From: William Breathitt Gray To: jic23@kernel.org, benjamin.gaignard@linaro.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 v3 1/6] iio: Implement counter channel specification and IIO_SIGNAL constant Date: Thu, 5 Oct 2017 14:13:30 -0400 Message-Id: <14129e5a8b64502496690bf9743888ab67dc4e8c.1507220144.git.vilhelm.gray@gmail.com> 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 50cae8504256..9f949dd74b60 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 {