From patchwork Mon Aug 9 12:37:25 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: 12426383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEB28C4338F for ; Mon, 9 Aug 2021 12:40:25 +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 9D17B60F38 for ; Mon, 9 Aug 2021 12:40:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9D17B60F38 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=nN9bN5uk3c4OhkZ3DnJvvEpVQOLQV5SCyV2sKygbtn8=; b=QyvopJ/r7OYNQD 1SjLIxABWoGTe/JyJ1J9mG2kAAmZajdrV9BaiO2ekKewROIZlFsYnQ8xCz6pHYtX+0jEN3oMMq8/n sHddbMt0s5MPn5p/va1n8YXlwBI88d2iUthagaqa85pJgjaLVNrCWRtMvus9vuMlzclRnF1nHuBwk 7B6PP+2uoavYN4wcaRrC26RwWbEPNviRuU+Uw3s6FcXf9C500K5mHGri2ni8oYy5bF5XAllONuN1a MWXKlIZpbqT7G9UACDxc+VH4xoHPGyc/WlVXaVJeJLYZWsw8OrSB/VqIHC6O6z1UognqTs163WaJ4 A60hRWvh/D8/UBnU8SYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mD4XW-000Ykm-HE; Mon, 09 Aug 2021 12:37:58 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mD4XS-000Yjs-LC for linux-arm-kernel@lists.infradead.org; Mon, 09 Aug 2021 12:37:56 +0000 Received: by mail-pj1-x1029.google.com with SMTP id bo18so5642751pjb.0 for ; Mon, 09 Aug 2021 05:37:53 -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:mime-version :content-transfer-encoding; bh=SRRfOMGRdWmSmqR/jCwDTPGfm5oA2KrQYIknx7HPYGM=; b=I02Ftysn1jyRMA2SJeLr+43VRYWurwqgoEHDJmLgc1b1Bd0xeN53XOIO9KbKJr9Yfi Dk7wx7icdBf8R9qnHBk3xNey7IMzRYLbggFRZNTbiL8HhqPNw6KT789G43ca4XxfaKxT KEMQHvo8riJOkZAwS+gskQLWsGhlCjCWTJKw8ix3nn8YR6mUd80sm/Jc6Kx2rCWXAoHt +nhO5BJabIqH9RS952X36lHKN6WISl/Wire8zRq8iy/Iud9RX+V3IiTHdBDFlrg+Gfa8 dOLTjfR79K5QngmF9PGd3kVrgV993G4v+kH65wrzKdivXYj8rHZaWYZ0oq336p/AyUIm joqg== 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:mime-version :content-transfer-encoding; bh=SRRfOMGRdWmSmqR/jCwDTPGfm5oA2KrQYIknx7HPYGM=; b=PRtFBKDcKOSsUaAvJquJTJG2aSdxuNI9ocG3mop4oG9DBiqJC76iDSCpUTfbUs+2IR boRJPLF4kX+/0U4CdaWF2z/qlrfqO07WKXY1E3jWlIuzMhBXcks6OXaNsZTeGuAKgKj2 diiuwo1QRvinJ8X+d6cV9kWiZGbvXPi2QkpOHgrYunZYdKVx7ezOI6XabONnjREz1pdf WQSCHufkQaMuWDfiWbeCD0wrPtJmovBXQb1vtvOEi0LhneN03nO4VB0jZMytiYr2pqm6 XotejsC3fo7uQsu98MPAA8NOjfTMCVezGYYOUm1OBqojJzxqeU564Qo0JFmA2odX13p8 5o2Q== X-Gm-Message-State: AOAM532PYE7PWatvP4QjsPVElkLl052I8sCDoTGIDOfHYWqBoAsKUWz+ LGoQ8/8AUf8Qr01teSITZJI= X-Google-Smtp-Source: ABdhPJzZQp34WPlUWoCcv5TWsKqOi0aBXJs0mxrtXU6YexojYGaftCiT8EJK3MwGkNBMYo1lUU97Rg== X-Received: by 2002:a05:6a00:bd3:b029:3c6:9c64:9771 with SMTP id x19-20020a056a000bd3b02903c69c649771mr23237597pfu.78.1628512673418; Mon, 09 Aug 2021 05:37:53 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id e35sm22382177pjk.28.2021.08.09.05.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 05:37:52 -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 v15 00/13] Introduce the Counter character device interface Date: Mon, 9 Aug 2021 21:37:25 +0900 Message-Id: X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210809_053754_743094_05BABB49 X-CRM114-Status: GOOD ( 18.58 ) 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 v15: - Move the description for the member 'lock' in the 'quad8' structure as a separate patch - Reorganize the "counter: Internalize sysfs interface code" patch to not call chrdev code; respective code moved to the "counter: Add character device interface" patch with the other chrdev code - Custom enums removed from the ftm-quaddec.c, stm32-lptimer-cnt.c, and stm32-timer-cnt.c files; respective drivers refactored to use the COUNTER_FUNCTION_* and COUNTER_SYNAPSE_* enum constants instead For convenience, this patchset is also available on my personal git repo: https://gitlab.com/vilhelmgray/iio/-/tree/counter_chrdev_v15 The patches preceding "counter: Internalize sysfs interface code" are primarily cleanup and fixes that can be picked up and applied now to the IIO tree if so desired. The "counter: Internalize sysfs interface code" patch as well may be considered for pickup because it is relatively safe and makes no changes to the userspace interface. To summarize the main points of this patchset: there are no changes to the existing Counter sysfs userspace interface; 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 (13): counter: 104-quad-8: Describe member 'lock' in 'quad8' counter: Internalize sysfs interface code counter: Update counter.h comments to reflect sysfs internalization docs: counter: Update to reflect sysfs internalization 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 | 38 +- Documentation/driver-api/generic-counter.rst | 358 +++- .../userspace-api/ioctl/ioctl-number.rst | 1 + MAINTAINERS | 3 +- drivers/counter/104-quad-8.c | 700 ++++---- drivers/counter/Kconfig | 6 +- drivers/counter/Makefile | 1 + drivers/counter/counter-chrdev.c | 553 ++++++ drivers/counter/counter-chrdev.h | 14 + drivers/counter/counter-core.c | 191 +++ drivers/counter/counter-sysfs.c | 962 +++++++++++ drivers/counter/counter-sysfs.h | 13 + drivers/counter/counter.c | 1496 ----------------- drivers/counter/ftm-quaddec.c | 60 +- drivers/counter/intel-qep.c | 144 +- drivers/counter/interrupt-cnt.c | 62 +- drivers/counter/microchip-tcb-capture.c | 91 +- drivers/counter/stm32-lptimer-cnt.c | 226 +-- drivers/counter/stm32-timer-cnt.c | 179 +- drivers/counter/ti-eqep.c | 180 +- include/linux/counter.h | 715 ++++---- include/linux/counter_enum.h | 45 - include/uapi/linux/counter.h | 154 ++ tools/Makefile | 13 +- tools/counter/Build | 1 + tools/counter/Makefile | 53 + tools/counter/counter_example.c | 93 + 27 files changed, 3568 insertions(+), 2784 deletions(-) create mode 100644 drivers/counter/counter-chrdev.c create mode 100644 drivers/counter/counter-chrdev.h create mode 100644 drivers/counter/counter-core.c create mode 100644 drivers/counter/counter-sysfs.c create mode 100644 drivers/counter/counter-sysfs.h delete mode 100644 drivers/counter/counter.c delete mode 100644 include/linux/counter_enum.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: c886885336b0b5f1a08ce580f7201a2ca30ab041 prerequisite-patch-id: 8ca55ffcdd5d060dd5fa2b4dd50bf01dc1026da6 prerequisite-patch-id: 46ef2668ca6bdc0d08dd488fe1d2b886189a5652 prerequisite-patch-id: 2df1946c917d6408148306db30a071e67b00ad73 prerequisite-patch-id: f81579f50552e6041a95403cc743c5f36962b111 prerequisite-patch-id: 8a6860e75cdec162812c56dc39c5d7fc6fc5154e