From patchwork Wed Sep 29 03:15:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 12524495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAFDFC433EF for ; Wed, 29 Sep 2021 03:19:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 968EB6138F for ; Wed, 29 Sep 2021 03:19:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 968EB6138F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=WhoY8Xy1mByCNjoHg921YcmrTNMRfnaZFHFNLk64Icw=; b=dbmTUiPhkRVaYr tCBKLGah0EtppG++jYkACkWq6rNppCagby+lmdagHK+sNA+glNQx1/0wHnTRTMdvtxTUxm118jcKq JQjN22mB8EA64au3bs1S7ByCqHbUgTqTg255OVjc+4p5ylFnsQu5g2U44R1GU4jlgpo6YA8o9dNS7 kc0kxg+1lQcZhqEaq88oOwKut/OVX6YLL+/0SUaZx5T0DFHOMZIACSJmz8N4LEsRqazUU4O+7z6sZ S7aJvd6kAEJIUW9AzFdGAp49y10ROe791Nwxcor9sMlbYnZZOsK2oEbLrdhAWjnGdNYdr5MqoMzHc mBam5q1vqmlRWco7JrQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVQ5A-009kds-JG; Wed, 29 Sep 2021 03:16:32 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVQ56-009kcw-E8 for linux-arm-kernel@lists.infradead.org; Wed, 29 Sep 2021 03:16:30 +0000 Received: by mail-pf1-x42e.google.com with SMTP id g2so754454pfc.6 for ; Tue, 28 Sep 2021 20:16:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nU8NjFcHiQb2juc6iNrXx4yBJlrwbry86U2d9RYhoEc=; b=ea9XZQK839csHLMExTfIPXgY4B/YhV0ikwP4KLbKfdTb1LxOXTjjd0FVIUV/iIJWtZ Lp5uwzTHdT025gACEWTVCKrIqCotGjaBLQ2fdEw97UKlIqGfhBxF8mpgRoTfseMak8EI Pii6a5Q8dYw9f4vuaUYTjBrqxpCrN9H+dPa2rYDVJqnlspqTa1hi5LRVIIcO1OQOY/J2 /sWp0UxttFYUMYY44ACDYqPLL00wDoi1wzuhxoc4UWCUsV8jk6DYJM+a97gNnoZktkwd pIquPCHLds98CRSIZoF668JVQX5NqZQ0i+EenkdwUmfiTCZ3MPavZwYbvxGcClk+dYcZ /mNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nU8NjFcHiQb2juc6iNrXx4yBJlrwbry86U2d9RYhoEc=; b=hw/yQBvQeW7GHFkd0s4pM1xajH9rsJXomLHROT0xOwknDijZ/C6CQx7W1a5OJqGRu5 aa65Zf4LgbVh+UNDWYOqRYOkdRCztEyM1QmqBBLSf3o8fcV5JdDgW3fDLBEXWqKIvNGN cBdBogfejtiM7Fcq1BJxen+fwaux33UquX4a3Hwz6GFyl9/XJUHxlifIiKsC7/rcyQSs 9dHMo5JPtOdXVjhPvZMLviXxkcdC4x6bgWfiWz6PqIABWcpmAPMYNshb2yEp0DGdWuHp o0tMBANjrlCWfRRMYWxe3eY60tC+tlQ4IbxqDngAWt24F5hnKZOeXEGDB6/JR8G5rpkf 1CFQ== X-Gm-Message-State: AOAM531Oro9V3RfvCQ0E+PxEwu4jR8+nwfJMWjRIUJwxIAb3loLtSavQ JxH9VlqfNL8H8gqNzJYKHtCYw4Mg9Ds= X-Google-Smtp-Source: ABdhPJypHhopEVNS9JguXT5SH+XWxunhd/Pyg0tmBrjCHDWxgUIykr9qaW8Y1Ww9rfYyZjTNTWu8AA== X-Received: by 2002:a63:e057:: with SMTP id n23mr7793886pgj.183.1632885386999; Tue, 28 Sep 2021 20:16:26 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id 65sm464203pfv.210.2021.09.28.20.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 20:16:26 -0700 (PDT) From: William Breathitt Gray To: jic23@kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, kernel@pengutronix.de, a.fatoum@pengutronix.de, kamel.bouhara@bootlin.com, gwendal@chromium.org, alexandre.belloni@bootlin.com, david@lechnology.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, syednwaris@gmail.com, patrick.havelange@essensium.com, fabrice.gasnier@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, o.rempel@pengutronix.de, jarkko.nikula@linux.intel.com, William Breathitt Gray Subject: [PATCH v17 0/9] Introduce the Counter character device interface Date: Wed, 29 Sep 2021 12:15:57 +0900 Message-Id: X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210928_201628_499975_5081D1ED X-CRM114-Status: GOOD ( 15.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Changes in v17: - A couple minor improvements to documentation from review suggestions - chrdev_lock redeclared as atomic_t; BITMAP was not necessary because chrdev_lock is a single flag - test_and_set_bit_lock(), clear_bit_unlock(), and clear_bit(), replaced respectively with atomic_add_unless(), atomic_dec(), and atomic_set() - counter_comp_read_is_equal() and counter_comp_read_is_set() macros implemented in order to properly test counter_comp structures' read callback states - counter_sysfs_add() call performed before counter_chrdev_add() call in counter_register() in order to match unwinding sequence - for-loop utilized in counter-example.c in order to simplify code - counter-example.c returns 1 on error instead of -errno; errno may be modified after a subsequent library call so we can't depend on it For convenience, this patchset is also available on my personal git repo: https://gitlab.com/vilhelmgray/iio/-/tree/counter_chrdev_v17 A Counter character device interface is introduced that allows Counter events and associated data to be read() by userspace; the events_configure() and watch_validate() driver callbacks are introduced to support Counter events; and IRQ support is added to the 104-QUAD-8 driver, serving as an example of how to support the new Counter events functionality. William Breathitt Gray (9): counter: Move counter enums to uapi header counter: Add character device interface docs: counter: Document character device interface tools/counter: Create Counter tools counter: Implement signalZ_action_component_id sysfs attribute counter: Implement *_component_id sysfs attributes counter: Implement events_queue_size sysfs attribute counter: 104-quad-8: Replace mutex with spinlock counter: 104-quad-8: Add IRQ support for the ACCES 104-QUAD-8 Documentation/ABI/testing/sysfs-bus-counter | 29 + Documentation/driver-api/generic-counter.rst | 177 ++++-- .../userspace-api/ioctl/ioctl-number.rst | 1 + MAINTAINERS | 2 + drivers/counter/104-quad-8.c | 256 ++++++-- drivers/counter/Kconfig | 6 +- drivers/counter/Makefile | 2 +- drivers/counter/counter-chrdev.c | 578 ++++++++++++++++++ drivers/counter/counter-chrdev.h | 14 + drivers/counter/counter-core.c | 56 +- drivers/counter/counter-sysfs.c | 123 +++- include/linux/counter.h | 98 +-- include/uapi/linux/counter.h | 154 +++++ tools/Makefile | 13 +- tools/counter/Build | 1 + tools/counter/Makefile | 53 ++ tools/counter/counter_example.c | 92 +++ 17 files changed, 1509 insertions(+), 146 deletions(-) create mode 100644 drivers/counter/counter-chrdev.c create mode 100644 drivers/counter/counter-chrdev.h create mode 100644 include/uapi/linux/counter.h create mode 100644 tools/counter/Build create mode 100644 tools/counter/Makefile create mode 100644 tools/counter/counter_example.c base-commit: a5ae0cfd53aaf031c2e9ba048281776fa67047c2