From patchwork Tue Mar 9 13:19:14 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: 12125111 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 0F1E7C433E0 for ; Tue, 9 Mar 2021 13:20:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B25CB650E6 for ; Tue, 9 Mar 2021 13:20:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230421AbhCINUX (ORCPT ); Tue, 9 Mar 2021 08:20:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbhCINUR (ORCPT ); Tue, 9 Mar 2021 08:20:17 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE7AAC06174A; Tue, 9 Mar 2021 05:20:17 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id w7so3062726pll.8; Tue, 09 Mar 2021 05:20:17 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=3mig/qMjkMKBLNQDSOdz3dnToagqjo5qKVAJFH1PTbE=; b=P21hPd7HwfCd++bVOSHd3P9PkdIzmKQntfngASpmzxuTA5WQnuO2G/Dq8Rm/QB+J34 cAPgq+MIqIZzuJHW3NI3cgMOhZY7pqdyQK6rTmZkfu89X6bhf7wQFgig2TzUJchP2m2D +zYyP1x0G6MVNBrJDJARKrB0yGrTICjt0DAC2LoyvIiSbbwWqw+BLh9NXXT47P0T2GCp yXjW4Lq1psi9Tww5fPW7w9vt10eCxHoc+Cd0VKsI0KTCKmf71i0UgSlhNtup8v88kcfr LAj5UChs8nijJh+Yiy7fxrAJI6MUiX+SrTpthrbLqui7QyMOOxnj9sNbfpJ4HvWVoIh4 jbtw== 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:mime-version:content-transfer-encoding; bh=3mig/qMjkMKBLNQDSOdz3dnToagqjo5qKVAJFH1PTbE=; b=GRSTppG/9nOB1+k0wwDJj2RI6P/IAiYbt/FBlTWpQkBPUrpuiK3mY5toeqGhyGBmXI sXHHJHWHyCC02TNU1JcP1PAIWkici98Hvmru0jiIFQf5KU+3dz05oH1yjbRhGxUAId30 gLbDcQpSw0tdDficnPQXfwkgaT8gE68y+H8UZbYSXQHn+EKwUQWKBkTpp+sIIuVN6zCj +FiqwG0jA4H4yTt+Z0Zv2ITgZhDjfSiNoKl9GhqwHYRz4J3YmlKEWXSWJZPEPdAKl8w/ t7JMy4X3G1/2WVnjtsfsgTys5OsYNiwgxj5WqRj8TxJxYBXWgcfANxo7fsLBOFHzwXbX /yYw== X-Gm-Message-State: AOAM532eC8H5RDT6zzUaO3hZ2fI/LO18Xz+bmIe9OY6WUNsOzTcHL+jL 7Ha8U6zJiuU4+05SaPvAm3U= X-Google-Smtp-Source: ABdhPJxhpQPkkPnebX+jR7TlCTiQdHhK+YUGpumv+L9adw1292UXwvsh9ht+O0l3BMMMQ9EuOLZfhA== X-Received: by 2002:a17:90b:e95:: with SMTP id fv21mr4566784pjb.217.1615296017193; Tue, 09 Mar 2021 05:20:17 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.20.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:20:16 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 01/33] docs: counter: Consolidate Counter sysfs attributes documentation Date: Tue, 9 Mar 2021 22:19:14 +0900 Message-Id: <45c91b52199539ad2bc14990f02499ee05f7ccc9.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Duplicate ABIs are not valid, so let's consolidate these sysfs attributes into the main sysfs-bus-counter documentation file. Cc: Patrick Havelange Reviewed-by: David Lechner Signed-off-by: William Breathitt Gray --- Documentation/ABI/testing/sysfs-bus-counter | 76 ++++++++++++++++++- .../ABI/testing/sysfs-bus-counter-104-quad-8 | 61 --------------- .../ABI/testing/sysfs-bus-counter-ftm-quaddec | 16 ---- MAINTAINERS | 4 +- 4 files changed, 75 insertions(+), 82 deletions(-) delete mode 100644 Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 delete mode 100644 Documentation/ABI/testing/sysfs-bus-counter-ftm-quaddec diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter index 566bd99fe0a5..29f54484183f 100644 --- a/Documentation/ABI/testing/sysfs-bus-counter +++ b/Documentation/ABI/testing/sysfs-bus-counter @@ -57,6 +57,7 @@ Description: What: /sys/bus/counter/devices/counterX/countY/count_mode_available What: /sys/bus/counter/devices/counterX/countY/error_noise_available What: /sys/bus/counter/devices/counterX/countY/function_available +What: /sys/bus/counter/devices/counterX/countY/prescaler_available What: /sys/bus/counter/devices/counterX/countY/signalZ_action_available KernelVersion: 5.2 Contact: linux-iio@vger.kernel.org @@ -154,6 +155,15 @@ Description: Count Y. If possible, this should match the name of the respective channel as it appears in the device datasheet. +What: /sys/bus/counter/devices/counterX/countY/prescaler +KernelVersion: 5.2 +Contact: linux-iio@vger.kernel.org +Description: + Configure the prescaler value associated with Count Y. + On the FlexTimer, the counter clock source passes through a + prescaler (i.e. a counter). This acts like a clock + divider. + What: /sys/bus/counter/devices/counterX/countY/preset KernelVersion: 5.2 Contact: linux-iio@vger.kernel.org @@ -215,11 +225,45 @@ Description: Read-only attribute that indicates the total number of Signals belonging to the Counter. -What: /sys/bus/counter/devices/counterX/signalY/signal +What: /sys/bus/counter/devices/counterX/signalY/cable_fault +KernelVersion: 5.7 +Contact: linux-iio@vger.kernel.org +Description: + Read-only attribute that indicates whether a differential + encoder cable fault (not connected or loose wires) is detected + for the respective channel of Signal Y. Valid attribute values + are boolean. Detection must first be enabled via the + corresponding cable_fault_enable attribute. + +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_enable +KernelVersion: 5.7 +Contact: linux-iio@vger.kernel.org +Description: + Whether detection of differential encoder cable faults for the + respective channel of Signal Y is enabled. Valid attribute + values are boolean. + +What: /sys/bus/counter/devices/counterX/signalY/filter_clock_prescaler +KernelVersion: 5.7 +Contact: linux-iio@vger.kernel.org +Description: + Filter clock factor for input Signal Y. This prescaler value + affects the inputs of both quadrature pair signals. + +What: /sys/bus/counter/devices/counterX/signalY/index_polarity KernelVersion: 5.2 Contact: linux-iio@vger.kernel.org Description: - Signal data of Signal Y represented as a string. + Active level of index input Signal Y; irrelevant in + non-synchronous load mode. + +What: /sys/bus/counter/devices/counterX/signalY/index_polarity_available +What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode_available +KernelVersion: 5.2 +Contact: linux-iio@vger.kernel.org +Description: + Discrete set of available values for the respective Signal Y + configuration are listed in this file. What: /sys/bus/counter/devices/counterX/signalY/name KernelVersion: 5.2 @@ -228,3 +272,31 @@ Description: Read-only attribute that indicates the device-specific name of Signal Y. If possible, this should match the name of the respective signal as it appears in the device datasheet. + +What: /sys/bus/counter/devices/counterX/signalY/signal +KernelVersion: 5.2 +Contact: linux-iio@vger.kernel.org +Description: + Signal data of Signal Y represented as a string. + +What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode +KernelVersion: 5.2 +Contact: linux-iio@vger.kernel.org +Description: + Configure the counter associated with Signal Y for + non-synchronous or synchronous load mode. Synchronous load mode + cannot be selected in non-quadrature (Pulse-Direction) clock + mode. + + non-synchronous: + A logic low level is the active level at this index + input. The index function (as enabled via preset_enable) + is performed directly on the active level of the index + input. + + synchronous: + Intended for interfacing with encoder Index output in + quadrature clock mode. The active level is configured + via index_polarity. The index function (as enabled via + preset_enable) is performed synchronously with the + quadrature clock on the active level of the index input. diff --git a/Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 b/Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 deleted file mode 100644 index eac32180c40d..000000000000 --- a/Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 +++ /dev/null @@ -1,61 +0,0 @@ -What: /sys/bus/counter/devices/counterX/signalY/cable_fault -KernelVersion: 5.7 -Contact: linux-iio@vger.kernel.org -Description: - Read-only attribute that indicates whether a differential - encoder cable fault (not connected or loose wires) is detected - for the respective channel of Signal Y. Valid attribute values - are boolean. Detection must first be enabled via the - corresponding cable_fault_enable attribute. - -What: /sys/bus/counter/devices/counterX/signalY/cable_fault_enable -KernelVersion: 5.7 -Contact: linux-iio@vger.kernel.org -Description: - Whether detection of differential encoder cable faults for the - respective channel of Signal Y is enabled. Valid attribute - values are boolean. - -What: /sys/bus/counter/devices/counterX/signalY/filter_clock_prescaler -KernelVersion: 5.7 -Contact: linux-iio@vger.kernel.org -Description: - Filter clock factor for input Signal Y. This prescaler value - affects the inputs of both quadrature pair signals. - -What: /sys/bus/counter/devices/counterX/signalY/index_polarity -KernelVersion: 5.2 -Contact: linux-iio@vger.kernel.org -Description: - Active level of index input Signal Y; irrelevant in - non-synchronous load mode. - -What: /sys/bus/counter/devices/counterX/signalY/index_polarity_available -What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode_available -KernelVersion: 5.2 -Contact: linux-iio@vger.kernel.org -Description: - Discrete set of available values for the respective Signal Y - configuration are listed in this file. - -What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode -KernelVersion: 5.2 -Contact: linux-iio@vger.kernel.org -Description: - Configure the counter associated with Signal Y for - non-synchronous or synchronous load mode. Synchronous load mode - cannot be selected in non-quadrature (Pulse-Direction) clock - mode. - - non-synchronous: - A logic low level is the active level at this index - input. The index function (as enabled via preset_enable) - is performed directly on the active level of the index - input. - - synchronous: - Intended for interfacing with encoder Index output in - quadrature clock mode. The active level is configured - via index_polarity. The index function (as enabled via - preset_enable) is performed synchronously with the - quadrature clock on the active level of the index input. diff --git a/Documentation/ABI/testing/sysfs-bus-counter-ftm-quaddec b/Documentation/ABI/testing/sysfs-bus-counter-ftm-quaddec deleted file mode 100644 index 7d2e7b363467..000000000000 --- a/Documentation/ABI/testing/sysfs-bus-counter-ftm-quaddec +++ /dev/null @@ -1,16 +0,0 @@ -What: /sys/bus/counter/devices/counterX/countY/prescaler_available -KernelVersion: 5.2 -Contact: linux-iio@vger.kernel.org -Description: - Discrete set of available values for the respective Count Y - configuration are listed in this file. Values are delimited by - newline characters. - -What: /sys/bus/counter/devices/counterX/countY/prescaler -KernelVersion: 5.2 -Contact: linux-iio@vger.kernel.org -Description: - Configure the prescaler value associated with Count Y. - On the FlexTimer, the counter clock source passes through a - prescaler (i.e. a counter). This acts like a clock - divider. diff --git a/MAINTAINERS b/MAINTAINERS index 9a9bf18bba00..ddabf7bb5246 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -299,7 +299,6 @@ M: William Breathitt Gray M: Syed Nayyar Waris L: linux-iio@vger.kernel.org S: Maintained -F: Documentation/ABI/testing/sysfs-bus-counter-104-quad-8 F: drivers/counter/104-quad-8.c ACCES PCI-IDIO-16 GPIO DRIVER @@ -4578,7 +4577,7 @@ COUNTER SUBSYSTEM M: William Breathitt Gray L: linux-iio@vger.kernel.org S: Maintained -F: Documentation/ABI/testing/sysfs-bus-counter* +F: Documentation/ABI/testing/sysfs-bus-counter F: Documentation/driver-api/generic-counter.rst F: drivers/counter/ F: include/linux/counter.h @@ -6960,7 +6959,6 @@ FLEXTIMER FTM-QUADDEC DRIVER M: Patrick Havelange L: linux-iio@vger.kernel.org S: Maintained -F: Documentation/ABI/testing/sysfs-bus-counter-ftm-quaddec F: Documentation/devicetree/bindings/counter/ftm-quaddec.txt F: drivers/counter/ftm-quaddec.c From patchwork Tue Mar 9 13:19:15 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: 12125113 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 1F039C433DB for ; Tue, 9 Mar 2021 13:21:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C645F650E6 for ; Tue, 9 Mar 2021 13:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230341AbhCINUy (ORCPT ); Tue, 9 Mar 2021 08:20:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbhCINUW (ORCPT ); Tue, 9 Mar 2021 08:20:22 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80F35C06174A; Tue, 9 Mar 2021 05:20:22 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id mz6-20020a17090b3786b02900c16cb41d63so5186847pjb.2; Tue, 09 Mar 2021 05:20:22 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=bg5qFyXKAm+O0oZX3oySwuvn9LP/nKtXNZnKHyMJuCw=; b=pe3koxT5n4t/VhCCDA7GwX6ehizUjwoZ4L28oLnp3eR51AGzcCWGKtKb9rqj6Q0EHA qBEvsEYAssU+tLeuUiK4ZcbSmgCk1mdIohDXLqIE6VFwYT/4BKP7kbaPOuTXRawDyL88 GTT54CpQgWZB0mB19eZLkVb3d9TMgDJcWLdn465X+/yGqNyTTqKWf6zIzenvd1ZdL1VF Zv705GwIH1KWI+EcyxCQW/yd3OkmcjxIc1aZWlULvad1KMomwLYsU2MCR0PJtkkxzBtf hWgNAQPJyYRiPtsf/FLMXkn+AEKtzah8PSOohV4QdhPZZ49/DidPBXujvJtB1TiDVW7M gh3Q== 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:mime-version:content-transfer-encoding; bh=bg5qFyXKAm+O0oZX3oySwuvn9LP/nKtXNZnKHyMJuCw=; b=rem27sRXRa7ptRocYcR35IyjNbXKx3kZ0qP9lkAiXUbdDKyCBxX+6UaTPZMZwXWQAd JBlDHvZ6x7RvGwXSn6yMst/JWeDTSIWLzQWoBhayQBLffBSCz0RQb3KxvgfxFRki/joO x/U+koTgR8ZoZ28dRFXbmFZLT8tXIWnHvbSZTOMkkc/fy9TMqMJRqFckF7XBIYwEUIKf enE7W5Dp+vZd1nIIpnxC7tM9u3SicsmSWHc+b+kfU2lnG3axdhG0pkuqGwzAcX6IT2ju q0SJPhzSagX9UGKPdDitquhlUUockQCR+e+mvYnNw74dfQQa98xloZaabvxPJJSUWM+y 0KVg== X-Gm-Message-State: AOAM530hSVvMRdB6D6jFm2vYps/S3GX1Pk5EIjj12n5ky2CjINT7/Zt2 s/SV4rAie4wulnAaJ4ZNAa8= X-Google-Smtp-Source: ABdhPJwOqzhV8kA4WQiAnQbL8enOzmt6KpcxjVrGgHYUAz/sr3uZG4aolV2X49YSZs0b+UU4gthLvA== X-Received: by 2002:a17:90b:100e:: with SMTP id gm14mr4669996pjb.217.1615296022135; Tue, 09 Mar 2021 05:20:22 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.20.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:20:21 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 02/33] docs: counter: Fix spelling Date: Tue, 9 Mar 2021 22:19:15 +0900 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org "Miscellaneous" is the correct spelling. Reviewed-by: David Lechner Signed-off-by: William Breathitt Gray --- Documentation/driver-api/generic-counter.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/driver-api/generic-counter.rst b/Documentation/driver-api/generic-counter.rst index b02c52cd69d6..64fe7db080e5 100644 --- a/Documentation/driver-api/generic-counter.rst +++ b/Documentation/driver-api/generic-counter.rst @@ -307,7 +307,7 @@ Determining the type of extension to create is a matter of scope. * Device extensions are attributes that expose information/control non-specific to a particular Count or Signal. This is where you would - put your global features or other miscellanous functionality. + put your global features or other miscellaneous functionality. For example, if your device has an overtemp sensor, you can report the chip overheated via a device extension called "error_overtemp": From patchwork Tue Mar 9 13:19:16 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: 12125115 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 C02AAC433E0 for ; Tue, 9 Mar 2021 13:21:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A4F3650F5 for ; Tue, 9 Mar 2021 13:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230518AbhCINUz (ORCPT ); Tue, 9 Mar 2021 08:20:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbhCINU1 (ORCPT ); Tue, 9 Mar 2021 08:20:27 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71BF1C06174A; Tue, 9 Mar 2021 05:20:27 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id v14so1827473pgq.2; Tue, 09 Mar 2021 05:20:27 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=o8tDypyv5ahTAAMuxI8NeVKXWRsIZA+Poj3szWZsqgo=; b=AYFaivlvQ/oLIjqJsJ/oehFS2L+56XUaU6sHt6nqOxr8FYpHMoGpDayLhwbo+RksWm m7Gdt+fW7hkOkEmzec0TM8IDtMPPmzEbDFvYQ+YT0XYHv66cHlTmoL1ghMEgsCalRPZB Es2RSKI/6Bj1qBz5P7gFOivsQoQCTuTIGUo2z8IupngTF9Jx0J4Zrc9WtdNTTQ2UoRqS dApjEniHKrL/jhZukBBhOnIZX2SNyrhB/at8RH6/sL/hBbFJWuJbPnQH6zzoM3bixpPG r8ZJe2EXD/nkza8KiXAtWxFAvgr9II1Xfmr0u1gQkwUeGo8voIN4det8zp4pwRs6K5Vv FBkQ== 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:mime-version:content-transfer-encoding; bh=o8tDypyv5ahTAAMuxI8NeVKXWRsIZA+Poj3szWZsqgo=; b=MGOGlk2CpIG81od9v0mjvFzO18G5/GqA8Y2KRQeFeQFWpiIU5S7t8XMitZNtxk6x/y PDb7GdPznm0KtY1ek8GwJO4440/uHYSSCePp67q+pSsw41PNWAMeDePiJAJ6Y4W7sw3y HUMnwgvy/yVk7b0g6dKt3FR+ERIIi0fRvAKWhDudjc1zmjSB7tphTVj3jsDPLhMimWHY Vb8yR+lVgSIkYm+Ev28TRJ+a34gOuFv2N68e8Nont2txjlWWdDvg4DvBsRv75ltwAIw1 BZKDckDKT0VPdpSAfAm4oqGBff+louweels6uFouWjPREat2/HW2QhiV5clmSGLb+SEp /G2A== X-Gm-Message-State: AOAM531aSJCHEVwHX3Zql5gxVmG4Qy/lkZ41IOJphuT8y7yJTMPvA3v6 uit9w6WYbe+kzYDK1I0fBE8= X-Google-Smtp-Source: ABdhPJxZKUUTrkGax8iWT8D8hxgyat5r+1Lghh1cpjR/93ysYtEmj5xKbxB+lyQOaaMyj9VgK4pDiA== X-Received: by 2002:a63:2441:: with SMTP id k62mr24161252pgk.332.1615296027115; Tue, 09 Mar 2021 05:20:27 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.20.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:20:26 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 03/33] counter: 104-quad-8: Remove pointless comment Date: Tue, 9 Mar 2021 22:19:16 +0900 Message-Id: <75913055bea8c4200f35727c03dd090d84f46c51.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org It is obvious that devm_counter_register() is used to register a Counter device, so a comment stating such is pointless here. Cc: Syed Nayyar Waris Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index 9691f8612be8..4bb9abffae48 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -1082,7 +1082,6 @@ static int quad8_probe(struct device *dev, unsigned int id) /* Enable all counters */ outb(QUAD8_CHAN_OP_ENABLE_COUNTERS, base[id] + QUAD8_REG_CHAN_OP); - /* Register Counter device */ return devm_counter_register(dev, &priv->counter); } From patchwork Tue Mar 9 13:19:17 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: 12125117 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 42CE9C4332B for ; Tue, 9 Mar 2021 13:21:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10F1765105 for ; Tue, 9 Mar 2021 13:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230512AbhCINU4 (ORCPT ); Tue, 9 Mar 2021 08:20:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231131AbhCINUc (ORCPT ); Tue, 9 Mar 2021 08:20:32 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81AD7C06174A; Tue, 9 Mar 2021 05:20:32 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id c16so6568703ply.0; Tue, 09 Mar 2021 05:20:32 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=Uo8aZJ7uFJm9IN0X5m8O12CJstLR4Mg3ThLr0VJ0OLA=; b=iyVwdDeb0d9ar/SgQS8NCqCJF8zBmbqYEU7YVIcfERfeXU9rRk+X9zQwpng9qVLZda d1yQFwkRQ8moVuHOC4RaL4Eo+CI1Jg13S3Hg6IASCNLMFxuYym7guA7qAb4WPvmIhWn6 P/fdq6zIxxYWhKwBGjfuOapE0xGM0vv5wE20G+6Ri5Twoc+Wx5yUlWsdz13BfRWUowNs saUOHkge4Z82XVoDKISrpPzLWDywMrP/a+UBj+RSFBKZNgXdtK1ZH2UiUnola7ptT952 yBn8kK5z87O+8qTLztPBkh6iP7/J+wmtH/wZUR+UVgqVXKcvt1/VcQUQF/CG6wjMMSJy lFzQ== 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:mime-version:content-transfer-encoding; bh=Uo8aZJ7uFJm9IN0X5m8O12CJstLR4Mg3ThLr0VJ0OLA=; b=oc1KcUyDV8LjJQ11TAx/r83sWhaFHFd/tACCdEQC6KYxUkxRXONjX+0Dvxl9JE+0bX zCPYI8+bOlV0KiUB2EVJ+NtaClo81W8MxGRyLKHVai+pzrJ9I6xnfNplb8IttOseFW0e VaKXTmw8uKKdtqZUpcav8INtcTwjTCV8CU5IyRH15tKFJOEcWJw3AkI2/DxuoZnV6QBF YnALzTqmD3+AihLrFxC5V5KkxvMMGRIvxTEH1iwgqNbiF9/Bc9j0bvfZM8oP9BHHhhvd DLUJG4yif/P3w58f1gMLnkSeanTrw0lR7IAm5HqAEWy779Ce/ay6UY0yz5iY9btmUp0m mlWA== X-Gm-Message-State: AOAM531pbiuAoWNWzN4UVTQ0Nc5zYTP3kKj3qirHV+f/yzWGfFgTp2so Q4J+9fJS8BgNNU39Pkekoqk= X-Google-Smtp-Source: ABdhPJzztWhpH23pplZlKp2maeyt5sWNUAAE2Am8BwuwOdJ/qsjqY345MQI6zfkVfbAY+PYd8TblmA== X-Received: by 2002:a17:90a:cca:: with SMTP id 10mr4613485pjt.103.1615296032134; Tue, 09 Mar 2021 05:20:32 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:20:31 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 04/33] counter: 104-quad-8: Return error when invalid mode during ceiling_write Date: Tue, 9 Mar 2021 22:19:17 +0900 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The 104-QUAD-8 only has two count modes where a ceiling value makes sense: Range Limit and Modulo-N. Outside of these two modes, setting a ceiling value is an invalid operation -- so let's report it as such by returning -EINVAL. Fixes: fc069262261c ("counter: 104-quad-8: Add lock guards - generic interface") Cc: Syed Nayyar Waris Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index 4bb9abffae48..233a3acc1377 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -714,13 +714,14 @@ static ssize_t quad8_count_ceiling_write(struct counter_device *counter, switch (priv->count_mode[count->id]) { case 1: case 3: + mutex_unlock(&priv->lock); quad8_preset_register_set(priv, count->id, ceiling); - break; + return len; } mutex_unlock(&priv->lock); - return len; + return -EINVAL; } static ssize_t quad8_count_preset_enable_read(struct counter_device *counter, From patchwork Tue Mar 9 13:19:18 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: 12125123 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 D468FC43333 for ; Tue, 9 Mar 2021 13:21:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B22F4650ED for ; Tue, 9 Mar 2021 13:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230372AbhCINU5 (ORCPT ); Tue, 9 Mar 2021 08:20:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbhCINUh (ORCPT ); Tue, 9 Mar 2021 08:20:37 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88037C06174A; Tue, 9 Mar 2021 05:20:37 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id n9so7794265pgi.7; Tue, 09 Mar 2021 05:20:37 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=fGsMq/or5LrbS6jzzwVkZSD8zHMbssCRETsq5AlmHhk=; b=BF2JeSQcBj5jKUajNNhfuC3RoAx40evJrNJ4jcEXKRuM8WUBWCil6hP9b89RjeqSjF iZ3CxQf0Cb6OS5BbtCIonpLqvfb4F4SNvpGxRZV6tUojZBRM9sVIuLyq0Lj9P/ktOram /8kPcJ3OWmvbqzak0914vmxbQn4e+V0D4Wbe9zJcrlQgXsd8wjBx9qPUjRBgGPJnnig6 o6qyI2qyS77Oj9JBLyYKJJMiS8QZt2WaAMYoPuL6xFot8HvZGMGi5OI4lYh7AalKKfba ehY87TN+zKbUk6LJ4nErVtbaQONWCO/flWpdZ5CFWStInUtpqX+UrKEgDecCz27TXZes azuQ== 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:mime-version:content-transfer-encoding; bh=fGsMq/or5LrbS6jzzwVkZSD8zHMbssCRETsq5AlmHhk=; b=f8l9wADLuKFYny00VE49jxdq7PZ7iPkzc+d+G4YJA0DyGXGLij7mVI/fKfVNEsh8jM mljAgYOhVCcvBYRcNdNCFAJeWNNhNIG3JENGUJUg5odKWcDZBj7SkgEvdosLqxB+CrOk H3BnTttRB9MquZtRRGPSPWdEPWV8z7golYIy2ngO5RbRHEZ/18ht4Y9eK5wZHHt2a3N5 084ZqBVWY/sHnzyeD7y9dtWLKyEylZ9dRIu7uL5Jh8JMDhxRjZ/L6WTtc6UIV2IbJNx6 Py1vO6vQaGHVD8kOI/76ZHN1p6Gi54SWvVnBYok4BGeRrpem2iiUQpyzy8jK3eL0UmBJ c6Zg== X-Gm-Message-State: AOAM530duhc8KrxzKh2xBWN9zGKJCsM8DIDtxFzZhRwLTH5sY5wKK+Tu Jx59ZkDlp/pOpp+jLPblfq8= X-Google-Smtp-Source: ABdhPJxYMcx8TAwzEMsyNljEGsxrjAzaeLrqUb84oaUmvtU0ci1sM9AnHXfbQ8l6WsU4z40xxM0RXA== X-Received: by 2002:aa7:8d05:0:b029:1ec:b460:f21d with SMTP id j5-20020aa78d050000b02901ecb460f21dmr26014314pfe.29.1615296037168; Tue, 09 Mar 2021 05:20:37 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:20:36 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 05/33] counter: 104-quad-8: Annotate hardware config module parameter Date: Tue, 9 Mar 2021 22:19:18 +0900 Message-Id: <97bee75c6b792f49e0b6331c922bd944591206ec.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org When the kernel is running in secure boot mode, we lock down the kernel to prevent userspace from modifying the running kernel image. Whilst this includes prohibiting access to things like /dev/mem, it must also prevent access by means of configuring driver modules in such a way as to cause a device to access or modify the kernel image. To this end, annotate module_param* statements that refer to hardware configuration and indicate for future reference what type of parameter they specify. The parameter parser in the core sees this information and can skip such parameters with an error message if the kernel is locked down. The module initialisation then runs as normal, but just sees whatever the default values for those parameters is. Note that we do still need to do the module initialisation because some drivers have viable defaults set in case parameters aren't specified and some drivers support automatic configuration (e.g. PNP or PCI) in addition to manually coded parameters. This patch annotates the 104-QUAD-8 driver. Cc: Syed Nayyar Waris Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index 233a3acc1377..0fd61cc82d30 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -21,7 +21,7 @@ static unsigned int base[max_num_isa_dev(QUAD8_EXTENT)]; static unsigned int num_quad8; -module_param_array(base, uint, &num_quad8, 0); +module_param_hw_array(base, uint, ioport, &num_quad8, 0); MODULE_PARM_DESC(base, "ACCES 104-QUAD-8 base addresses"); #define QUAD8_NUM_COUNTERS 8 From patchwork Tue Mar 9 13:19:19 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: 12125121 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 A9826C43331 for ; Tue, 9 Mar 2021 13:21:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75AB9650E6 for ; Tue, 9 Mar 2021 13:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230319AbhCINU5 (ORCPT ); Tue, 9 Mar 2021 08:20:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbhCINUm (ORCPT ); Tue, 9 Mar 2021 08:20:42 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6F05C06174A; Tue, 9 Mar 2021 05:20:42 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id fu20so886473pjb.2; Tue, 09 Mar 2021 05:20:42 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=jNbuVcZgloeyR2LVzHohVrUsgceqLUUAvFiu7EZYLL4=; b=OiDLg/jNmamc1mtL3gaPFwjt7jTKbMZ+aqomYModCj29Z1bpZ82+RHODdUZKFDVcfR z9p7UcTX5W5PpVCGnqmRT/MQB+mR1h31g0syjgDDZRIVLGMBI/1OJmfQOTwsKF0GQ8jx 2bYh9ALrtmpTRmnyABFOEuVjb2fDvLPI418tYkQmF0qzu7vR5vNvHnWp4FD8scgEkixV 8slgACiMoWoTxY4dm9l1tNn9lFZh8a7vjL/FfW/XcbnPzLoxEF7cgFphI1RKH6tSNTPi KpovAM357vJ5wm8k+24tqNJw6aZqevtzJF4hVMK4EcErGsX9t/GFhttmAtlZpVG+sahZ gMBw== 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:mime-version:content-transfer-encoding; bh=jNbuVcZgloeyR2LVzHohVrUsgceqLUUAvFiu7EZYLL4=; b=DpGVqGyqZRMQpzbiir2FgLUtx2YWEOoNXWpHqFmFcqFIzrjoq6v10eNM0s6uDbWtLU Tp4BUhxUfyRuYPnNZL6AqDIzOeatRmPKib4aGayOolr3IrqUsey9971Xz0tlbWzme7Q0 AXvR0uaXNz4u5vQAAIeXHNEZmagnkFfRaKHMOHEfXgAVpNAadQvZJGcyOEG5VHvF8YYp tWF8OziTKTMpvPQpPAZv4PU6m7whsQ5puijzIGtZPnJXLYhk8QwMgl3C5ehv/vi1Aklh V7Ae+yldpNpg5bYEvh0y0DwLuPej/EgEoK7GGeahoGHCCHyVG+gXDvLuYdVKXTgEkSgd zXkA== X-Gm-Message-State: AOAM530SsjtdCYPU0x5VZyoCewuJVk/XiSHEmNkGui2VpSq5pps/VD2J s6sFeqWAKLQe/w4dtIaWNxw= X-Google-Smtp-Source: ABdhPJwEpv8MPkJndDfnJHfd27hFk1fPpQhJPLsyGIytQ7HNvZsyMi2HU3uDDtSNepF1K82XCBwm8g== X-Received: by 2002:a17:90a:a63:: with SMTP id o90mr4795577pjo.90.1615296042338; Tue, 09 Mar 2021 05:20:42 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:20:41 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 06/33] counter: 104-quad-8: Add const qualifiers for quad8_preset_register_set Date: Tue, 9 Mar 2021 22:19:19 +0900 Message-Id: <67c6b42f44015b24eeb8136b2efda28aa41cd055.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add some safety by qualifying the quad8_preset_register_set() function parameters as const. Cc: Syed Nayyar Waris Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index 0fd61cc82d30..51fba8cf9c2a 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -632,8 +632,8 @@ static ssize_t quad8_count_preset_read(struct counter_device *counter, return sprintf(buf, "%u\n", priv->preset[count->id]); } -static void quad8_preset_register_set(struct quad8 *priv, int id, - unsigned int preset) +static void quad8_preset_register_set(struct quad8 *const priv, const int id, + const unsigned int preset) { const unsigned int base_offset = priv->base + 2 * id; int i; From patchwork Tue Mar 9 13:19:20 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: 12125119 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 9A344C4332D for ; Tue, 9 Mar 2021 13:21:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A1A0650F7 for ; Tue, 9 Mar 2021 13:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231150AbhCINU6 (ORCPT ); Tue, 9 Mar 2021 08:20:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230242AbhCINUr (ORCPT ); Tue, 9 Mar 2021 08:20:47 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B66DEC06174A; Tue, 9 Mar 2021 05:20:47 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id nh23-20020a17090b3657b02900c0d5e235a8so5189533pjb.0; Tue, 09 Mar 2021 05:20:47 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=Zj7+sm7nk2JUK10WGHF14mMymh0P+kdsvv/edNpXnVQ=; b=dr1NBz1sIQAoYrrUbrRdkjOj9yhfd+zFT5TTFhG3smfCVNmH9EJ+fW/RiBfPXdYJCz KMAE5GLHZYPIP9vCq7Uua1LiPg9IQQG+GRHW3Hx1HbzjdDfB0SxDKTWwwib7W8IyZcCm Ym6Dzq/2XIPH8v0wb4Wysob7fTtAZY1cFZ9vVNBv9rUjqW4mOKCYPoxImr1aRa1jiiiw OSrX3TDkO0w9BsbVGwVFO6pSiJ1OAhnuQZWQ+64HbUQyihAucSifjk2iQ/bWlAWzOSgQ l4noN+n6Yb9on9upQPWXzpVHI6tGqprEl8odS2YcDAikDBq2+VkhPHxWE6CD0Pxw3mbz JhDA== 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:mime-version:content-transfer-encoding; bh=Zj7+sm7nk2JUK10WGHF14mMymh0P+kdsvv/edNpXnVQ=; b=mtp2xSF9KaBKbwwfclI1OexbkvAM95843XSJVwTETLgGXUm8MkxL1lczt5Ki0Vta9F ZKQX2H1g+Lfm3NOlx+WyiPauC4hHaHT3GFWfsYqMrTAZ9YDidNKoHj4qL7ifR0XuPADv 6ijTfttJkH09nRNRThUxu2oF7sVih4rWX0XiA+GfexYQvKz8o5bmCeULVuuX0EFP6eFd ITGctqgb6nhaKcIWYeF/o9xESx7eMj2E3DZKXHdDiN8az4GvbglJazL847AQU/nyfXRn J8HBtFhuzvD0tGorqgB2JcFDaqVRH6Wq1CG6Hh/a4OVjKXpbYe4ud/DLzNhx8mSmD96G dVMA== X-Gm-Message-State: AOAM532J2B9jCPUgOxsM1mGX9v5DdmMg7TY6YV7I8HjsR89wRCHrpPZU E+2FkajGxFj1qGF3I5ybYesdASyNbPM4IA== X-Google-Smtp-Source: ABdhPJxVIxri8CSPeQwEBxpL4lyaoQVUFDNOXibjSAlsHzjikvlIqauj3O0He51c/uXIyeIi0wkRTw== X-Received: by 2002:a17:902:8ec9:b029:e6:c5e:cf18 with SMTP id x9-20020a1709028ec9b02900e60c5ecf18mr13935274plo.47.1615296047360; Tue, 09 Mar 2021 05:20:47 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:20:46 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 07/33] counter: 104-quad-8: Add const qualifier for functions_list array Date: Tue, 9 Mar 2021 22:19:20 +0900 Message-Id: <4d899b2fb1ed37f97f827af5880fdde916c5c4bf.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The struct counter_count functions_list member expects a const enum counter_count_function array. This patch adds the const qualifier to the quad8_count_functions_list to match functions_list. Cc: Syed Nayyar Waris Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index 51fba8cf9c2a..ae89ad7a91c6 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -193,7 +193,7 @@ enum quad8_count_function { QUAD8_COUNT_FUNCTION_QUADRATURE_X4 }; -static enum counter_count_function quad8_count_functions_list[] = { +static const enum counter_count_function quad8_count_functions_list[] = { [QUAD8_COUNT_FUNCTION_PULSE_DIRECTION] = COUNTER_COUNT_FUNCTION_PULSE_DIRECTION, [QUAD8_COUNT_FUNCTION_QUADRATURE_X1] = COUNTER_COUNT_FUNCTION_QUADRATURE_X1_A, [QUAD8_COUNT_FUNCTION_QUADRATURE_X2] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_A, From patchwork Tue Mar 9 13:19:21 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: 12125125 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,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 341E8C43332 for ; Tue, 9 Mar 2021 13:21:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA75A652C9 for ; Tue, 9 Mar 2021 13:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231161AbhCINU6 (ORCPT ); Tue, 9 Mar 2021 08:20:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbhCINUx (ORCPT ); Tue, 9 Mar 2021 08:20:53 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1745C06174A; Tue, 9 Mar 2021 05:20:52 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id b23so810766pfo.8; Tue, 09 Mar 2021 05:20:52 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=HvARqXgeQ2fZeiR/U1XlXXl6N9XMxqOiCPuY7eJJp30=; b=daDaJJOuSYYv2U02zs+uchgqbT0gUVfefQebIL0i4wEieLWddHnNzkXYRuIF2Lcfkg PPYTwLFD4JRIpZ244rbGj1/4gruuuGVHk5NN3zyAwjTSUIcLoBJovLdzbu7mpvZPULpu ZDUUi2D8sPog66u8TuDPAv3Z67uUxKzwsxFfmepV8Z4Vhlh1dqzcLGG9MLSShZjoEdPy 1wI3yVsYJXhAjlIeY8+VWegA0dMrAh7awbZ38Nb8GFrdjE73E5ltkLM8KyZsEU73IDAP YxuC+r8czFtxV14NhFpXVtDsCn2m4WsEjD/Hj8CevL67DxMUJdc019sOgqgWggoo4QVL R7og== 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:mime-version:content-transfer-encoding; bh=HvARqXgeQ2fZeiR/U1XlXXl6N9XMxqOiCPuY7eJJp30=; b=b4LZw9ybb2npd6QpNSLdkV/mHisVp4YWUzryxVvivgU0jIWeLbu4jA2rk69HmSFMJI OzuZhm2srnzR4NxLWUpJMJ4YMqkbTgEAyvBxtwt9hkuDx/IFEDjfEw7Zy8l9pHqZbOFw kUbmrE+Yj1jmdZpU65LoSjGbx34mvA0c9IbjLZIELcD3yUr+K46wCkazYia5CiCu+ebb xMyPZA6S9Jm0OFYGDtHC5mtoCWY/ozm6G4IP6+u4rzJABt4aAwaxyE/bt7uESq7EaP8N xBQJ6nLItXradRdevM64sg9njdnM0dCea7/zmDMIthBROSgMQD3z/oPnE+eoK0VpNvJi osHg== X-Gm-Message-State: AOAM531pVD3pIzl8bRt+WuQZbLZ2257f66UnsSso0KriWmaG+IrdwM4n rriCb22ydr7PZH1gt62hCkw= X-Google-Smtp-Source: ABdhPJzRAXelYHDtirlTtKesTFBuImAY941y8ZqiNjYmDxoddlkFWj+wWb14a12LcAATmO1yfpjUng== X-Received: by 2002:a63:1946:: with SMTP id 6mr14219508pgz.359.1615296052621; Tue, 09 Mar 2021 05:20:52 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:20:52 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 08/33] counter: interrupt-cnt: Add const qualifier for functions_list array Date: Tue, 9 Mar 2021 22:19:21 +0900 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The struct counter_count functions_list member expects a const enum counter_count_function array. This patch adds the const qualifier to the interrupt__cnt_functions to match functions_list. Cc: Oleksij Rempel Signed-off-by: William Breathitt Gray --- drivers/counter/interrupt-cnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c index a99ee7996977..827d785e19b4 100644 --- a/drivers/counter/interrupt-cnt.c +++ b/drivers/counter/interrupt-cnt.c @@ -112,7 +112,7 @@ static int interrupt_cnt_write(struct counter_device *counter, return 0; } -static enum counter_count_function interrupt_cnt_functions[] = { +static const enum counter_count_function interrupt_cnt_functions[] = { COUNTER_COUNT_FUNCTION_INCREASE, }; From patchwork Tue Mar 9 13:19:22 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: 12125127 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 32D7FC433E0 for ; Tue, 9 Mar 2021 13:21:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1E0F650DC for ; Tue, 9 Mar 2021 13:21:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231378AbhCINV1 (ORCPT ); Tue, 9 Mar 2021 08:21:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbhCINU7 (ORCPT ); Tue, 9 Mar 2021 08:20:59 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A7A7C06174A; Tue, 9 Mar 2021 05:20:59 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id 16so7950639pfn.5; Tue, 09 Mar 2021 05:20:59 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=P1nrq/4ri+fE+Ilcjx/mmcch8pXzmb2SwjOeRT4IcXw=; b=iJuGBvTig6gCxoRWZAjYZwOCL5LUQ+ojN2NsJSGSpHX02kW872JtXtqDU0lJSNUPbZ ptci+vytxDskqoPNo503TEwxh6zqvcjfQVZQE1K0zmre42auTZocUWwaFangkldy0/Wq tu09zItvH6d2oFp6RXYVaObaKyITOnRG1aWPxK57gg2oHlqKNydkW+BCXkA4z2kTnGRJ RrXJ+UtzNk6rlzul4h94FAwt50kNvvSqPXVCMdMlzSiz3tOCzb7vuhjUs471pCcUDFW1 Mn4NJMLXKlp3bky/QRCA6DbuZWfB3ZYrWqcVGblv+/kwnvX485xZbYzxvQy4e0vsWF2j Y9pg== 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:mime-version:content-transfer-encoding; bh=P1nrq/4ri+fE+Ilcjx/mmcch8pXzmb2SwjOeRT4IcXw=; b=AQPzV6AbTmLDEnQFI8CGkq1oSkmhbdxmGNgXBjAR+jBgq7h3yDE6NWK1RgqcP6/7Ao Qer8ihFBYP+GwMB7Z+2jLpD8LxawqxXJmjHhOCkTmBqNDY8290cVp17zGr0JtK6OqKAW ufEnMgi1WYnluHtKcqTO8aBh1D2XJUscU6IcAKFD0Bp1mlnvZ+/bu4wqa/IupDw7ifmm bGknXVS1XJ0wTdNzwNkES820rrnt11U9WcqhYYe2+qDC++4OkDNUyUcCoRSm7XYowVt4 UgOxqbKgZATo6mb+Jaol/UOQqx1oxM37y047YyVIQHXaaFI/8mH5tsBfUR9CE6yXnf/d erPQ== X-Gm-Message-State: AOAM533LU7GBgeUUn21/7Gfnh57YzcQyP93fzPpAfzDBwsiDLjPvEiIZ TLBt7eWrZrEiWs1lueoHEFA= X-Google-Smtp-Source: ABdhPJxBiCwRlmZ1ZVaN9w8ZTI3BTyAsztf03NSnBCbgzsKnmm+LmB45p6bpfilnxSSPdBV6BRoI+g== X-Received: by 2002:a63:d40b:: with SMTP id a11mr3171412pgh.192.1615296058721; Tue, 09 Mar 2021 05:20:58 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.20.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:20:58 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 09/33] counter: microchip-tcb-capture: Add const qualifier for functions_list array Date: Tue, 9 Mar 2021 22:19:22 +0900 Message-Id: <06801459f7fa7fa47ec973c1278df70181a48cd1.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The struct counter_count functions_list member expects a const enum counter_count_function array. This patch adds the const qualifier to the mchp_tc_count_functions to match functions_list. Cc: Kamel Bouhara Signed-off-by: William Breathitt Gray --- drivers/counter/microchip-tcb-capture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/counter/microchip-tcb-capture.c b/drivers/counter/microchip-tcb-capture.c index 710acc0a3704..cabcfebfc799 100644 --- a/drivers/counter/microchip-tcb-capture.c +++ b/drivers/counter/microchip-tcb-capture.c @@ -37,7 +37,7 @@ enum mchp_tc_count_function { MCHP_TC_FUNCTION_QUADRATURE, }; -static enum counter_count_function mchp_tc_count_functions[] = { +static const enum counter_count_function mchp_tc_count_functions[] = { [MCHP_TC_FUNCTION_INCREASE] = COUNTER_COUNT_FUNCTION_INCREASE, [MCHP_TC_FUNCTION_QUADRATURE] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4, }; From patchwork Tue Mar 9 13:19:23 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: 12125129 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 5AB34C433DB for ; Tue, 9 Mar 2021 13:21:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1AD56650F7 for ; Tue, 9 Mar 2021 13:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231131AbhCINV2 (ORCPT ); Tue, 9 Mar 2021 08:21:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230242AbhCINVE (ORCPT ); Tue, 9 Mar 2021 08:21:04 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 150D5C06174A; Tue, 9 Mar 2021 05:21:04 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id e2so1287583pld.9; Tue, 09 Mar 2021 05:21:04 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=UIAVd9muG3GyzUO3PQ0xXOFMJbQ/8NwAgbwz6em0ZRg=; b=jW4gcFVXjW/JzLz3cPSkBjbDaBo7tO/oiG724aeK0AHoO05rKqd4AKWvx1if7eAHD+ fiQSL6f8rZ8ViPuFQkYvAHO4kVlvV0jah/mzK5yD35slTRN4LKOJg0efzq02kONJvhXm QuV4bY5t7iLV8WfhAD4MSAeL/U99u3RMbSz9gUrJKK6M4sezn4AbIAPXat7GfNIyQxmb 58pgasZgH2HmtV6jrHyhMsgl670VOZ2sI+tDluqgnCDCzFm5g+B49Kg7mDdolWgveF85 2DW5U7GJyhwBacxmVtI8e8VQCaE6nyNuK/z8pg0hxwI1D5ddWFRs50DXcYQ7W9EBegz4 nm/w== 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:mime-version:content-transfer-encoding; bh=UIAVd9muG3GyzUO3PQ0xXOFMJbQ/8NwAgbwz6em0ZRg=; b=Dciwk5e2L+b4lAVZ7oeUG1cn2PoKL7enhIuSWC078pfnYmqKd2Uh1r9J8E5oX/79pB HGlqgNQ5GouPu2AWSFnie3Wf8bMQIkM97N4txIdGQPKnZMyXLs4Vbtlp3x02mxIuyA1Z 58efyiZKyaLQ8dADyj2Q+Ao1fDymw5HdgWN82qhg2Uac0W1G6A/4Pos0/46Psuq9jW1B XI8VO1KMZXPk2RWvKfyBsNpeMGSRyev2SGpS8aD6QqjLqf9oXnYUrsgLYd7kHCz+SC0/ NNgrZLuPMctLPmRbXEI7laDBI2WNNbIIyA0W9r66wZ7kIqntr+pCBsJWJTu95VgMQ+FV 6cuQ== X-Gm-Message-State: AOAM5329ReVvC9LtE0bUjsjAkkFwYQqZ6ovtXQ2iOKuoHUZ+rT/wfwS0 6tMYF9uLZqNKLOSkVIXtvEw= X-Google-Smtp-Source: ABdhPJxVXkw9bGWsBjUq7o7hg1B/IvBD9mBlo1XlR95LPUGnVPTey/VSv8pOU7IfUWfxSbINqhwdFw== X-Received: by 2002:a17:90a:a584:: with SMTP id b4mr4701165pjq.186.1615296063689; Tue, 09 Mar 2021 05:21:03 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:21:03 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 10/33] counter: stm32-lptimer-cnt: Add const qualifier for functions_list array Date: Tue, 9 Mar 2021 22:19:23 +0900 Message-Id: <6325a9857d8566c31c6bd7fb3812249c99350fbd.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The struct counter_count functions_list member expects a const enum counter_count_function array. This patch adds the const qualifier to the stm32_lptim_cnt_functions to match functions_list. Cc: Fabrice Gasnier Signed-off-by: William Breathitt Gray --- drivers/counter/stm32-lptimer-cnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c index 937439635d53..0f7d3f1ec1b6 100644 --- a/drivers/counter/stm32-lptimer-cnt.c +++ b/drivers/counter/stm32-lptimer-cnt.c @@ -134,7 +134,7 @@ enum stm32_lptim_cnt_function { STM32_LPTIM_ENCODER_BOTH_EDGE, }; -static enum counter_count_function stm32_lptim_cnt_functions[] = { +static const enum counter_count_function stm32_lptim_cnt_functions[] = { [STM32_LPTIM_COUNTER_INCREASE] = COUNTER_COUNT_FUNCTION_INCREASE, [STM32_LPTIM_ENCODER_BOTH_EDGE] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4, }; From patchwork Tue Mar 9 13:19:24 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: 12125131 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 A540CC43381 for ; Tue, 9 Mar 2021 13:21:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8169065105 for ; Tue, 9 Mar 2021 13:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231362AbhCINV3 (ORCPT ); Tue, 9 Mar 2021 08:21:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231342AbhCINVJ (ORCPT ); Tue, 9 Mar 2021 08:21:09 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ED4AC06174A; Tue, 9 Mar 2021 05:21:09 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id a188so9477489pfb.4; Tue, 09 Mar 2021 05:21:09 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=GNvPFH0nbH03EWMVb853Te4h5hOebkH389D/4/Ar3Gc=; b=oHsuOiqMdMxnXlvuMVnuJtbCtO6m8GaPBzu1TtoNuV/yMutJbslbGT93vPW6pcL0qA E0QsNVaJRX6FG2ROv+fQUG6WEiyDTo8YHATz03XYW16NghpHEhJd/AAH06zrrfwJjBWQ fLBvXF+gmx6rqoJj25pjIxs0PmYuigH9GCxrirLNUvKeW9lfqW9sxg6i/GSlX3OlqS3b CRfxOYwVwIWcd8gAPZPyMDSnhG4/v30MZQMxqNHUVvjR++z6lOysCgS5gJ9kQkFqtOLi 3LwS4D6yUCljHjF4s86ICVhzqenEdJge6p3VwyMcj5k4Qc/gXohYgSEVxqCF4TwLzgaD eAqg== 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:mime-version:content-transfer-encoding; bh=GNvPFH0nbH03EWMVb853Te4h5hOebkH389D/4/Ar3Gc=; b=o0I9dM3IOxeluootHbsMa60EqIeo6u4r9/9mIV+FMGgPVo5a6vmXAocmuRfZ81kWeJ YaHk0og0Y6UfHvzEGcSC9yBsF+pxGMH2T7EPrRcN9DVoEOjql57bWUYiPbEI+Ikkk3hc ZRekPy1Z1bz6msEMjRGvYuRgsxpG1sgAPI5wJTKvAAOLCFb8szmIpHXVejGM/hdFr+Oa H5HoWQyG3DMb7Lvah7N9/d6llXy3Q86c1wIspLk1cJ9e4DLKYHAVO7fuV8273380em9H O4genYY5u+6S5tm4SKRbf9HsWPTKIhw4zjPVU1UzMglvFFG9Ff/18+gnuv4mLFFB/8Un goog== X-Gm-Message-State: AOAM530WIdcM2vrX1zmInaeM7mwdNF2I5xFgsigiMEdCQqjRhsnUco3z S6VxFRewNkuRAerKMzm2vTg= X-Google-Smtp-Source: ABdhPJwIKDxPC96PkVg3vgpek6rrcJkG+VKEdqIg1FFHHf4+K1TPcqyv7FyM+65t0sLIKaMaxK5uTw== X-Received: by 2002:aa7:91d2:0:b029:1ed:b10b:5a7 with SMTP id z18-20020aa791d20000b02901edb10b05a7mr3666547pfa.2.1615296068948; Tue, 09 Mar 2021 05:21:08 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.21.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:21:08 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray , Benjamin Gaignard Subject: [PATCH v9 11/33] counter: stm32-timer-cnt: Add const qualifier for functions_list array Date: Tue, 9 Mar 2021 22:19:24 +0900 Message-Id: <84fc37f8c32e8b9b52ca55e0ffeda67cd93e16f5.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The struct counter_count functions_list member expects a const enum counter_count_function array. This patch adds the const qualifier to the stm32_count_functions to match functions_list. Cc: Fabrice Gasnier Cc: Benjamin Gaignard Signed-off-by: William Breathitt Gray --- drivers/counter/stm32-timer-cnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c index 75bc401fdd18..0c18573a7837 100644 --- a/drivers/counter/stm32-timer-cnt.c +++ b/drivers/counter/stm32-timer-cnt.c @@ -50,7 +50,7 @@ enum stm32_count_function { STM32_COUNT_ENCODER_MODE_3, }; -static enum counter_count_function stm32_count_functions[] = { +static const enum counter_count_function stm32_count_functions[] = { [STM32_COUNT_SLAVE_MODE_DISABLED] = COUNTER_COUNT_FUNCTION_INCREASE, [STM32_COUNT_ENCODER_MODE_1] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_A, [STM32_COUNT_ENCODER_MODE_2] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_B, From patchwork Tue Mar 9 13:19: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: 12125133 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 D7E7EC4332B for ; Tue, 9 Mar 2021 13:21:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5A3A650F7 for ; Tue, 9 Mar 2021 13:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229775AbhCINVa (ORCPT ); Tue, 9 Mar 2021 08:21:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231345AbhCINVO (ORCPT ); Tue, 9 Mar 2021 08:21:14 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 410DCC06174A; Tue, 9 Mar 2021 05:21:14 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id p21so8752153pgl.12; Tue, 09 Mar 2021 05:21:14 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=ZWre/5BlgKXL1iyhEnRSRabCNrSj07MKqwX9rpON0N0=; b=EPzgiswKRcoUeRnTBjq6Tx6uWKKDlWfj9SXcpEIGX2skUnRDOEjyOUn+jjyGxouEEv YMCtoqmhuTgfDRjRy1NYIHZVORxf4YhW8Kz4z8O5QQ8NEDV5RfsFvfs5pzaVEOoTjMDJ 8s2C1k8e7ZHi/cDyYDaAuNjVNgUzNKTI5Z/RUdmDiRyMkvBsJSI7l9tcffOce9RNxK/h gMy9LgWYczmXXhK+QOos5Wb/c35vxbnrxV1oHjrVYv6NK//hd1qMDrXIWg3i/rN5ljJw sjdOGduippNTDY+jLvalvicHZymCaCWQnU0RBGfdcjx+nYIjZzu/qE/SKH5exRTqg0i7 iAQQ== 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:mime-version:content-transfer-encoding; bh=ZWre/5BlgKXL1iyhEnRSRabCNrSj07MKqwX9rpON0N0=; b=WVV3Xic25hRh78ytu19ijt94w/nE5LiRFKCacLBZ/fMnVRZ7g4kEVqMA6HH1OvBYLz XSlrjUiqKkf99dTsTO/AFX1JiL/mNmGeJnhiK38p1/rBMfh8moNjqFhEV5I4meKxtL+x LyEyLCBTwiucKQsu8T0zv2xQH+PWxc5OtT5Dl0cjmUvJo7hSJLffCv/CGTCoV+Gxko8M h5WOY1/+Ur4Jrggq/ZJFcvYARQA/2wuwWB4SrsOzerQRlWoWdI5XY5gPER+IildimfCh Bwt7qdX4pyQI4KzgcMNg3bXzviBVr+d5JyTxLmA/12qbI/26+lfAm0hBY1ZOJZK98I8e 2J5g== X-Gm-Message-State: AOAM533GLkW+kM68fYD1Z/rHyPQCjDr8hqnK5WE2DjUbzFLhPGBhRBGj d3WzDUh0eptvbBdIT42WkIk= X-Google-Smtp-Source: ABdhPJx+4sNzc6b+jcn9nwYXMErpaUoVChItdCn/vQu7L4lcitioJp3OEfACaGLCYqRp1bdW5bK69A== X-Received: by 2002:a63:5014:: with SMTP id e20mr24895866pgb.152.1615296073915; Tue, 09 Mar 2021 05:21:13 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:21:13 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 12/33] counter: 104-quad-8: Add const qualifier for actions_list array Date: Tue, 9 Mar 2021 22:19:25 +0900 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The struct counter_synapse actions_list member expects a const enum counter_synapse_action array. This patch adds the const qualifier to the quad8_index_actions_list and quad8_synapse_actions_list to match actions_list. Cc: Syed Nayyar Waris Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index ae89ad7a91c6..09d779544969 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -305,12 +305,12 @@ enum quad8_synapse_action { QUAD8_SYNAPSE_ACTION_BOTH_EDGES }; -static enum counter_synapse_action quad8_index_actions_list[] = { +static const enum counter_synapse_action quad8_index_actions_list[] = { [QUAD8_SYNAPSE_ACTION_NONE] = COUNTER_SYNAPSE_ACTION_NONE, [QUAD8_SYNAPSE_ACTION_RISING_EDGE] = COUNTER_SYNAPSE_ACTION_RISING_EDGE }; -static enum counter_synapse_action quad8_synapse_actions_list[] = { +static const enum counter_synapse_action quad8_synapse_actions_list[] = { [QUAD8_SYNAPSE_ACTION_NONE] = COUNTER_SYNAPSE_ACTION_NONE, [QUAD8_SYNAPSE_ACTION_RISING_EDGE] = COUNTER_SYNAPSE_ACTION_RISING_EDGE, [QUAD8_SYNAPSE_ACTION_FALLING_EDGE] = COUNTER_SYNAPSE_ACTION_FALLING_EDGE, From patchwork Tue Mar 9 13:19:26 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: 12125177 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 9D2CFC43603 for ; Tue, 9 Mar 2021 13:22:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73684650ED for ; Tue, 9 Mar 2021 13:22:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231386AbhCINVb (ORCPT ); Tue, 9 Mar 2021 08:21:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230086AbhCINVT (ORCPT ); Tue, 9 Mar 2021 08:21:19 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FD39C06174A; Tue, 9 Mar 2021 05:21:19 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id w34so7691000pga.8; Tue, 09 Mar 2021 05:21:19 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=t3RYDFFjHkpdIJ04TsWBr8TmaLo8cU+WLWiTJPwxr6A=; b=cPm80utEO4gK7NjFC0zhB5gCOPQtq5RrNUNd9cA58RKV54Pyfn5Ple+ImuNJKzBvpt n8wndmxhEJq8BsaC+on7Q07Q9RHLFCNoxNaPe97INCetElIrmTqsj+Bwb9lPnVIRGw1g Un727QcUYB5HiVK+udGrEKeO9EX8vCZYnIbjKJWtph48VCX2XFggT0wmSwc3TO0ybB5z CBXoOaDrVfuxpGeV99w8q8QegdY1RsYgGuSbz9gBE4n6XusXJbjRBb1RvX4eDWh0EO4l K58k5bv/48LTWLNqywOg69rT+vHYe/T9mxJJjOsyCGOR24wHn0wqcfvJkzzq0n+h9zZ5 wnlw== 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:mime-version:content-transfer-encoding; bh=t3RYDFFjHkpdIJ04TsWBr8TmaLo8cU+WLWiTJPwxr6A=; b=nHx1J2jp7uUmz3YSy/zap8/+7HjrZ6AOg7BN9+piOF0qlEaBMeAJSI4MEa2hz5y1SC uIP7G5blD5Aw/RDifzfMQHnTYVaFgOVcM3UR66Bi9+y72W28orHVjOkg1nP7/EvVOE+W w7LxNuFry7c2wtu5NZqPs1yXis7OfgLRXIWWix5gYKO2lH1Ks2t8bblcjd0fFe/+Bs6T DHT2UoecmyWnK6AqJIffrZkm7WGXGh3IgNBCJKf+96qGGs+AvsqgiHLv2yHBqfvyk6f0 rYmElM+/7f1I4Xg4h+kNzx3/4AE2Jq5EBiN++7BFvhm1v+VV55h8CccrlwlQb8/bfnoG hDGQ== X-Gm-Message-State: AOAM532ZEO8hhM/QmSPY2l5f3f7ZwZ+cB9hFw4z4pBW6AUkkRre9NXqJ /WbDd2PGyTabC8T1CNZFfbNhNOG9frDaXA== X-Google-Smtp-Source: ABdhPJzuf+IfHPoOevXWiR5Tex/ci8k9Iu42/LT75i/JLS8DvEf89M7PROm+OH0amxUz5yHaHNf9Eg== X-Received: by 2002:a63:d242:: with SMTP id t2mr24853367pgi.431.1615296079245; Tue, 09 Mar 2021 05:21:19 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:21:18 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 13/33] counter: ftm-quaddec: Add const qualifier for actions_list array Date: Tue, 9 Mar 2021 22:19:26 +0900 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The struct counter_synapse actions_list member expects a const enum counter_synapse_action array. This patch adds the const qualifier to the ftm_quaddec_synapse_actions to match actions_list. Cc: Patrick Havelange Signed-off-by: William Breathitt Gray --- drivers/counter/ftm-quaddec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/counter/ftm-quaddec.c b/drivers/counter/ftm-quaddec.c index c2b3fdfd8b77..9371532406ca 100644 --- a/drivers/counter/ftm-quaddec.c +++ b/drivers/counter/ftm-quaddec.c @@ -162,7 +162,7 @@ enum ftm_quaddec_synapse_action { FTM_QUADDEC_SYNAPSE_ACTION_BOTH_EDGES, }; -static enum counter_synapse_action ftm_quaddec_synapse_actions[] = { +static const enum counter_synapse_action ftm_quaddec_synapse_actions[] = { [FTM_QUADDEC_SYNAPSE_ACTION_BOTH_EDGES] = COUNTER_SYNAPSE_ACTION_BOTH_EDGES }; From patchwork Tue Mar 9 13:19:27 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: 12125175 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 6EC15C432C3 for ; Tue, 9 Mar 2021 13:22:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4506C650DC for ; Tue, 9 Mar 2021 13:22:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231394AbhCINVd (ORCPT ); Tue, 9 Mar 2021 08:21:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231366AbhCINVY (ORCPT ); Tue, 9 Mar 2021 08:21:24 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC2CDC06174A; Tue, 9 Mar 2021 05:21:24 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id t9so880170pjl.5; Tue, 09 Mar 2021 05:21:24 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=hMXw7mJLvmbOCLGtZkacbJfdNcshHDOykbRbagCdG6s=; b=dS5t11yTimmAgWJ/VyICyJwpRHriakfanzUCa8NwNNgvjVV+OGrPXIiYtW0Ce4opoj rYPFyJDZvTANqOGxcWde7x9EbxGjgYr0F4jX5zctNvALNAqyNnOMOM0QLHzURiv0A0YZ T5710qgW8E/37FOATqErMkbQdmEqgjmUQfVHaTEwtExaO4o/oSs3f+Qh2j2MU0hQnBLX Rb1i2KdWdYNFjby3VInHJSZvRbjDMr6ghHAw18IbicCLbq+MQ1m97oQzgjKucim0ZBXE YRcJGy1mmKRRtRGnf+2HPZr70tPqUd9+tIReg3e0KnviRS2tRAyDCLZlgmV78FIT0EM6 VWbA== 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:mime-version:content-transfer-encoding; bh=hMXw7mJLvmbOCLGtZkacbJfdNcshHDOykbRbagCdG6s=; b=EwYVu6UszulHaBIJr0TiBXM6WGobReJd6oA+U04ooPyLRHOkQMQCcHeYUzs1scsQSP ZW0e+0pvw0+vv+RvR1jazR8LyvwXyrykxMMsAbYvbeBWesbKuWZNIfzeCUGS5z0DBltl yY56voJng4c67HkFdMKIQIvphIQL2tStvSQjO0bRWfb5r/h+6Zwjcm/Q7ttaIkO+3yDP Ztt+DV/3FjOyCNXee5exOEKHrR3xlWLYrqPQLMp0JAOWxmY2px2c1eFSt4/oHNTe6mD4 cbBDigyStDwA/lpYr/Y4hFaN26NZ/zLOPjtZ6YZtITneN+VT5ngGwJ/BRjKOd2Eg35QS Ehng== X-Gm-Message-State: AOAM531lAyzu7iZetKRi1oIeGPTOjpuxY8ebG4RblScmZDJAFFhSbTXH dgO1SZsK5XAknhq33Gl1LO0= X-Google-Smtp-Source: ABdhPJxoxzQivWDNyZ9YM3b54AMuzlgre0Fcfw0AmJmmILw6QJPteZGZXZjWn8Dhf1/XZN5tsVsGDg== X-Received: by 2002:a17:90a:ea91:: with SMTP id h17mr4726826pjz.66.1615296084435; Tue, 09 Mar 2021 05:21:24 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:21:24 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 14/33] counter: interrupt-cnt: Add const qualifier for actions_list array Date: Tue, 9 Mar 2021 22:19:27 +0900 Message-Id: <0cad0b85e28f558e4774f02ca267c32a6ac03b6d.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The struct counter_synapse actions_list member expects a const enum counter_synapse_action array. This patch adds the const qualifier to the interrupt_cnt_synapse_actionss to match actions_list. Cc: Oleksij Rempel Signed-off-by: William Breathitt Gray --- drivers/counter/interrupt-cnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c index 827d785e19b4..0e07607f2cd3 100644 --- a/drivers/counter/interrupt-cnt.c +++ b/drivers/counter/interrupt-cnt.c @@ -77,7 +77,7 @@ static const struct counter_count_ext interrupt_cnt_ext[] = { }, }; -static enum counter_synapse_action interrupt_cnt_synapse_actionss[] = { +static const enum counter_synapse_action interrupt_cnt_synapse_actionss[] = { COUNTER_SYNAPSE_ACTION_RISING_EDGE, }; From patchwork Tue Mar 9 13:19:28 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: 12125179 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 D71A5C433DB for ; Tue, 9 Mar 2021 13:22:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E04F64D8F for ; Tue, 9 Mar 2021 13:22:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbhCINV6 (ORCPT ); Tue, 9 Mar 2021 08:21:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231367AbhCINVa (ORCPT ); Tue, 9 Mar 2021 08:21:30 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7B04C06174A; Tue, 9 Mar 2021 05:21:29 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id y67so9520693pfb.2; Tue, 09 Mar 2021 05:21:29 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=rC2Th++vNt7CqGAj8WhJOkxOFf8ZEs13/9ziRoW9ymc=; b=E/4zwhWgcU4xyOXY8FDQeW+SR9ur9RmudK7zimF4LzKDITpUVG4827s/iONgSA9PpG y9Tby0YfFWbRhVpxHArnaYYiqbKBuTV5jVQyckjVVAxHjufzRbu70bxnbXuYrr2sKz78 Azqb0OjEmY08D5CCel1gMdHXed8HtHiT2xBGNlLhKuS/Fs2W+/9HpIe7RfjBM1uWQOJ+ czzF9qSKODr59CXoLqF1iJTdYqABa64zXh00WbOV2AMDX8GPj/rDiOYJcCFVqAfcMfE/ xsqpJniF26aFbx9eCEEI+DnaWOsEKuW4ns05JQLBiDwb8tfqP/WNMJfIxzpH2me97cIL Enbw== 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:mime-version:content-transfer-encoding; bh=rC2Th++vNt7CqGAj8WhJOkxOFf8ZEs13/9ziRoW9ymc=; b=JUxIiVYgyPyqYayEDw4CIDSQxwhlGmPoCsq26gcLzgXbkCUYmmD1UqDT2q5Og+MCNG 0ey3fP6Uz2oH+wdd76fB/cwaW1/67LUzacAu7rLaOtekqze8j3A08qeNKBSQS1vAcdq1 VtqXtmDNkXZxhpTJ+lczo/k0/KkLvex+/kUSdtxkNfbGmvB396drpXZyu9zzleZj3YA0 BaptfGbAPQF3+b0BU2VjciysApM3t51DpYLgm/DecQzpnL6grJtUtvLmEBLhpeJwKowF erHFUurg0TdvGn1k09WgzDvyPgWEndzcvWIP/XYoKfFnBQBXrcvM4M75zy1/b5HHhp1X DLWg== X-Gm-Message-State: AOAM532Rvt+7hkeM6dU4xqE2gmnPJgxIkUwLha9B6rwVGihO/ii997BI f1i2FJFL1hiq4xoNveVAEVs= X-Google-Smtp-Source: ABdhPJw9kLoA+icLpJPLdh1A/lMDX6fb53r5KBvtgKq0qWuhM1Z2JhSYca6Qi8lTMgRjJfO1PhKqmw== X-Received: by 2002:a63:2e06:: with SMTP id u6mr9962931pgu.444.1615296089500; Tue, 09 Mar 2021 05:21:29 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:21:28 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 15/33] counter: microchip-tcb-capture: Add const qualifier for actions_list array Date: Tue, 9 Mar 2021 22:19:28 +0900 Message-Id: <08b2f787df2965aca63988ca35e58133cb4e2c3e.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The struct counter_synapse actions_list member expects a const enum counter_synapse_action array. This patch adds the const qualifier to the mchp_tc_synapse_actions to match actions_list. Cc: Kamel Bouhara Signed-off-by: William Breathitt Gray --- drivers/counter/microchip-tcb-capture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/counter/microchip-tcb-capture.c b/drivers/counter/microchip-tcb-capture.c index cabcfebfc799..51b8af80f98b 100644 --- a/drivers/counter/microchip-tcb-capture.c +++ b/drivers/counter/microchip-tcb-capture.c @@ -49,7 +49,7 @@ enum mchp_tc_synapse_action { MCHP_TC_SYNAPSE_ACTION_BOTH_EDGE }; -static enum counter_synapse_action mchp_tc_synapse_actions[] = { +static const enum counter_synapse_action mchp_tc_synapse_actions[] = { [MCHP_TC_SYNAPSE_ACTION_NONE] = COUNTER_SYNAPSE_ACTION_NONE, [MCHP_TC_SYNAPSE_ACTION_RISING_EDGE] = COUNTER_SYNAPSE_ACTION_RISING_EDGE, [MCHP_TC_SYNAPSE_ACTION_FALLING_EDGE] = COUNTER_SYNAPSE_ACTION_FALLING_EDGE, From patchwork Tue Mar 9 13:19:29 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: 12125183 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 ACC4AC4332D for ; Tue, 9 Mar 2021 13:22:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D48064EBB for ; Tue, 9 Mar 2021 13:22:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231149AbhCINWA (ORCPT ); Tue, 9 Mar 2021 08:22:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231422AbhCINVf (ORCPT ); Tue, 9 Mar 2021 08:21:35 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9774C06174A; Tue, 9 Mar 2021 05:21:34 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id a188so9478198pfb.4; Tue, 09 Mar 2021 05:21:34 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=lKQBbBWNoQCAzrzOLXLXaWKO88BEqFAf4JzZ/BOkGvk=; b=h9WuVuuqiNzrtydGX1I+OAyd5xdQWeCeb19No6Q9k349Tqh4H6uH3x5Cxx3KM7/kCf b6FtVO35EmYC/8BDUs3JwcHbVvGVzJ5KeIMV4iW8anmQIiVcIgsDAXYEiRMAbkBU1866 C9sC1208pC96x5X5JBEurygLyzBSDY0tjlcGo3HYD8jTF1DDdenq+AQW/IlU2l5zyAVn 2qe7tPOajW1VwQj9H9O6u90GfeGun8cbzNKaTNFRTwaKBUNNp4dcoN6AQF2KC5ANnr+2 ajp6E3j6wuMCtmkCV7Bq4WFPmXpPJlLpf6quj0pFmlewc0Lx6wfdaVY9kFrBGGH51R+5 KBMA== 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:mime-version:content-transfer-encoding; bh=lKQBbBWNoQCAzrzOLXLXaWKO88BEqFAf4JzZ/BOkGvk=; b=VFeJzRvzculfjFcB2IVAQw0UNj7lKNCJ/J+qVI2LmfLTSMGz23XsuYiAnczcqheQAN lrLTEmAu+4fZxif1nZnYvQ5sRktOZAc0FLL+a5vaOWuRWT62+IPcKmBIpg0iU6YlsYSv WvtSmxqUTjMZ/3hXiYsBmMbDFnYs3kh5kbxAO+pSVJ8StWynNC+ScUypKQq0UBSoJdX4 Bnjfj4a8+k3oWio7dMGYesmffHggVJQnexhZhrXk8riIK5prezsTAPzgFr0YIlBuCtDi t2f22tsNPicPmzVWxm0PDq1s8mN1Y/cH8saBQv8V9EohsG/eu9kF7pEE0hWTd26vTeLo A45g== X-Gm-Message-State: AOAM532QKzcsCOJp8T52DuhHs75XJE5KwcblRKxUOWEfCZwDR24B46As C7rDidui/XlC+Nsr8Bb27lY= X-Google-Smtp-Source: ABdhPJwhZtTdMde26dsAarCbRJh8s9mIuxXONPgp8SHKC13ALeUMBJEC0fjJIDp7ScHjRLkR5ibpnA== X-Received: by 2002:aa7:9298:0:b029:1ed:fd64:e6b7 with SMTP id j24-20020aa792980000b02901edfd64e6b7mr25686117pfa.5.1615296094436; Tue, 09 Mar 2021 05:21:34 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:21:34 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 16/33] counter: stm32-lptimer-cnt: Add const qualifier for actions_list array Date: Tue, 9 Mar 2021 22:19:29 +0900 Message-Id: <01cafeb117b6c12288db7d36ff295ff903397e34.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The struct counter_synapse actions_list member expects a const enum counter_synapse_action array. This patch adds the const qualifier to the stm32_lptim_cnt_synapse_actions to match actions_list. Cc: Fabrice Gasnier Signed-off-by: William Breathitt Gray --- drivers/counter/stm32-lptimer-cnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c index 0f7d3f1ec1b6..c19d998df5ba 100644 --- a/drivers/counter/stm32-lptimer-cnt.c +++ b/drivers/counter/stm32-lptimer-cnt.c @@ -146,7 +146,7 @@ enum stm32_lptim_synapse_action { STM32_LPTIM_SYNAPSE_ACTION_NONE, }; -static enum counter_synapse_action stm32_lptim_cnt_synapse_actions[] = { +static const enum counter_synapse_action stm32_lptim_cnt_synapse_actions[] = { /* Index must match with stm32_lptim_cnt_polarity[] (priv->polarity) */ [STM32_LPTIM_SYNAPSE_ACTION_RISING_EDGE] = COUNTER_SYNAPSE_ACTION_RISING_EDGE, [STM32_LPTIM_SYNAPSE_ACTION_FALLING_EDGE] = COUNTER_SYNAPSE_ACTION_FALLING_EDGE, From patchwork Tue Mar 9 13:19:30 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: 12125181 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 73123C43381 for ; Tue, 9 Mar 2021 13:22:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E868650E6 for ; Tue, 9 Mar 2021 13:22:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230435AbhCINWB (ORCPT ); Tue, 9 Mar 2021 08:22:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230502AbhCINVk (ORCPT ); Tue, 9 Mar 2021 08:21:40 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4006FC06174A; Tue, 9 Mar 2021 05:21:40 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id q204so9361338pfq.10; Tue, 09 Mar 2021 05:21:40 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=K+ywkOKIYI1rUeLTBajU0K1er4fWBGM8+BnI9DpZoy4=; b=llzPUbkZxWj2ssspPIFBoD9My5GmxNP0UdKdVEXdz2zTh/foocktiGWxwlIfJRrW45 FOQPeFWkgFJA6uvgzNbb18ffI2aSIKJaf2Nxh1NOqOr43nJx5WTDzmKwlzYr1lcWwDUc clNvv9Co6ef7KmnE8OQszPLQ4TtmGTF65GqOntoIFFysIoFobvTu6O2G4VGTVNQyJDxo d1T1n//jA+sdhr3RSOgPIrY77OCfVqPS76BZ7+Pk9u10JTdIgL7mUuSUisGCW8n+9uYU pJLL6lkUIBYwiaig6NrOJ9TKFfZraijrjmUYMN7yhxoLuFmGdPhNkp5Y5a8nxQG/MYlI hejw== 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:mime-version:content-transfer-encoding; bh=K+ywkOKIYI1rUeLTBajU0K1er4fWBGM8+BnI9DpZoy4=; b=eID89azRpHPgD4YyORh2znfsy/vUcktjVMhEa1UF5SvHR/l9QYti/iKIZ6OBLNVLm8 05ib97cuYzkoLz9oTC7rTHzxDc2KyW3RmgCOb0d2ixUc7Kz6ktpVtjFbR6PB0w0OJIzT CabkA6KRU+rjzLk8aTuRj6TbIVGcGU7/o3U3yFSGGr3yczk11pesF9lzI+kMlCj7eZeY oYTaumhDIiT/1akb8gNwsQ/xSzMNjoPnl/9CeSIcy2fGkQW0ADPmJhMVQeNMUBOfiDRF AYGNUX78tp1KtG28hdnU2bu/intjRDMxF+zSlTjU5HIXNc0q+gABJyOqZODLi6YAgBcG zALw== X-Gm-Message-State: AOAM530MvbnqW+cRdqnsbanSFqgIoptriE8jWljSBt4u+7qBYgZN7VH8 +0z95jcUg59aLE3HxtT5PqtPbdnFBbnWAQ== X-Google-Smtp-Source: ABdhPJyMLZ5b8EtqeiyGaxx6CJ7F0mX+VStcZ4Cbtooq3osrjRxIYqYrjb9XnyiH4sa4PKgADAZXqg== X-Received: by 2002:a62:928f:0:b029:1ef:2370:2600 with SMTP id o137-20020a62928f0000b02901ef23702600mr24730883pfd.9.1615296099884; Tue, 09 Mar 2021 05:21:39 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:21:39 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray , Benjamin Gaignard Subject: [PATCH v9 17/33] counter: stm32-timer-cnt: Add const qualifier for actions_list array Date: Tue, 9 Mar 2021 22:19:30 +0900 Message-Id: <4d1b80ddf1ec22c70b7b11389a5c14fe209e06c2.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The struct counter_synapse actions_list member expects a const enum counter_synapse_action array. This patch adds the const qualifier to the stm32_synapse_actions to match actions_list. Cc: Fabrice Gasnier Cc: Benjamin Gaignard Signed-off-by: William Breathitt Gray --- drivers/counter/stm32-timer-cnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c index 0c18573a7837..603b30ada839 100644 --- a/drivers/counter/stm32-timer-cnt.c +++ b/drivers/counter/stm32-timer-cnt.c @@ -267,7 +267,7 @@ enum stm32_synapse_action { STM32_SYNAPSE_ACTION_BOTH_EDGES }; -static enum counter_synapse_action stm32_synapse_actions[] = { +static const enum counter_synapse_action stm32_synapse_actions[] = { [STM32_SYNAPSE_ACTION_NONE] = COUNTER_SYNAPSE_ACTION_NONE, [STM32_SYNAPSE_ACTION_BOTH_EDGES] = COUNTER_SYNAPSE_ACTION_BOTH_EDGES }; From patchwork Tue Mar 9 13:19:31 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: 12125189 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 CC441C4332B for ; Tue, 9 Mar 2021 13:22:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6584650E6 for ; Tue, 9 Mar 2021 13:22:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231342AbhCINWB (ORCPT ); Tue, 9 Mar 2021 08:22:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231366AbhCINVp (ORCPT ); Tue, 9 Mar 2021 08:21:45 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB5D9C06174A; Tue, 9 Mar 2021 05:21:45 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id y67so9521108pfb.2; Tue, 09 Mar 2021 05:21:45 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=NsY4hvP6vR3kebyGKLSUcX7e2GsC73FIe/tGpJlrL+E=; b=CzxAejpt6T1ihScgSygWzUdshIWTP9koo4T/FK5ybdV479ghQpXwvuCiqw1TIfz+Fc lvH9fCSBWbsok86OzjGGdWr4VeYTzBm6j2Mf9d4G6HXuwJeZ0ELLBsjpGsOMgxwLHu6H ydsxnpQm6YZ+e+8JA/eKY/yNbNn3H7C/1ZexWqAy5ltP73z/JDh9Ei0jc3cPB+ki/Hg5 xSRzuNllWyDnfZLIAmrYgyu9WqAaIuQdJv+mNLjX/PuoTj1pyPuv18FCvks/Xbfzf57t veV3bOOSNoQdyZ7Pxqv72trO9m6rhzP19mOUYE+v1V3i3AmZOEetTLd3L9B5dHGFsKTD wTdA== 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:mime-version:content-transfer-encoding; bh=NsY4hvP6vR3kebyGKLSUcX7e2GsC73FIe/tGpJlrL+E=; b=tze6xKcRRJtcGYQh7lCjGYjxyb4Yd7ob8viDHL/d4fHxOTAb+6BUZUmG80/9PcwDzJ UeucJG/PAsWCOmeM6k0mItkgyLqcYJEhH8cQchLW4ON4scI3U3Ncp591QnoAeBbla9Ww PqpZ33hFQb229/eMPxgXUTa/Q6ZWidpqs2HxIwUztWfAYa0iYnfpeewxvSAdYMrdpBVY wGxl614brNNgVNzq6oDNIfVbtNUBaDqhNDl08yMR9zUBhe0pt8DhjCwW3ArEPG1EFWen S3afRxr7xrWZ6y9zYK1SXdn2dZk84GNmwwy7wvBEO6i7BUupCgSQobx5cqZNp9ZlYxUq cMjg== X-Gm-Message-State: AOAM531ibQ4auzfteLa0YTzDb23qT7/EL80+mzaeUYKY269+qmIK+D3q Fu+ORak0JTDCg06k/G51wak= X-Google-Smtp-Source: ABdhPJzgrCqjg7OU4ZSKNWl4RO39vCHDj/yCkNuUh/xDwXYHDq6WZbBuOTPji1vP8BVlrz5NNUfwKQ== X-Received: by 2002:aa7:8d84:0:b029:1f8:3449:1bc6 with SMTP id i4-20020aa78d840000b02901f834491bc6mr6482584pfr.76.1615296105432; Tue, 09 Mar 2021 05:21:45 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:21:45 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 18/33] counter: Return error code on invalid modes Date: Tue, 9 Mar 2021 22:19:31 +0900 Message-Id: <22c9bc0a85509df31483b5dcfa50562ba0b16295.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Only a select set of modes (function, action, etc.) are valid for a given device configuration. This patch ensures that invalid modes result in a return -EINVAL. Such a situation should never occur in reality, but it's good to define a default switch cases for the sake of making the intent of the code clear. Cc: Syed Nayyar Waris Cc: Kamel Bouhara Cc: Fabrice Gasnier Cc: Maxime Coquelin Cc: Alexandre Torgue Cc: David Lechner Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 20 +++++++---- drivers/counter/microchip-tcb-capture.c | 6 ++++ drivers/counter/stm32-lptimer-cnt.c | 10 +++--- drivers/counter/ti-eqep.c | 45 +++++++++++-------------- 4 files changed, 46 insertions(+), 35 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index 09d779544969..b7d6c1c43655 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -273,6 +273,10 @@ static int quad8_function_set(struct counter_device *counter, *scale = 2; mode_cfg |= QUAD8_CMR_QUADRATURE_X4; break; + default: + /* should never reach this path */ + mutex_unlock(&priv->lock); + return -EINVAL; } } @@ -349,7 +353,7 @@ static int quad8_action_get(struct counter_device *counter, case QUAD8_COUNT_FUNCTION_PULSE_DIRECTION: if (synapse->signal->id == signal_a_id) *action = QUAD8_SYNAPSE_ACTION_RISING_EDGE; - break; + return 0; case QUAD8_COUNT_FUNCTION_QUADRATURE_X1: if (synapse->signal->id == signal_a_id) { quad8_direction_get(counter, count, &direction); @@ -359,17 +363,18 @@ static int quad8_action_get(struct counter_device *counter, else *action = QUAD8_SYNAPSE_ACTION_FALLING_EDGE; } - break; + return 0; case QUAD8_COUNT_FUNCTION_QUADRATURE_X2: if (synapse->signal->id == signal_a_id) *action = QUAD8_SYNAPSE_ACTION_BOTH_EDGES; - break; + return 0; case QUAD8_COUNT_FUNCTION_QUADRATURE_X4: *action = QUAD8_SYNAPSE_ACTION_BOTH_EDGES; - break; + return 0; + default: + /* should never reach this path */ + return -EINVAL; } - - return 0; } static const struct counter_ops quad8_ops = { @@ -529,6 +534,9 @@ static int quad8_count_mode_set(struct counter_device *counter, case COUNTER_COUNT_MODE_MODULO_N: cnt_mode = 3; break; + default: + /* should never reach this path */ + return -EINVAL; } mutex_lock(&priv->lock); diff --git a/drivers/counter/microchip-tcb-capture.c b/drivers/counter/microchip-tcb-capture.c index 51b8af80f98b..0c9a61962911 100644 --- a/drivers/counter/microchip-tcb-capture.c +++ b/drivers/counter/microchip-tcb-capture.c @@ -133,6 +133,9 @@ static int mchp_tc_count_function_set(struct counter_device *counter, bmr |= ATMEL_TC_QDEN | ATMEL_TC_POSEN; cmr |= ATMEL_TC_ETRGEDG_RISING | ATMEL_TC_ABETRG | ATMEL_TC_XC0; break; + default: + /* should never reach this path */ + return -EINVAL; } regmap_write(priv->regmap, ATMEL_TC_BMR, bmr); @@ -226,6 +229,9 @@ static int mchp_tc_count_action_set(struct counter_device *counter, case MCHP_TC_SYNAPSE_ACTION_BOTH_EDGE: edge = ATMEL_TC_ETRGEDG_BOTH; break; + default: + /* should never reach this path */ + return -EINVAL; } return regmap_write_bits(priv->regmap, diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c index c19d998df5ba..78f383b77bd2 100644 --- a/drivers/counter/stm32-lptimer-cnt.c +++ b/drivers/counter/stm32-lptimer-cnt.c @@ -206,9 +206,10 @@ static int stm32_lptim_cnt_function_set(struct counter_device *counter, priv->quadrature_mode = 1; priv->polarity = STM32_LPTIM_SYNAPSE_ACTION_BOTH_EDGES; return 0; + default: + /* should never reach this path */ + return -EINVAL; } - - return -EINVAL; } static ssize_t stm32_lptim_cnt_enable_read(struct counter_device *counter, @@ -326,9 +327,10 @@ static int stm32_lptim_cnt_action_get(struct counter_device *counter, case STM32_LPTIM_ENCODER_BOTH_EDGE: *action = priv->polarity; return 0; + default: + /* should never reach this path */ + return -EINVAL; } - - return -EINVAL; } static int stm32_lptim_cnt_action_set(struct counter_device *counter, diff --git a/drivers/counter/ti-eqep.c b/drivers/counter/ti-eqep.c index 65df9ef5b5bc..878725c2f010 100644 --- a/drivers/counter/ti-eqep.c +++ b/drivers/counter/ti-eqep.c @@ -157,44 +157,39 @@ static int ti_eqep_action_get(struct counter_device *counter, * QEPA and QEPB trigger QCLK. */ *action = TI_EQEP_SYNAPSE_ACTION_BOTH_EDGES; - break; + return 0; case TI_EQEP_COUNT_FUNC_DIR_COUNT: /* In direction-count mode only rising edge of QEPA is counted * and QEPB gives direction. */ - switch (synapse->signal->id) { - case TI_EQEP_SIGNAL_QEPA: - *action = TI_EQEP_SYNAPSE_ACTION_RISING_EDGE; - break; - default: + if (synapse->signal->id == TI_EQEP_SIGNAL_QEPB) *action = TI_EQEP_SYNAPSE_ACTION_NONE; - break; - } - break; + else + *action = TI_EQEP_SYNAPSE_ACTION_RISING_EDGE; + return 0; case TI_EQEP_COUNT_FUNC_UP_COUNT: case TI_EQEP_COUNT_FUNC_DOWN_COUNT: /* In up/down-count modes only QEPA is counted and QEPB is not * used. */ - switch (synapse->signal->id) { - case TI_EQEP_SIGNAL_QEPA: - err = regmap_read(priv->regmap16, QDECCTL, &qdecctl); - if (err) - return err; - - if (qdecctl & QDECCTL_XCR) - *action = TI_EQEP_SYNAPSE_ACTION_BOTH_EDGES; - else - *action = TI_EQEP_SYNAPSE_ACTION_RISING_EDGE; - break; - default: + if (synapse->signal->id == TI_EQEP_SIGNAL_QEPB) { *action = TI_EQEP_SYNAPSE_ACTION_NONE; - break; + return 0; } - break; - } - return 0; + err = regmap_read(priv->regmap16, QDECCTL, &qdecctl); + if (err) + return err; + + if (qdecctl & QDECCTL_XCR) + *action = TI_EQEP_SYNAPSE_ACTION_BOTH_EDGES; + else + *action = TI_EQEP_SYNAPSE_ACTION_RISING_EDGE; + return 0; + default: + /* should never reach this path */ + return -EINVAL; + } } static const struct counter_ops ti_eqep_counter_ops = { From patchwork Tue Mar 9 13:19:32 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: 12125187 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 44C5AC43331 for ; Tue, 9 Mar 2021 13:22:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19911650E6 for ; Tue, 9 Mar 2021 13:22:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231405AbhCINWC (ORCPT ); Tue, 9 Mar 2021 08:22:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231668AbhCINVv (ORCPT ); Tue, 9 Mar 2021 08:21:51 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AA1BC06174A; Tue, 9 Mar 2021 05:21:51 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id t29so9340770pfg.11; Tue, 09 Mar 2021 05:21:51 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=xBOjIvBEx7zNTTNiL0i0jumW/DpoGf2xNUhJv3RRJNM=; b=JOwllKhQNc2ZYTn9eNxf6x2/3Mexv3Bg4SwcbtPIy+9qnMpG1dvDsP/XaQfzR35bPK a9u1HyGuURMORUb3G9jqZ4QHyFTO4hPv5yBIeIZQIiykh7DfQ9YKpALQbEQKoyfTgWm7 rHmrG/TQ6tqZ2mht+ZMH7CoTyZOtgbz0R9ckFDqxdmhtYhDgoCAIeLfawmpiugVuVQoJ a3hWPLlZP8y1NZ4vTJKlQGjwzbwklR9dsFSQ/4G0mwDdRfy4+SMZmh+7Lw9GFm0DHCHa jrNpre8mCaglaVIRiFoP8tO8UncjT5ww7nKEyjMaqSZrJcZ12gF59iekbsutr+bJv4hO cOMA== 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:mime-version:content-transfer-encoding; bh=xBOjIvBEx7zNTTNiL0i0jumW/DpoGf2xNUhJv3RRJNM=; b=J9sk1kdiSpSULVjl1mtaOec/V87VvdWkU0yx6fnNvQQQfwH1kupd0q7iJa6ABiIvGr XqwXiRC+xRLfNaNHAMSotTTVQzS7GCJKPNJwdtIS/jbSXQPlKbvbb5OxApM8Qn9xq2KM nyztcxbCuBuRDNcpIgdx4pTe6xwQXn33HoJQcvAVTyChJ5vPxn3FAG8Ynytn1ugBO7tZ x5b7D3EFQ+YQgrouuQsTecjhfl8x00iwuRxFao2biNuZzlkZ4Ms39H7+2Z9l51XB4XTt ubtBw+N1RxF6NUwPcqjQlGN+zqAxpcxWZOLNWIRSt4IsDuFwxkW+/mb8UKVbm3nlsiMz RJfQ== X-Gm-Message-State: AOAM533xMgs77bMK6OnRW+mbgBV09JUO96FZr9ZlpVLpi6LvzopgWSGo l909aqccvLw2AMe9m3Y0yCs= X-Google-Smtp-Source: ABdhPJy2zbMwdBSGPR3dx1mMoqiMQh+zfCG7RLUlUDLCF1Ho5wLeEo9bj9hqdskuk9EJ6DI2k2fogw== X-Received: by 2002:a65:53ca:: with SMTP id z10mr24946840pgr.271.1615296110710; Tue, 09 Mar 2021 05:21:50 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.21.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:21:50 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 19/33] counter: Standardize to ERANGE for limit exceeded errors Date: Tue, 9 Mar 2021 22:19:32 +0900 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org ERANGE is a semantically better error code to return when an argument value falls outside the supported limit range of a device. Cc: Syed Nayyar Waris Cc: Oleksij Rempel Cc: Fabrice Gasnier Cc: Maxime Coquelin Cc: Alexandre Torgue Reviewed-by: David Lechner Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 6 +++--- drivers/counter/interrupt-cnt.c | 3 +++ drivers/counter/stm32-lptimer-cnt.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index b7d6c1c43655..0409b1771fd9 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -154,7 +154,7 @@ static int quad8_count_write(struct counter_device *counter, /* Only 24-bit values are supported */ if (val > 0xFFFFFF) - return -EINVAL; + return -ERANGE; mutex_lock(&priv->lock); @@ -669,7 +669,7 @@ static ssize_t quad8_count_preset_write(struct counter_device *counter, /* Only 24-bit values are supported */ if (preset > 0xFFFFFF) - return -EINVAL; + return -ERANGE; mutex_lock(&priv->lock); @@ -714,7 +714,7 @@ static ssize_t quad8_count_ceiling_write(struct counter_device *counter, /* Only 24-bit values are supported */ if (ceiling > 0xFFFFFF) - return -EINVAL; + return -ERANGE; mutex_lock(&priv->lock); diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c index 0e07607f2cd3..f27dea317965 100644 --- a/drivers/counter/interrupt-cnt.c +++ b/drivers/counter/interrupt-cnt.c @@ -107,6 +107,9 @@ static int interrupt_cnt_write(struct counter_device *counter, { struct interrupt_cnt_priv *priv = counter->priv; + if (val != (typeof(priv->count.counter))val) + return -ERANGE; + atomic_set(&priv->count, val); return 0; diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c index 78f383b77bd2..49aeb9e393f3 100644 --- a/drivers/counter/stm32-lptimer-cnt.c +++ b/drivers/counter/stm32-lptimer-cnt.c @@ -283,7 +283,7 @@ static ssize_t stm32_lptim_cnt_ceiling_write(struct counter_device *counter, return ret; if (ceiling > STM32_LPTIM_MAX_ARR) - return -EINVAL; + return -ERANGE; priv->ceiling = ceiling; From patchwork Tue Mar 9 13:19:33 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: 12125185 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 02992C4332E for ; Tue, 9 Mar 2021 13:22:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C45D164EBB for ; Tue, 9 Mar 2021 13:22:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231424AbhCINWC (ORCPT ); Tue, 9 Mar 2021 08:22:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbhCINV4 (ORCPT ); Tue, 9 Mar 2021 08:21:56 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2109DC06174A; Tue, 9 Mar 2021 05:21:56 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id fu20so888127pjb.2; Tue, 09 Mar 2021 05:21:56 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=DEdrckemkYx8poMfzLkSrC8voq/zhDbA2hHX3mjuC00=; b=gSm3nOAhQpNaoc9DhpyynvRflsKnVrTliD/EKys5s2XaVe3XdtcPZitAtkRfA2Ue7e kyDInGmi75lZDn2yQcOQ1K36tp7klrINgBQ6hId4ltFEpVDMnv41uWrvh0Z7Dxcrroee y8OA0VAefY5uKssVhZWUfxKRn4/eCO2OvG7QkgNpGJHGMbmywieml8kU+jrSiep2aNeZ tm5xDd+huO1imAR65vXf7AWIYGvTzV2O8BdTeYwutzEXFtgSnDHxAyTVmyGvrRMcwUgA uN359zIPB6H00sUNdd8saIO6urHL4Vrmq1wQuqESkap0b7nKWO50UN/OaEwAFlIS2Pln uCQA== 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:mime-version:content-transfer-encoding; bh=DEdrckemkYx8poMfzLkSrC8voq/zhDbA2hHX3mjuC00=; b=XuAfGXShPyCvWKkszuiDUHjMRPQW8f995m0NCjXhk9KWDMipQqv9C7A7r0Jhhcq+sG S1M4GCAgcJEr5rib721Csopj6P0pnNMbqFulQMtKye8GkkMPfPWu+hxt9xsf3y8Qrpog EIlFU8y19AztnrBbE457P745cY0uSEB4xhhsA8tTQLWGSS2EOkOecGHE+zMEoceCHQ21 k++WH4ufoifUdg84hQC8+6CwSBju4UQWml5Xm1jjNO2KCtGmItsZ5DBUOVmlVYpOYKCa yfV57SVAWTszW1eyThH3wzFpVc9xtdSaOsa7tlbzaAI8L35Jpx3MYvOKlvDMP9F9h3fz kObg== X-Gm-Message-State: AOAM531zWGYcV2HGq8YEpbaw17XXGBdcqwNur8HLJO0h4mFKnd9xumtv Xo1tQ08VWWVuLiSUzTPBkbA= X-Google-Smtp-Source: ABdhPJxikR/4OBFVRgIgoR6k3L4k6CVzNZEZcGEhKBe+7N0nCIU0wUPQOunrdVHaAsSWDpONqyL7yg== X-Received: by 2002:a17:90a:8:: with SMTP id 8mr4736713pja.6.1615296115742; Tue, 09 Mar 2021 05:21:55 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:21:55 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 20/33] counter: Rename counter_signal_value to counter_signal_level Date: Tue, 9 Mar 2021 22:19:33 +0900 Message-Id: <4aadcb1779d212e01c89d052926bbc422fd12174.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Signal values will always be levels so let's be explicit it about it to make the intent of the code clear. Cc: Syed Nayyar Waris Cc: Oleksij Rempel Cc: Kamel Bouhara Reviewed-by: David Lechner Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 5 +++-- drivers/counter/counter.c | 12 ++++++------ drivers/counter/interrupt-cnt.c | 4 ++-- drivers/counter/microchip-tcb-capture.c | 4 ++-- include/linux/counter.h | 12 ++++++------ 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index 0409b1771fd9..fb0f021c0751 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -97,7 +97,8 @@ struct quad8 { #define QUAD8_CMR_QUADRATURE_X4 0x18 static int quad8_signal_read(struct counter_device *counter, - struct counter_signal *signal, enum counter_signal_value *val) + struct counter_signal *signal, + enum counter_signal_level *level) { const struct quad8 *const priv = counter->priv; unsigned int state; @@ -109,7 +110,7 @@ static int quad8_signal_read(struct counter_device *counter, state = inb(priv->base + QUAD8_REG_INDEX_INPUT_LEVELS) & BIT(signal->id - 16); - *val = (state) ? COUNTER_SIGNAL_HIGH : COUNTER_SIGNAL_LOW; + *level = (state) ? COUNTER_SIGNAL_LEVEL_HIGH : COUNTER_SIGNAL_LEVEL_LOW; return 0; } diff --git a/drivers/counter/counter.c b/drivers/counter/counter.c index 6a683d086008..cb92673552b5 100644 --- a/drivers/counter/counter.c +++ b/drivers/counter/counter.c @@ -289,9 +289,9 @@ struct counter_signal_unit { struct counter_signal *signal; }; -static const char *const counter_signal_value_str[] = { - [COUNTER_SIGNAL_LOW] = "low", - [COUNTER_SIGNAL_HIGH] = "high" +static const char *const counter_signal_level_str[] = { + [COUNTER_SIGNAL_LEVEL_LOW] = "low", + [COUNTER_SIGNAL_LEVEL_HIGH] = "high" }; static ssize_t counter_signal_show(struct device *dev, @@ -302,13 +302,13 @@ static ssize_t counter_signal_show(struct device *dev, const struct counter_signal_unit *const component = devattr->component; struct counter_signal *const signal = component->signal; int err; - enum counter_signal_value val; + enum counter_signal_level level; - err = counter->ops->signal_read(counter, signal, &val); + err = counter->ops->signal_read(counter, signal, &level); if (err) return err; - return sprintf(buf, "%s\n", counter_signal_value_str[val]); + return sprintf(buf, "%s\n", counter_signal_level_str[level]); } struct counter_name_unit { diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c index f27dea317965..cce579c1c6ae 100644 --- a/drivers/counter/interrupt-cnt.c +++ b/drivers/counter/interrupt-cnt.c @@ -130,7 +130,7 @@ static int interrupt_cnt_function_get(struct counter_device *counter, static int interrupt_cnt_signal_read(struct counter_device *counter, struct counter_signal *signal, - enum counter_signal_value *val) + enum counter_signal_level *level) { struct interrupt_cnt_priv *priv = counter->priv; int ret; @@ -142,7 +142,7 @@ static int interrupt_cnt_signal_read(struct counter_device *counter, if (ret < 0) return ret; - *val = ret ? COUNTER_SIGNAL_HIGH : COUNTER_SIGNAL_LOW; + *level = ret ? COUNTER_SIGNAL_LEVEL_HIGH : COUNTER_SIGNAL_LEVEL_LOW; return 0; } diff --git a/drivers/counter/microchip-tcb-capture.c b/drivers/counter/microchip-tcb-capture.c index 0c9a61962911..6be3adf74114 100644 --- a/drivers/counter/microchip-tcb-capture.c +++ b/drivers/counter/microchip-tcb-capture.c @@ -158,7 +158,7 @@ static int mchp_tc_count_function_set(struct counter_device *counter, static int mchp_tc_count_signal_read(struct counter_device *counter, struct counter_signal *signal, - enum counter_signal_value *val) + enum counter_signal_level *lvl) { struct mchp_tc_data *const priv = counter->priv; bool sigstatus; @@ -171,7 +171,7 @@ static int mchp_tc_count_signal_read(struct counter_device *counter, else sigstatus = (sr & ATMEL_TC_MTIOA); - *val = sigstatus ? COUNTER_SIGNAL_HIGH : COUNTER_SIGNAL_LOW; + *lvl = sigstatus ? COUNTER_SIGNAL_LEVEL_HIGH : COUNTER_SIGNAL_LEVEL_LOW; return 0; } diff --git a/include/linux/counter.h b/include/linux/counter.h index 9dbd5df4cd34..79f5dcaf6ba0 100644 --- a/include/linux/counter.h +++ b/include/linux/counter.h @@ -290,16 +290,16 @@ struct counter_device_state { const struct attribute_group **groups; }; -enum counter_signal_value { - COUNTER_SIGNAL_LOW = 0, - COUNTER_SIGNAL_HIGH +enum counter_signal_level { + COUNTER_SIGNAL_LEVEL_LOW, + COUNTER_SIGNAL_LEVEL_HIGH, }; /** * struct counter_ops - Callbacks from driver * @signal_read: optional read callback for Signal attribute. The read - * value of the respective Signal should be passed back via - * the val parameter. + * level of the respective Signal should be passed back via + * the level parameter. * @count_read: optional read callback for Count attribute. The read * value of the respective Count should be passed back via * the val parameter. @@ -324,7 +324,7 @@ enum counter_signal_value { struct counter_ops { int (*signal_read)(struct counter_device *counter, struct counter_signal *signal, - enum counter_signal_value *val); + enum counter_signal_level *level); int (*count_read)(struct counter_device *counter, struct counter_count *count, unsigned long *val); int (*count_write)(struct counter_device *counter, From patchwork Tue Mar 9 13:19:34 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: 12125191 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 A9CF3C433DB for ; Tue, 9 Mar 2021 13:23:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DBE2650E6 for ; Tue, 9 Mar 2021 13:23:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231359AbhCINWa (ORCPT ); Tue, 9 Mar 2021 08:22:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231355AbhCINWB (ORCPT ); Tue, 9 Mar 2021 08:22:01 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8693FC06174A; Tue, 9 Mar 2021 05:22:01 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id d8so6539446plg.10; Tue, 09 Mar 2021 05:22:01 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=gnU5Pm8nqREuMtBgFRKsnhWdy4fN/VawToX+PaXXPmg=; b=AKv25vTf2CelPIchffe4er/oUhEyJvYhyLjugxhPZZ9R6iqLQADzDQmKHaT8sXfXfv ZEFVyPU9znKHil8WKFy58cjiYnoKeO2NjTfNuDjoXA4MV6gLGYHcwMmrhpkdhRuBuYYf 3iq8z3+hmxpbInfgzkUBOqGtL+ugqkhCBycEUndpTr23Ixgy3O0Teehk0pBncAH3TgCS g5ZoasWfAbHuZOnkJLYZKbLrC2+c2trqC9TS3KFsoxcg9z98T368SGar2PYwq8E22ekV CIxQTLFe1lt/YacscgY1qvudlU9R1p0JZJLQQjT3sC4FzODcKHtj9Yo8cYxZEyTWi9iv jVRg== 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:mime-version:content-transfer-encoding; bh=gnU5Pm8nqREuMtBgFRKsnhWdy4fN/VawToX+PaXXPmg=; b=ocf+guclPLyRBZb8J6D0gjYaiHBWytEVWgi6lTUvi3Sy5v252Bfvir/V+mcGNTShod ewawbK1FDHjh4u41CQPwgXxBEDD890sK59NGHWRgziv3rpS5gTH2JB8NzpjALyrMts+f A03rdpTriELGZkJgmkBjL6DY5xxsmt2bEyTDk4Y2+ZK4RT59pU9qpWnnKB6iXILYrBIO X8hsxVHO/qka2So9ot0JqoWFM8TdPJRQbyV8J5BHCm6G3yRF7nnHIiMrA/4N88ls8R9M oLKnlzQgVn89phChN2BjiFFj/5Ls64+XDZFbow2lnAKsVuUQbSfR/btTm4WeC51VPzW8 qCxg== X-Gm-Message-State: AOAM532SlBW29LcsFjEL+RwEFduNjgGg7GD9IuQ+2XqT1Fl82a7bN3/7 JbV1Jws3viR0KQdcfXJQJ4M= X-Google-Smtp-Source: ABdhPJxTzNydqEWcZX7gRHVIa/ZtNzfU4PFlJEfw5rI0AfU549KZVSfNN/pSrzeOqOxAnkiRkobzRg== X-Received: by 2002:a17:903:31cc:b029:e4:bd48:c8e3 with SMTP id v12-20020a17090331ccb02900e4bd48c8e3mr25435136ple.40.1615296120781; Tue, 09 Mar 2021 05:22:00 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.21.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:00 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 21/33] counter: Rename counter_count_function to counter_function Date: Tue, 9 Mar 2021 22:19:34 +0900 Message-Id: <8f99d204361a00ecab243cc35db27ac2b3943d16.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The phrase "Counter Count function" is verbose and unintentionally implies that function is a Count extension. This patch adjusts the Counter subsystem code to use the more direct "Counter function" phrase to make the intent of this code clearer. Cc: Syed Nayyar Waris Cc: Patrick Havelange Cc: Oleksij Rempel Cc: Kamel Bouhara Cc: Fabrice Gasnier Cc: Maxime Coquelin Cc: Alexandre Torgue Cc: David Lechner Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 10 +++---- drivers/counter/counter.c | 38 ++++++++++++------------- drivers/counter/ftm-quaddec.c | 5 ++-- drivers/counter/interrupt-cnt.c | 4 +-- drivers/counter/microchip-tcb-capture.c | 4 +-- drivers/counter/stm32-lptimer-cnt.c | 6 ++-- drivers/counter/stm32-timer-cnt.c | 10 +++---- drivers/counter/ti-eqep.c | 10 +++---- include/linux/counter.h | 20 ++++++------- 9 files changed, 53 insertions(+), 54 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index fb0f021c0751..5a49ace2d4a6 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -194,11 +194,11 @@ enum quad8_count_function { QUAD8_COUNT_FUNCTION_QUADRATURE_X4 }; -static const enum counter_count_function quad8_count_functions_list[] = { - [QUAD8_COUNT_FUNCTION_PULSE_DIRECTION] = COUNTER_COUNT_FUNCTION_PULSE_DIRECTION, - [QUAD8_COUNT_FUNCTION_QUADRATURE_X1] = COUNTER_COUNT_FUNCTION_QUADRATURE_X1_A, - [QUAD8_COUNT_FUNCTION_QUADRATURE_X2] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_A, - [QUAD8_COUNT_FUNCTION_QUADRATURE_X4] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4 +static const enum counter_function quad8_count_functions_list[] = { + [QUAD8_COUNT_FUNCTION_PULSE_DIRECTION] = COUNTER_FUNCTION_PULSE_DIRECTION, + [QUAD8_COUNT_FUNCTION_QUADRATURE_X1] = COUNTER_FUNCTION_QUADRATURE_X1_A, + [QUAD8_COUNT_FUNCTION_QUADRATURE_X2] = COUNTER_FUNCTION_QUADRATURE_X2_A, + [QUAD8_COUNT_FUNCTION_QUADRATURE_X4] = COUNTER_FUNCTION_QUADRATURE_X4 }; static int quad8_function_get(struct counter_device *counter, diff --git a/drivers/counter/counter.c b/drivers/counter/counter.c index cb92673552b5..de921e8a3f72 100644 --- a/drivers/counter/counter.c +++ b/drivers/counter/counter.c @@ -744,15 +744,15 @@ static ssize_t counter_count_store(struct device *dev, return len; } -static const char *const counter_count_function_str[] = { - [COUNTER_COUNT_FUNCTION_INCREASE] = "increase", - [COUNTER_COUNT_FUNCTION_DECREASE] = "decrease", - [COUNTER_COUNT_FUNCTION_PULSE_DIRECTION] = "pulse-direction", - [COUNTER_COUNT_FUNCTION_QUADRATURE_X1_A] = "quadrature x1 a", - [COUNTER_COUNT_FUNCTION_QUADRATURE_X1_B] = "quadrature x1 b", - [COUNTER_COUNT_FUNCTION_QUADRATURE_X2_A] = "quadrature x2 a", - [COUNTER_COUNT_FUNCTION_QUADRATURE_X2_B] = "quadrature x2 b", - [COUNTER_COUNT_FUNCTION_QUADRATURE_X4] = "quadrature x4" +static const char *const counter_function_str[] = { + [COUNTER_FUNCTION_INCREASE] = "increase", + [COUNTER_FUNCTION_DECREASE] = "decrease", + [COUNTER_FUNCTION_PULSE_DIRECTION] = "pulse-direction", + [COUNTER_FUNCTION_QUADRATURE_X1_A] = "quadrature x1 a", + [COUNTER_FUNCTION_QUADRATURE_X1_B] = "quadrature x1 b", + [COUNTER_FUNCTION_QUADRATURE_X2_A] = "quadrature x2 a", + [COUNTER_FUNCTION_QUADRATURE_X2_B] = "quadrature x2 b", + [COUNTER_FUNCTION_QUADRATURE_X4] = "quadrature x4" }; static ssize_t counter_function_show(struct device *dev, @@ -764,7 +764,7 @@ static ssize_t counter_function_show(struct device *dev, const struct counter_count_unit *const component = devattr->component; struct counter_count *const count = component->count; size_t func_index; - enum counter_count_function function; + enum counter_function function; err = counter->ops->function_get(counter, count, &func_index); if (err) @@ -773,7 +773,7 @@ static ssize_t counter_function_show(struct device *dev, count->function = func_index; function = count->functions_list[func_index]; - return sprintf(buf, "%s\n", counter_count_function_str[function]); + return sprintf(buf, "%s\n", counter_function_str[function]); } static ssize_t counter_function_store(struct device *dev, @@ -785,14 +785,14 @@ static ssize_t counter_function_store(struct device *dev, struct counter_count *const count = component->count; const size_t num_functions = count->num_functions; size_t func_index; - enum counter_count_function function; + enum counter_function function; int err; struct counter_device *const counter = dev_get_drvdata(dev); /* Find requested Count function mode */ for (func_index = 0; func_index < num_functions; func_index++) { function = count->functions_list[func_index]; - if (sysfs_streq(buf, counter_count_function_str[function])) + if (sysfs_streq(buf, counter_function_str[function])) break; } /* Return error if requested Count function mode not found */ @@ -880,25 +880,25 @@ static int counter_count_ext_register( } struct counter_func_avail_unit { - const enum counter_count_function *functions_list; + const enum counter_function *functions_list; size_t num_functions; }; -static ssize_t counter_count_function_available_show(struct device *dev, +static ssize_t counter_function_available_show(struct device *dev, struct device_attribute *attr, char *buf) { const struct counter_device_attr *const devattr = to_counter_attr(attr); const struct counter_func_avail_unit *const component = devattr->component; - const enum counter_count_function *const func_list = component->functions_list; + const enum counter_function *const func_list = component->functions_list; const size_t num_functions = component->num_functions; size_t i; - enum counter_count_function function; + enum counter_function function; ssize_t len = 0; for (i = 0; i < num_functions; i++) { function = func_list[i]; len += sprintf(buf + len, "%s\n", - counter_count_function_str[function]); + counter_function_str[function]); } return len; @@ -968,7 +968,7 @@ static int counter_count_attributes_create( parm.group = group; parm.prefix = ""; parm.name = "function_available"; - parm.show = counter_count_function_available_show; + parm.show = counter_function_available_show; parm.store = NULL; parm.component = avail_comp; err = counter_attribute_create(&parm); diff --git a/drivers/counter/ftm-quaddec.c b/drivers/counter/ftm-quaddec.c index 9371532406ca..53c15f84909b 100644 --- a/drivers/counter/ftm-quaddec.c +++ b/drivers/counter/ftm-quaddec.c @@ -171,9 +171,8 @@ enum ftm_quaddec_count_function { FTM_QUADDEC_COUNT_ENCODER_MODE_1, }; -static const enum counter_count_function ftm_quaddec_count_functions[] = { - [FTM_QUADDEC_COUNT_ENCODER_MODE_1] = - COUNTER_COUNT_FUNCTION_QUADRATURE_X4 +static const enum counter_function ftm_quaddec_count_functions[] = { + [FTM_QUADDEC_COUNT_ENCODER_MODE_1] = COUNTER_FUNCTION_QUADRATURE_X4 }; static int ftm_quaddec_count_read(struct counter_device *counter, diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c index cce579c1c6ae..3dbb8acc67eb 100644 --- a/drivers/counter/interrupt-cnt.c +++ b/drivers/counter/interrupt-cnt.c @@ -115,8 +115,8 @@ static int interrupt_cnt_write(struct counter_device *counter, return 0; } -static const enum counter_count_function interrupt_cnt_functions[] = { - COUNTER_COUNT_FUNCTION_INCREASE, +static const enum counter_function interrupt_cnt_functions[] = { + COUNTER_FUNCTION_INCREASE, }; static int interrupt_cnt_function_get(struct counter_device *counter, diff --git a/drivers/counter/microchip-tcb-capture.c b/drivers/counter/microchip-tcb-capture.c index 6be3adf74114..4c57d43e7d66 100644 --- a/drivers/counter/microchip-tcb-capture.c +++ b/drivers/counter/microchip-tcb-capture.c @@ -38,8 +38,8 @@ enum mchp_tc_count_function { }; static const enum counter_count_function mchp_tc_count_functions[] = { - [MCHP_TC_FUNCTION_INCREASE] = COUNTER_COUNT_FUNCTION_INCREASE, - [MCHP_TC_FUNCTION_QUADRATURE] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4, + [MCHP_TC_FUNCTION_INCREASE] = COUNTER_FUNCTION_INCREASE, + [MCHP_TC_FUNCTION_QUADRATURE] = COUNTER_FUNCTION_QUADRATURE_X4, }; enum mchp_tc_synapse_action { diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c index 49aeb9e393f3..13656957c45f 100644 --- a/drivers/counter/stm32-lptimer-cnt.c +++ b/drivers/counter/stm32-lptimer-cnt.c @@ -134,9 +134,9 @@ enum stm32_lptim_cnt_function { STM32_LPTIM_ENCODER_BOTH_EDGE, }; -static const enum counter_count_function stm32_lptim_cnt_functions[] = { - [STM32_LPTIM_COUNTER_INCREASE] = COUNTER_COUNT_FUNCTION_INCREASE, - [STM32_LPTIM_ENCODER_BOTH_EDGE] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4, +static const enum counter_function stm32_lptim_cnt_functions[] = { + [STM32_LPTIM_COUNTER_INCREASE] = COUNTER_FUNCTION_INCREASE, + [STM32_LPTIM_ENCODER_BOTH_EDGE] = COUNTER_FUNCTION_QUADRATURE_X4, }; enum stm32_lptim_synapse_action { diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c index 603b30ada839..3fb0debd7425 100644 --- a/drivers/counter/stm32-timer-cnt.c +++ b/drivers/counter/stm32-timer-cnt.c @@ -50,11 +50,11 @@ enum stm32_count_function { STM32_COUNT_ENCODER_MODE_3, }; -static const enum counter_count_function stm32_count_functions[] = { - [STM32_COUNT_SLAVE_MODE_DISABLED] = COUNTER_COUNT_FUNCTION_INCREASE, - [STM32_COUNT_ENCODER_MODE_1] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_A, - [STM32_COUNT_ENCODER_MODE_2] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_B, - [STM32_COUNT_ENCODER_MODE_3] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4, +static const enum counter_function stm32_count_functions[] = { + [STM32_COUNT_SLAVE_MODE_DISABLED] = COUNTER_FUNCTION_INCREASE, + [STM32_COUNT_ENCODER_MODE_1] = COUNTER_FUNCTION_QUADRATURE_X2_A, + [STM32_COUNT_ENCODER_MODE_2] = COUNTER_FUNCTION_QUADRATURE_X2_B, + [STM32_COUNT_ENCODER_MODE_3] = COUNTER_FUNCTION_QUADRATURE_X4, }; static int stm32_count_read(struct counter_device *counter, diff --git a/drivers/counter/ti-eqep.c b/drivers/counter/ti-eqep.c index 878725c2f010..04be25ebf4a4 100644 --- a/drivers/counter/ti-eqep.c +++ b/drivers/counter/ti-eqep.c @@ -284,11 +284,11 @@ static struct counter_signal ti_eqep_signals[] = { }, }; -static const enum counter_count_function ti_eqep_position_functions[] = { - [TI_EQEP_COUNT_FUNC_QUAD_COUNT] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4, - [TI_EQEP_COUNT_FUNC_DIR_COUNT] = COUNTER_COUNT_FUNCTION_PULSE_DIRECTION, - [TI_EQEP_COUNT_FUNC_UP_COUNT] = COUNTER_COUNT_FUNCTION_INCREASE, - [TI_EQEP_COUNT_FUNC_DOWN_COUNT] = COUNTER_COUNT_FUNCTION_DECREASE, +static const enum counter_function ti_eqep_position_functions[] = { + [TI_EQEP_COUNT_FUNC_QUAD_COUNT] = COUNTER_FUNCTION_QUADRATURE_X4, + [TI_EQEP_COUNT_FUNC_DIR_COUNT] = COUNTER_FUNCTION_PULSE_DIRECTION, + [TI_EQEP_COUNT_FUNC_UP_COUNT] = COUNTER_FUNCTION_INCREASE, + [TI_EQEP_COUNT_FUNC_DOWN_COUNT] = COUNTER_FUNCTION_DECREASE, }; static const enum counter_synapse_action ti_eqep_position_synapse_actions[] = { diff --git a/include/linux/counter.h b/include/linux/counter.h index 79f5dcaf6ba0..d16ce2819b48 100644 --- a/include/linux/counter.h +++ b/include/linux/counter.h @@ -162,15 +162,15 @@ struct counter_count_ext { void *priv; }; -enum counter_count_function { - COUNTER_COUNT_FUNCTION_INCREASE = 0, - COUNTER_COUNT_FUNCTION_DECREASE, - COUNTER_COUNT_FUNCTION_PULSE_DIRECTION, - COUNTER_COUNT_FUNCTION_QUADRATURE_X1_A, - COUNTER_COUNT_FUNCTION_QUADRATURE_X1_B, - COUNTER_COUNT_FUNCTION_QUADRATURE_X2_A, - COUNTER_COUNT_FUNCTION_QUADRATURE_X2_B, - COUNTER_COUNT_FUNCTION_QUADRATURE_X4 +enum counter_function { + COUNTER_FUNCTION_INCREASE = 0, + COUNTER_FUNCTION_DECREASE, + COUNTER_FUNCTION_PULSE_DIRECTION, + COUNTER_FUNCTION_QUADRATURE_X1_A, + COUNTER_FUNCTION_QUADRATURE_X1_B, + COUNTER_FUNCTION_QUADRATURE_X2_A, + COUNTER_FUNCTION_QUADRATURE_X2_B, + COUNTER_FUNCTION_QUADRATURE_X4 }; /** @@ -192,7 +192,7 @@ struct counter_count { const char *name; size_t function; - const enum counter_count_function *functions_list; + const enum counter_function *functions_list; size_t num_functions; struct counter_synapse *synapses; From patchwork Tue Mar 9 13:19:36 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: 12125195 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 59512C433E9 for ; Tue, 9 Mar 2021 13:23:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15DA0650ED for ; Tue, 9 Mar 2021 13:23:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231226AbhCINWd (ORCPT ); Tue, 9 Mar 2021 08:22:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbhCINWN (ORCPT ); Tue, 9 Mar 2021 08:22:13 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49CFBC06174A; Tue, 9 Mar 2021 05:22:13 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id q204so9362236pfq.10; Tue, 09 Mar 2021 05:22:13 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=spjhsDWsVmp1rYIFmfvPTKmpLE6A3E8vWL8uxeu2qR0=; b=vhQn/aeItqL6OlE36cHKbo1p2bsZLXE9P7CX9xjwOZB7oDsb5h7w1bKIwYADxUFf0/ idAcobrHnOa8HoAFrZO5tX/mHqb5Zu0kGezle6FdBAzZHEtPAFSKjU2ebN4o0tyioREQ bC+xyND4aFJ8pIZAQDbumlbj3RQzZx9luh0J5/GAQRMh3uju1q0FqhZvIigS62KtwbKp +Tbz+AeUKymJaCPIG3LCCBQroqWhtv9REnly5j3ARcFjlv3QZpQ8vnR7ALJAqF3Ln0TJ ZhpqPZ3zfh2vq8Y6UdAHtTdqMkMW08+LEqN7qh8wnHCrgByni5GrHAdqGE1p7qKfb8tM FXvg== 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:mime-version:content-transfer-encoding; bh=spjhsDWsVmp1rYIFmfvPTKmpLE6A3E8vWL8uxeu2qR0=; b=LxXGRyGJz4aIXOTrUe4H5ZfSu6FIpCAsI8iDNBtKtlGXbmgZ6bSRt6QrKkLs+4ZLUD fbARtfHdAA2k37jDLgHMc1KeVN/3znhwBTTdseuJxvqUw2tJ6u7V1PzoKhOqczF5FFpG L3epO8kccLtz52P36gDkpHRA3webCUS4LKa1CcM440gpL7KGVk0fRk5Dn4z0dn/FYn3J EO0fX4JHueiFWSVXHZWKBLcPbAXJhP+ndKseHpPnNkOT9KhTOx6oCQjIG3BNDwkf70PS 2MRVq9d0wcdgQvvopjzrn2UPNvt6JLCheai2d6+pILHJQuhlKUREqYxoSAjpuqUrpqlT QIgA== X-Gm-Message-State: AOAM5321KbxSGKCfi9mWpcaaAg3rlCoGMhDz+7ygJtgKpgP7MgpFOecB u7a7sIjmAbM3EZtcKBy9bww= X-Google-Smtp-Source: ABdhPJzuGNOPwo/Bvl7Mx8+XJDPIBFFBY1nXuNPZIeyt9003Bnto1cQysR14YdmUO/GzEaaObYI6WA== X-Received: by 2002:a63:1542:: with SMTP id 2mr25117350pgv.338.1615296132911; Tue, 09 Mar 2021 05:22:12 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:12 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 23/33] counter: Update counter.h comments to reflect sysfs internalization Date: Tue, 9 Mar 2021 22:19:36 +0900 Message-Id: <29e31fe01911058bad6a2f8373024c29cc6369fc.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The Counter subsystem architecture and driver implementations have changed in order to handle Counter sysfs interactions in a more consistent way. This patch updates the Generic Counter interface header file comments to reflect the changes. Signed-off-by: William Breathitt Gray --- drivers/counter/counter-core.c | 3 ++ include/linux/counter.h | 72 +++++++++++++++------------------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/drivers/counter/counter-core.c b/drivers/counter/counter-core.c index e7dd6ea01c8a..407661c6feb0 100644 --- a/drivers/counter/counter-core.c +++ b/drivers/counter/counter-core.c @@ -41,6 +41,9 @@ static struct bus_type counter_bus_type = { * This function registers a Counter to the system. A sysfs "counter" directory * will be created and populated with sysfs attributes correlating with the * Counter Signals, Synapses, and Counts respectively. + * + * RETURNS: + * 0 on success, negative error number on failure. */ int counter_register(struct counter_device *const counter) { diff --git a/include/linux/counter.h b/include/linux/counter.h index 567471818ec3..e7fd6d81a929 100644 --- a/include/linux/counter.h +++ b/include/linux/counter.h @@ -188,12 +188,10 @@ struct counter_comp { /** * struct counter_signal - Counter Signal node - * @id: unique ID used to identify signal - * @name: device-specific Signal name; ideally, this should match the name - * as it appears in the datasheet documentation - * @ext: optional array of Counter Signal extensions - * @num_ext: number of Counter Signal extensions specified in @ext - * @priv: optional private data supplied by driver + * @id: unique ID used to identify the Signal + * @name: device-specific Signal name + * @ext: optional array of Signal extensions + * @num_ext: number of Signal extensions specified in @ext */ struct counter_signal { int id; @@ -207,7 +205,7 @@ struct counter_signal { * struct counter_synapse - Counter Synapse node * @actions_list: array of available action modes * @num_actions: number of action modes specified in @actions_list - * @signal: pointer to associated signal + * @signal: pointer to the associated Signal */ struct counter_synapse { const enum counter_synapse_action *actions_list; @@ -218,17 +216,14 @@ struct counter_synapse { /** * struct counter_count - Counter Count node - * @id: unique ID used to identify Count - * @name: device-specific Count name; ideally, this should match - * the name as it appears in the datasheet documentation - * @function: index of current function mode - * @functions_list: array available function modes + * @id: unique ID used to identify the Count + * @name: device-specific Count name + * @functions_list: array of available function modes * @num_functions: number of function modes specified in @functions_list - * @synapses: array of synapses for initialization - * @num_synapses: number of synapses specified in @synapses - * @ext: optional array of Counter Count extensions - * @num_ext: number of Counter Count extensions specified in @ext - * @priv: optional private data supplied by driver + * @synapses: array of Synapses for initialization + * @num_synapses: number of Synapses specified in @synapses + * @ext: optional array of Count extensions + * @num_ext: number of Count extensions specified in @ext */ struct counter_count { int id; @@ -246,29 +241,26 @@ struct counter_count { /** * struct counter_ops - Callbacks from driver - * @signal_read: optional read callback for Signal attribute. The read - * level of the respective Signal should be passed back via - * the level parameter. - * @count_read: optional read callback for Count attribute. The read - * value of the respective Count should be passed back via - * the val parameter. - * @count_write: optional write callback for Count attribute. The write - * value for the respective Count is passed in via the val + * @signal_read: read callback for Signals. The read level of the + * respective Signal should be passed back via the level + * parameter. + * @count_read: read callback for Counts. The read value of the + * respective Count should be passed back via the value * parameter. - * @function_get: function to get the current count function mode. Returns - * 0 on success and negative error code on error. The index - * of the respective Count's returned function mode should - * be passed back via the function parameter. - * @function_set: function to set the count function mode. function is the - * index of the requested function mode from the respective - * Count's functions_list array. - * @action_get: function to get the current action mode. Returns 0 on - * success and negative error code on error. The index of - * the respective Synapse's returned action mode should be - * passed back via the action parameter. - * @action_set: function to set the action mode. action is the index of - * the requested action mode from the respective Synapse's - * actions_list array. + * @count_write: write callback for Counts. The write value for the + * respective Count is passed in via the value parameter. + * @function_read: read callback the Count function modes. The read + * function mode of the respective Count should be passed + * back via the function parameter. + * @function_write: write callback for Count function modes. The function + * mode to write for the respective Count is passed in via + * the function parameter. + * @action_read: read callback the Synapse action modes. The read action + * mode of the respective Synapse should be passed back via + * the action parameter. + * @action_write: write callback for Synapse action modes. The action mode + * to write for the respective Synapse is passed in via the + * action parameter. */ struct counter_ops { int (*signal_read)(struct counter_device *counter, @@ -296,7 +288,7 @@ struct counter_ops { /** * struct counter_device - Counter data structure - * @name: name of the device as it appears in the datasheet + * @name: name of the device * @parent: optional parent device providing the counters * @ops: callbacks from driver * @signals: array of Signals From patchwork Tue Mar 9 13:19:37 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: 12125197 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 B6F4FC43381 for ; Tue, 9 Mar 2021 13:23:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64E1F650E6 for ; Tue, 9 Mar 2021 13:23:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231355AbhCINWe (ORCPT ); Tue, 9 Mar 2021 08:22:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231826AbhCINWS (ORCPT ); Tue, 9 Mar 2021 08:22:18 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8974CC06174A; Tue, 9 Mar 2021 05:22:18 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id q6-20020a17090a4306b02900c42a012202so5187778pjg.5; Tue, 09 Mar 2021 05:22:18 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=A/dvFRFYhRNOeA/Lol38cTGkqCaGCrRyjtz1bYWrTlA=; b=cgExb5YvGWvpbpGOQIim+kLtrO9Gw3g55csYkZD6gWsbp/N+JKJcHtXeIB88VCKdpx flFF/Lq5z41lON7n6OffzskJUP5E8ZnmrqAeEXpSjMawNsODjdmyQ0GPgDSXd9dxRTdN 4zmL0Ssa/Ahah05sVc9nE5ecuN6oVRADNE+F9+EynWkDmc5ZOYaPohgIX/eyEzfpoBat iAEve2zFnbO95KZcf5+BjZdofBcHTSmu06Wj3XUiRz3rgRbJh44YUvEzmBEgxUroBzA9 Sab7KYfzZjAuc9TkJPiyQ00c7TaAuT0QXdQc5B+smLuaMu5Ag8ocg0v+0zeh37Up2kJf J8lg== 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:mime-version:content-transfer-encoding; bh=A/dvFRFYhRNOeA/Lol38cTGkqCaGCrRyjtz1bYWrTlA=; b=j/UyM792BcQPMySZ0tft+zLLDrsvx47b2mrw7cJkH4mxrnsmO3wUT6JrtgEoPZEjW5 aOsTCBjTrWmXzAlIdfab2OPbkGSGtGtl0BfRVGYsUBN0gWTpRZDnhFk8T7tL7Vcv+Vbn /9KII+bf2WPHjp7EOqg6ksaQmWSBW/JquIhuEuppU2VeIuz36qlv6Tl0uKJji/BV7P2K cZecxs9pqPBKrJKQbFYRe7kdlVjYlBnX4LNpA5xdEFmrTq8GhRbDgV6KcPXtkMntc3hc elmEECQclfGP1CLyjF9HfG49oBOqd9BpqGsRZUrPv/Z2+au0Sm8JU2FWc5qW8eAYkG6Y ypig== X-Gm-Message-State: AOAM5338oARqzycBYQa9d9Y0521J1t8UA8fuvKe/f63nlaM80Nz1wsOw MJ5sHvphoaw0/o6Q+mMVRVA= X-Google-Smtp-Source: ABdhPJzBjCYOhoRzX3puz3r9RvXC+c15vPYfB19aljAn1h6ToQzT5iESdlZFkn/1shr8DdAO+LuAqw== X-Received: by 2002:a17:90a:a403:: with SMTP id y3mr4653679pjp.227.1615296137885; Tue, 09 Mar 2021 05:22:17 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:17 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 24/33] docs: counter: Update to reflect sysfs internalization Date: Tue, 9 Mar 2021 22:19:37 +0900 Message-Id: <74b93ae1132f62183917a0083d764f426c7160f1.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The Counter subsystem architecture and driver implementations have changed in order to handle Counter sysfs interactions in a more consistent way. This patch updates the Generic Counter interface documentation to reflect the changes. Signed-off-by: William Breathitt Gray --- Documentation/ABI/testing/sysfs-bus-counter | 9 +- Documentation/driver-api/generic-counter.rst | 243 ++++++++++++++----- 2 files changed, 185 insertions(+), 67 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter index 29f54484183f..6353f0a2f8f8 100644 --- a/Documentation/ABI/testing/sysfs-bus-counter +++ b/Documentation/ABI/testing/sysfs-bus-counter @@ -277,7 +277,14 @@ What: /sys/bus/counter/devices/counterX/signalY/signal KernelVersion: 5.2 Contact: linux-iio@vger.kernel.org Description: - Signal data of Signal Y represented as a string. + Signal level state of Signal Y. The following signal level + states are available: + + low: + Low level state. + + high: + High level state. What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode KernelVersion: 5.2 diff --git a/Documentation/driver-api/generic-counter.rst b/Documentation/driver-api/generic-counter.rst index 64fe7db080e5..f6397218aa4c 100644 --- a/Documentation/driver-api/generic-counter.rst +++ b/Documentation/driver-api/generic-counter.rst @@ -250,8 +250,8 @@ for defining a counter device. .. kernel-doc:: drivers/counter/counter.c :export: -Implementation -============== +Driver Implementation +===================== To support a counter device, a driver must first allocate the available Counter Signals via counter_signal structures. These Signals should @@ -267,25 +267,61 @@ respective counter_count structure. These counter_count structures are set to the counts array member of an allocated counter_device structure before the Counter is registered to the system. -Driver callbacks should be provided to the counter_device structure via -a constant counter_ops structure in order to communicate with the -device: to read and write various Signals and Counts, and to set and get -the "action mode" and "function mode" for various Synapses and Counts -respectively. +Driver callbacks must be provided to the counter_device structure in +order to communicate with the device: to read and write various Signals +and Counts, and to set and get the "action mode" and "function mode" for +various Synapses and Counts respectively. A defined counter_device structure may be registered to the system by passing it to the counter_register function, and unregistered by passing it to the counter_unregister function. Similarly, the -devm_counter_register and devm_counter_unregister functions may be used -if device memory-managed registration is desired. - -Extension sysfs attributes can be created for auxiliary functionality -and data by passing in defined counter_device_ext, counter_count_ext, -and counter_signal_ext structures. In these cases, the -counter_device_ext structure is used for global/miscellaneous exposure -and configuration of the respective Counter device, while the -counter_count_ext and counter_signal_ext structures allow for auxiliary -exposure and configuration of a specific Count or Signal respectively. +devm_counter_register function may be used if device memory-managed +registration is desired. + +The struct counter_comp structure is used to define counter extensions +for Signals, Synapses, and Counts. + +The "type" member specifies the type of high-level data (e.g. BOOL, +COUNT_DIRECTION, etc.) handled by this extension. The "``*_read``" and +"``*_write``" members can then be set by the counter device driver with +callbacks to handle that data using native C data types (i.e. u8, u64, +etc.). + +Convenience macros such as ``COUNTER_COMP_COUNT_U64`` are provided for +use by driver authors. In particular, driver authors are expected to use +the provided macros for standard Counter subsystem attributes in order +to maintain a consistent interface for userspace. For example, a counter +device driver may define several standard attributes like so:: + + struct counter_comp count_ext[] = { + COUNTER_COMP_DIRECTION(count_direction_read), + COUNTER_COMP_ENABLE(count_enable_read, count_enable_write), + COUNTER_COMP_CEILING(count_ceiling_read, count_ceiling_write), + }; + +This makes it simple to see, add, and modify the attributes that are +supported by this driver ("direction", "enable", and "ceiling") and to +maintain this code without getting lost in a web of struct braces. + +Callbacks must match the function type expected for the respective +component or extension. These function types are defined in the struct +counter_comp structure as the "``*_read``" and "``*_write``" union +members. + +The corresponding callback prototypes for the extensions mentioned in +the previous example above would be:: + + int count_direction_read(struct counter_device *counter, + struct counter_count *count, + enum counter_count_direction *direction); + int count_enable_read(struct counter_device *counter, + struct counter_count *count, u8 *enable); + int count_enable_write(struct counter_device *counter, + struct counter_count *count, u8 enable); + int count_ceiling_read(struct counter_device *counter, + struct counter_count *count, u64 *ceiling); + int count_ceiling_write(struct counter_device *counter, + struct counter_count *count, u64 ceiling); Determining the type of extension to create is a matter of scope. @@ -313,52 +349,127 @@ Determining the type of extension to create is a matter of scope. chip overheated via a device extension called "error_overtemp": /sys/bus/counter/devices/counterX/error_overtemp -Architecture -============ - -When the Generic Counter interface counter module is loaded, the -counter_init function is called which registers a bus_type named -"counter" to the system. Subsequently, when the module is unloaded, the -counter_exit function is called which unregisters the bus_type named -"counter" from the system. - -Counter devices are registered to the system via the counter_register -function, and later removed via the counter_unregister function. The -counter_register function establishes a unique ID for the Counter -device and creates a respective sysfs directory, where X is the -mentioned unique ID: - - /sys/bus/counter/devices/counterX - -Sysfs attributes are created within the counterX directory to expose -functionality, configurations, and data relating to the Counts, Signals, -and Synapses of the Counter device, as well as options and information -for the Counter device itself. - -Each Signal has a directory created to house its relevant sysfs -attributes, where Y is the unique ID of the respective Signal: - - /sys/bus/counter/devices/counterX/signalY - -Similarly, each Count has a directory created to house its relevant -sysfs attributes, where Y is the unique ID of the respective Count: - - /sys/bus/counter/devices/counterX/countY - -For a more detailed breakdown of the available Generic Counter interface -sysfs attributes, please refer to the -Documentation/ABI/testing/sysfs-bus-counter file. - -The Signals and Counts associated with the Counter device are registered -to the system as well by the counter_register function. The -signal_read/signal_write driver callbacks are associated with their -respective Signal attributes, while the count_read/count_write and -function_get/function_set driver callbacks are associated with their -respective Count attributes; similarly, the same is true for the -action_get/action_set driver callbacks and their respective Synapse -attributes. If a driver callback is left undefined, then the respective -read/write permission is left disabled for the relevant attributes. - -Similarly, extension sysfs attributes are created for the defined -counter_device_ext, counter_count_ext, and counter_signal_ext -structures that are passed in. +Subsystem Architecture +====================== + +Counter drivers pass and take data natively (i.e. ``u8``, ``u64``, etc.) +and the shared counter module handles the translation between the sysfs +interface. This guarantees a standard userspace interface for all +counter drivers, and enables a Generic Counter chrdev interface via a +generalized device driver ABI. + +A high-level view of how a count value is passed down from a counter +driver is exemplified by the following. The driver callbacks are first +registered to the Counter core component for use by the Counter +userspace interface components:: + + Driver callbacks registration: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +----------------------------+ + | Counter device driver | + +----------------------------+ + | Processes data from device | + +----------------------------+ + | + ------------------- + / driver callbacks / + ------------------- + | + V + +----------------------+ + | Counter core | + +----------------------+ + | Routes device driver | + | callbacks to the | + | userspace interfaces | + +----------------------+ + | + ------------------- + / driver callbacks / + ------------------- + | + +---------------+ + | + V + +--------------------+ + | Counter sysfs | + +--------------------+ + | Translates to the | + | standard Counter | + | sysfs output | + +--------------------+ + +Thereafter, data can be transferred directly between the Counter device +driver and Counter userspace interface:: + + Count data request: + ~~~~~~~~~~~~~~~~~~~ + ---------------------- + / Counter device \ + +----------------------+ + | Count register: 0x28 | + +----------------------+ + | + ----------------- + / raw count data / + ----------------- + | + V + +----------------------------+ + | Counter device driver | + +----------------------------+ + | Processes data from device | + |----------------------------| + | Type: u64 | + | Value: 42 | + +----------------------------+ + | + ---------- + / u64 / + ---------- + | + +---------------+ + | + V + +--------------------+ + | Counter sysfs | + +--------------------+ + | Translates to the | + | standard Counter | + | sysfs output | + |--------------------| + | Type: const char * | + | Value: "42" | + +--------------------+ + | + --------------- + / const char * / + --------------- + | + V + +--------------------------------------------------+ + | `/sys/bus/counter/devices/counterX/countY/count` | + +--------------------------------------------------+ + \ Count: "42" / + -------------------------------------------------- + +There are three primary components involved: + +Counter device driver +--------------------- +Communicates with the hardware device to read/write data; e.g. counter +drivers for quadrature encoders, timers, etc. + +Counter core +------------ +Registers the counter device driver to the system so that the respective +callbacks are called during userspace interaction. + +Counter sysfs +------------- +Translates counter data to the standard Counter sysfs interface format +and vice versa. + +Please refer to the ``Documentation/ABI/testing/sysfs-bus-counter`` file +for a detailed breakdown of the available Generic Counter interface +sysfs attributes. From patchwork Tue Mar 9 13:19:38 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: 12125193 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 885BDC433E6 for ; Tue, 9 Mar 2021 13:23:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3828B65287 for ; Tue, 9 Mar 2021 13:23:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231661AbhCINWf (ORCPT ); Tue, 9 Mar 2021 08:22:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231833AbhCINWX (ORCPT ); Tue, 9 Mar 2021 08:22:23 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BD92C06174A; Tue, 9 Mar 2021 05:22:23 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id q204so9362525pfq.10; Tue, 09 Mar 2021 05:22:23 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=jtnafmPIEm/uciDz91Y90561rS0hqXgRCMM9b1KyMxI=; b=hm1K7gbeZ4zkZ3VpuaV5XXFT1+qMm+LLu2X2wNAQNYhVlW4p/KCUkFQogQc9yYsLmg D2iCzYeoQHJAmHgUAtWsr+jIBKsL8LTFWXRgDmroQeInG1PRLKKlTTxIT1Tzd2kaTuw/ X/ugI1Erldi4aOrE2Z10M11hlQcTfVaCffGHhSwFxTY+aizrMGq2xHi/jdl7vgeDBsiV leYifI2NoDdzHkF6mcOKRcMPnm+9hZUodm0Uw3RT+wYwZfAzrBS8JGEEb4PjcaxajG7n 1OAhZPECwgw8lcWEhVPwjoCKfmY/E6DoZWiNbnGODyTjF3QDVRUELzAAStMhYyRXhmQN 0h/A== 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:mime-version:content-transfer-encoding; bh=jtnafmPIEm/uciDz91Y90561rS0hqXgRCMM9b1KyMxI=; b=MfAlD/flTGyDIpm0pNaIuGpSlKAlLwZffpW6k72IcaRYU+GaP0+7nccygkLT9841QZ FtM9d0xLHHde3UxnZtd0BC5Y+1wHfNfK01YmEJLlLn3ZpKDDvyvS5tKH34W4TpiLjvB4 QVl9DaS2uNkQy9z111YjdvSdRRandhc5Jto7JMX+O5UozteRwyB23+7hBT9LuCkCmpXh Npnw4QRXnUMdB0uH9v9pNcOpY5ed8ezcRvOMmZqH9+pSYm6Nbia3wDVOBLpg+izTaevx zB+oh/p0DKbQK9gnUJM4vco2/8gBXqZKKBPFuchLBY0W4ZW9v2kq8GBpHHLcAQar0x1f LNyQ== X-Gm-Message-State: AOAM53108Dsx21/SlJUxGfU9hPmiH6RqOCziiqz3zSAzGk/lVnOFg0Fy oOmZMftYA1Bsp2W9a0LTHsg= X-Google-Smtp-Source: ABdhPJzje+jktfJMmynWKmgW9FgFg+J2/kZcAFyYOfDhvG55M+0C0LOdPRjRE6WaIdu37SpCZCBYiA== X-Received: by 2002:a63:fb18:: with SMTP id o24mr24474588pgh.55.1615296142824; Tue, 09 Mar 2021 05:22:22 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:22 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 25/33] counter: Move counter enums to uapi header Date: Tue, 9 Mar 2021 22:19:38 +0900 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This is in preparation for a subsequent patch implementing a character device interface for the Counter subsystem. Reviewed-by: David Lechner Signed-off-by: William Breathitt Gray --- MAINTAINERS | 1 + include/linux/counter.h | 42 +-------------------------- include/uapi/linux/counter.h | 56 ++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 41 deletions(-) create mode 100644 include/uapi/linux/counter.h diff --git a/MAINTAINERS b/MAINTAINERS index 1508db256784..93233a07f5aa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4581,6 +4581,7 @@ F: Documentation/ABI/testing/sysfs-bus-counter F: Documentation/driver-api/generic-counter.rst F: drivers/counter/ F: include/linux/counter.h +F: include/uapi/linux/counter.h CPMAC ETHERNET DRIVER M: Florian Fainelli diff --git a/include/linux/counter.h b/include/linux/counter.h index e7fd6d81a929..eee85db8e332 100644 --- a/include/linux/counter.h +++ b/include/linux/counter.h @@ -9,6 +9,7 @@ #include #include #include +#include struct counter_device; struct counter_count; @@ -27,47 +28,6 @@ enum counter_comp_type { COUNTER_COMP_COUNT_MODE, }; -enum counter_scope { - COUNTER_SCOPE_DEVICE, - COUNTER_SCOPE_SIGNAL, - COUNTER_SCOPE_COUNT, -}; - -enum counter_count_direction { - COUNTER_COUNT_DIRECTION_FORWARD, - COUNTER_COUNT_DIRECTION_BACKWARD, -}; - -enum counter_count_mode { - COUNTER_COUNT_MODE_NORMAL, - COUNTER_COUNT_MODE_RANGE_LIMIT, - COUNTER_COUNT_MODE_NON_RECYCLE, - COUNTER_COUNT_MODE_MODULO_N, -}; - -enum counter_function { - COUNTER_FUNCTION_INCREASE, - COUNTER_FUNCTION_DECREASE, - COUNTER_FUNCTION_PULSE_DIRECTION, - COUNTER_FUNCTION_QUADRATURE_X1_A, - COUNTER_FUNCTION_QUADRATURE_X1_B, - COUNTER_FUNCTION_QUADRATURE_X2_A, - COUNTER_FUNCTION_QUADRATURE_X2_B, - COUNTER_FUNCTION_QUADRATURE_X4, -}; - -enum counter_signal_level { - COUNTER_SIGNAL_LEVEL_LOW, - COUNTER_SIGNAL_LEVEL_HIGH, -}; - -enum counter_synapse_action { - COUNTER_SYNAPSE_ACTION_NONE, - COUNTER_SYNAPSE_ACTION_RISING_EDGE, - COUNTER_SYNAPSE_ACTION_FALLING_EDGE, - COUNTER_SYNAPSE_ACTION_BOTH_EDGES, -}; - /** * struct counter_comp - Counter component node * @type: Counter component data type diff --git a/include/uapi/linux/counter.h b/include/uapi/linux/counter.h new file mode 100644 index 000000000000..6113938a6044 --- /dev/null +++ b/include/uapi/linux/counter.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Userspace ABI for Counter character devices + * Copyright (C) 2020 William Breathitt Gray + */ +#ifndef _UAPI_COUNTER_H_ +#define _UAPI_COUNTER_H_ + +/* Component scope definitions */ +enum counter_scope { + COUNTER_SCOPE_DEVICE, + COUNTER_SCOPE_SIGNAL, + COUNTER_SCOPE_COUNT, +}; + +/* Count direction values */ +enum counter_count_direction { + COUNTER_COUNT_DIRECTION_FORWARD, + COUNTER_COUNT_DIRECTION_BACKWARD, +}; + +/* Count mode values */ +enum counter_count_mode { + COUNTER_COUNT_MODE_NORMAL, + COUNTER_COUNT_MODE_RANGE_LIMIT, + COUNTER_COUNT_MODE_NON_RECYCLE, + COUNTER_COUNT_MODE_MODULO_N, +}; + +/* Count function values */ +enum counter_function { + COUNTER_FUNCTION_INCREASE, + COUNTER_FUNCTION_DECREASE, + COUNTER_FUNCTION_PULSE_DIRECTION, + COUNTER_FUNCTION_QUADRATURE_X1_A, + COUNTER_FUNCTION_QUADRATURE_X1_B, + COUNTER_FUNCTION_QUADRATURE_X2_A, + COUNTER_FUNCTION_QUADRATURE_X2_B, + COUNTER_FUNCTION_QUADRATURE_X4, +}; + +/* Signal values */ +enum counter_signal_level { + COUNTER_SIGNAL_LEVEL_LOW, + COUNTER_SIGNAL_LEVEL_HIGH, +}; + +/* Action mode values */ +enum counter_synapse_action { + COUNTER_SYNAPSE_ACTION_NONE, + COUNTER_SYNAPSE_ACTION_RISING_EDGE, + COUNTER_SYNAPSE_ACTION_FALLING_EDGE, + COUNTER_SYNAPSE_ACTION_BOTH_EDGES, +}; + +#endif /* _UAPI_COUNTER_H_ */ From patchwork Tue Mar 9 13:19:39 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: 12125199 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 BC64EC4332B for ; Tue, 9 Mar 2021 13:23:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8605D6514A for ; Tue, 9 Mar 2021 13:23:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231666AbhCINWf (ORCPT ); Tue, 9 Mar 2021 08:22:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230521AbhCINW2 (ORCPT ); Tue, 9 Mar 2021 08:22:28 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C296C06174A; Tue, 9 Mar 2021 05:22:28 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id a22-20020a17090aa516b02900c1215e9b33so4995138pjq.5; Tue, 09 Mar 2021 05:22:28 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=6v2M/fOTWx4fUPrQO1wRcbiFjhf87JGosnGnVXJ39k8=; b=c+7WEm9chUAcL7YIwApQfn/pMcIOZmTh+gkcIBMzdOZb3IrS7uCGa4j9oMGUtJjOFg G0JTmZg9/ez+eFie2kw/zbIpRRYQmHtZI0ovMfZ6CT3k/vyfcqYcCgX5s+LoeHfKnpF5 KyUnDCnXHEmqjFfL1IV8KzdXWF0vo4/WJzxJr2UGsE0VGnIkT7UqZkxq1ZIVSnwl2eAO JeHDz1fc+ChzAC8IHXOLh7LWYcvgMmKb+u2cfHU6sYiSyJ2jhbBMBPWgpX+n8AIWKwlX tttYxhehG2jKToYwQ2aeTE/CTZq598jH8jyreUnB63k9V56L8gX4QWvBvixhjYsJ8XwZ +k2w== 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:mime-version:content-transfer-encoding; bh=6v2M/fOTWx4fUPrQO1wRcbiFjhf87JGosnGnVXJ39k8=; b=fqGscXiOm8fSJG0nCsIiI47YjOaFKUNiZWTyrkyk6u144YiNz10fTdU5f7bA8fOAOS 6PzqjLQwXi/TeT1+tNA5gsPTQeDxtDjv2hCS5eleTn00CUgjgskuPZIQ9CfHRvKUBFkQ CvfbfnwMLKSbXPzXiSZZRmt6NJ3UhMAf5T0iqkOQhoIQFs2ILZynbuXYDFe3IEnVekEd R6GgWF5TP0hfUiHXv0Ho5UpLyqpLpyV/Ym41QzK27RAET7HLoW57Sw1hPB+LRomplTRf QT94+VlvvVZv1rMt/SR/VkXZZZsDOfS8JNO+Nb/Re4oqrMvfs5NMLJKEQ/XN5Jvhp2GI K01A== X-Gm-Message-State: AOAM533b9nNrMOYI7Uf6KJRB7C1kuP7kS+4eJtqh6Z+rChAZJev4tL+y i3zAZCTa7P0a3ifPE6dT4qQ= X-Google-Smtp-Source: ABdhPJwHenWFSZ4TRmfcd7clJIBioLuUdHvx5wrcULM6OI0bShXLElVKIQMp1u6Nd9SCFBGgDQal1w== X-Received: by 2002:a17:90a:4603:: with SMTP id w3mr4730182pjg.125.1615296148172; Tue, 09 Mar 2021 05:22:28 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:27 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray , Dan Carpenter Subject: [PATCH v9 26/33] counter: Add character device interface Date: Tue, 9 Mar 2021 22:19:39 +0900 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This patch introduces a character device interface for the Counter subsystem. Device data is exposed through standard character device read operations. Device data is gathered when a Counter event is pushed by the respective Counter device driver. Configuration is handled via ioctl operations on the respective Counter character device node. Cc: David Lechner Cc: Gwendal Grignou Cc: Dan Carpenter Cc: Oleksij Rempel Signed-off-by: William Breathitt Gray --- drivers/counter/Makefile | 2 +- drivers/counter/counter-chrdev.c | 482 +++++++++++++++++++++++++++++++ drivers/counter/counter-chrdev.h | 14 + drivers/counter/counter-core.c | 44 ++- include/linux/counter.h | 45 +++ include/uapi/linux/counter.h | 77 +++++ 6 files changed, 658 insertions(+), 6 deletions(-) create mode 100644 drivers/counter/counter-chrdev.c create mode 100644 drivers/counter/counter-chrdev.h diff --git a/drivers/counter/Makefile b/drivers/counter/Makefile index 9a31394cb926..5e274e04a415 100644 --- a/drivers/counter/Makefile +++ b/drivers/counter/Makefile @@ -4,7 +4,7 @@ # obj-$(CONFIG_COUNTER) += counter.o -counter-y := counter-core.o counter-sysfs.o +counter-y := counter-core.o counter-sysfs.o counter-chrdev.o obj-$(CONFIG_104_QUAD_8) += 104-quad-8.o obj-$(CONFIG_INTERRUPT_CNT) += interrupt-cnt.o diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c new file mode 100644 index 000000000000..d5f92b2d3bb4 --- /dev/null +++ b/drivers/counter/counter-chrdev.c @@ -0,0 +1,482 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Generic Counter character device interface + * Copyright (C) 2020 William Breathitt Gray + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "counter-chrdev.h" + +struct counter_comp_node { + struct list_head l; + struct counter_component component; + struct counter_comp comp; + void *parent; +}; + +static ssize_t counter_chrdev_read(struct file *filp, char __user *buf, + size_t len, loff_t *f_ps) +{ + struct counter_device *const counter = filp->private_data; + int err; + unsigned int copied; + + if (len < sizeof(struct counter_event)) + return -EINVAL; + + do { + if (kfifo_is_empty(&counter->events)) { + if (filp->f_flags & O_NONBLOCK) + return -EAGAIN; + + err = wait_event_interruptible(counter->events_wait, + !kfifo_is_empty(&counter->events)); + if (err < 0) + return err; + } + + if (mutex_lock_interruptible(&counter->events_lock)) + return -ERESTARTSYS; + err = kfifo_to_user(&counter->events, buf, len, &copied); + mutex_unlock(&counter->events_lock); + if (err < 0) + return err; + } while (!copied); + + return copied; +} + +static __poll_t counter_chrdev_poll(struct file *filp, + struct poll_table_struct *pollt) +{ + struct counter_device *const counter = filp->private_data; + __poll_t events = 0; + + poll_wait(filp, &counter->events_wait, pollt); + + if (!kfifo_is_empty(&counter->events)) + events = EPOLLIN | EPOLLRDNORM; + + return events; +} + +static void counter_events_list_free(struct list_head *const events_list) +{ + struct counter_event_node *p, *n; + struct counter_comp_node *q, *o; + + list_for_each_entry_safe(p, n, events_list, l) { + /* Free associated component nodes */ + list_for_each_entry_safe(q, o, &p->comp_list, l) { + list_del(&q->l); + kfree(q); + } + + /* Free event node */ + list_del(&p->l); + kfree(p); + } +} + +static int counter_set_event_node(struct counter_device *const counter, + struct counter_watch *const watch, + const struct counter_comp_node *const cfg) +{ + struct counter_event_node *event_node; + struct counter_comp_node *comp_node; + + /* Search for event in the list */ + list_for_each_entry(event_node, &counter->next_events_list, l) + if (event_node->event == watch->event && + event_node->channel == watch->channel) + break; + + /* If event is not already in the list */ + if (&event_node->l == &counter->next_events_list) { + /* Allocate new event node */ + event_node = kmalloc(sizeof(*event_node), GFP_ATOMIC); + if (!event_node) + return -ENOMEM; + + /* Configure event node and add to the list */ + event_node->event = watch->event; + event_node->channel = watch->channel; + INIT_LIST_HEAD(&event_node->comp_list); + list_add(&event_node->l, &counter->next_events_list); + } + + /* Check if component watch has already been set before */ + list_for_each_entry(comp_node, &event_node->comp_list, l) + if (comp_node->parent == cfg->parent && + comp_node->comp.count_u8_read == cfg->comp.count_u8_read) + return -EINVAL; + + /* Allocate component node */ + comp_node = kmalloc(sizeof(*comp_node), GFP_ATOMIC); + if (!comp_node) { + /* Free event node if no one else is watching */ + if (list_empty(&event_node->comp_list)) { + list_del(&event_node->l); + kfree(event_node); + } + return -ENOMEM; + } + *comp_node = *cfg; + + /* Add component node to event node */ + list_add_tail(&comp_node->l, &event_node->comp_list); + + return 0; +} + +static int counter_disable_events(struct counter_device *const counter) +{ + unsigned long flags; + int err = 0; + + spin_lock_irqsave(&counter->events_list_lock, flags); + + counter_events_list_free(&counter->events_list); + + if (counter->ops->events_configure) + err = counter->ops->events_configure(counter); + + spin_unlock_irqrestore(&counter->events_list_lock, flags); + + counter_events_list_free(&counter->next_events_list); + + return err; +} + +static int counter_add_watch(struct counter_device *const counter, + const unsigned long arg) +{ + void __user *const uwatch = (void __user *)arg; + struct counter_watch watch; + struct counter_comp_node comp_node = {0}; + size_t parent, id; + struct counter_comp *ext; + size_t num_ext; + int err; + + if (copy_from_user(&watch, uwatch, sizeof(watch))) + return -EFAULT; + + if (watch.component.type == COUNTER_COMPONENT_NONE) + goto no_component; + + parent = watch.component.parent; + + /* Configure parent component info for comp node */ + switch (watch.component.scope) { + case COUNTER_SCOPE_DEVICE: + ext = counter->ext; + num_ext = counter->num_ext; + break; + case COUNTER_SCOPE_SIGNAL: + if (parent >= counter->num_signals) + return -EINVAL; + parent = array_index_nospec(parent, counter->num_signals); + + comp_node.parent = counter->signals + parent; + + ext = counter->signals[parent].ext; + num_ext = counter->signals[parent].num_ext; + break; + case COUNTER_SCOPE_COUNT: + if (parent >= counter->num_counts) + return -EINVAL; + parent = array_index_nospec(parent, counter->num_counts); + + comp_node.parent = counter->counts + parent; + + ext = counter->counts[parent].ext; + num_ext = counter->counts[parent].num_ext; + break; + default: + return -EINVAL; + } + + id = watch.component.id; + + /* Configure component info for comp node */ + switch (watch.component.type) { + case COUNTER_COMPONENT_SIGNAL: + if (watch.component.scope != COUNTER_SCOPE_SIGNAL) + return -EINVAL; + + comp_node.comp.type = COUNTER_COMP_SIGNAL_LEVEL; + comp_node.comp.signal_u32_read = counter->ops->signal_read; + break; + case COUNTER_COMPONENT_COUNT: + if (watch.component.scope != COUNTER_SCOPE_COUNT) + return -EINVAL; + + comp_node.comp.type = COUNTER_COMP_U64; + comp_node.comp.count_u64_read = counter->ops->count_read; + break; + case COUNTER_COMPONENT_FUNCTION: + if (watch.component.scope != COUNTER_SCOPE_COUNT) + return -EINVAL; + + comp_node.comp.type = COUNTER_COMP_FUNCTION; + comp_node.comp.count_u32_read = counter->ops->function_read; + break; + case COUNTER_COMPONENT_SYNAPSE_ACTION: + if (watch.component.scope != COUNTER_SCOPE_COUNT) + return -EINVAL; + if (id >= counter->counts[parent].num_synapses) + return -EINVAL; + id = array_index_nospec(id, counter->counts[parent].num_synapses); + + comp_node.comp.type = COUNTER_COMP_SYNAPSE_ACTION; + comp_node.comp.action_read = counter->ops->action_read; + comp_node.comp.priv = counter->counts[parent].synapses + id; + break; + case COUNTER_COMPONENT_EXTENSION: + if (id >= num_ext) + return -EINVAL; + id = array_index_nospec(id, num_ext); + + comp_node.comp = ext[id]; + break; + default: + return -EINVAL; + } + /* Check if any read callback is set; this is part of a union */ + if (!comp_node.comp.count_u8_read) + return -EOPNOTSUPP; + +no_component: + if (counter->ops->watch_validate) { + err = counter->ops->watch_validate(counter, &watch); + if (err < 0) + return err; + } + + comp_node.component = watch.component; + + return counter_set_event_node(counter, &watch, &comp_node); +} + +static long counter_chrdev_ioctl(struct file *filp, unsigned int cmd, + unsigned long arg) +{ + struct counter_device *const counter = filp->private_data; + unsigned long flags; + int err = 0; + + switch (cmd) { + case COUNTER_ADD_WATCH_IOCTL: + return counter_add_watch(counter, arg); + case COUNTER_ENABLE_EVENTS_IOCTL: + spin_lock_irqsave(&counter->events_list_lock, flags); + + counter_events_list_free(&counter->events_list); + list_replace_init(&counter->next_events_list, + &counter->events_list); + + if (counter->ops->events_configure) + err = counter->ops->events_configure(counter); + + spin_unlock_irqrestore(&counter->events_list_lock, flags); + return err; + case COUNTER_DISABLE_EVENTS_IOCTL: + return counter_disable_events(counter); + default: + return -ENOIOCTLCMD; + } +} + +static int counter_chrdev_open(struct inode *inode, struct file *filp) +{ + struct counter_device *const counter = container_of(inode->i_cdev, + typeof(*counter), + chrdev); + + get_device(&counter->dev); + filp->private_data = counter; + + return nonseekable_open(inode, filp); +} + +static int counter_chrdev_release(struct inode *inode, struct file *filp) +{ + struct counter_device *const counter = filp->private_data; + int err; + + err = counter_disable_events(counter); + if (err < 0) + return err; + + put_device(&counter->dev); + + return 0; +} + +static const struct file_operations counter_fops = { + .llseek = no_llseek, + .read = counter_chrdev_read, + .poll = counter_chrdev_poll, + .unlocked_ioctl = counter_chrdev_ioctl, + .open = counter_chrdev_open, + .release = counter_chrdev_release, +}; + +int counter_chrdev_add(struct counter_device *const counter) +{ + /* Initialize Counter events lists */ + INIT_LIST_HEAD(&counter->events_list); + INIT_LIST_HEAD(&counter->next_events_list); + spin_lock_init(&counter->events_list_lock); + init_waitqueue_head(&counter->events_wait); + mutex_init(&counter->events_lock); + + /* Initialize character device */ + cdev_init(&counter->chrdev, &counter_fops); + + /* Allocate Counter events queue */ + return kfifo_alloc(&counter->events, 64, GFP_ATOMIC); +} + +void counter_chrdev_remove(struct counter_device *const counter) +{ + kfifo_free(&counter->events); +} + +static int counter_get_data(struct counter_device *const counter, + const struct counter_comp_node *const comp_node, + u64 *const value) +{ + const struct counter_comp *const comp = &comp_node->comp; + void *const parent = comp_node->parent; + u8 value_u8 = 0; + u32 value_u32 = 0; + int ret; + + if (comp_node->component.type == COUNTER_COMPONENT_NONE) + return 0; + + switch (comp->type) { + case COUNTER_COMP_U8: + case COUNTER_COMP_BOOL: + switch (comp_node->component.scope) { + case COUNTER_SCOPE_DEVICE: + ret = comp->device_u8_read(counter, &value_u8); + break; + case COUNTER_SCOPE_SIGNAL: + ret = comp->signal_u8_read(counter, parent, &value_u8); + break; + case COUNTER_SCOPE_COUNT: + ret = comp->count_u8_read(counter, parent, &value_u8); + break; + } + *value = value_u8; + return ret; + case COUNTER_COMP_SIGNAL_LEVEL: + case COUNTER_COMP_FUNCTION: + case COUNTER_COMP_ENUM: + case COUNTER_COMP_COUNT_DIRECTION: + case COUNTER_COMP_COUNT_MODE: + switch (comp_node->component.scope) { + case COUNTER_SCOPE_DEVICE: + ret = comp->device_u32_read(counter, &value_u32); + break; + case COUNTER_SCOPE_SIGNAL: + ret = comp->signal_u32_read(counter, parent, + &value_u32); + break; + case COUNTER_SCOPE_COUNT: + ret = comp->count_u32_read(counter, parent, &value_u32); + break; + } + *value = value_u32; + return ret; + case COUNTER_COMP_U64: + switch (comp_node->component.scope) { + case COUNTER_SCOPE_DEVICE: + return comp->device_u64_read(counter, value); + case COUNTER_SCOPE_SIGNAL: + return comp->signal_u64_read(counter, parent, value); + case COUNTER_SCOPE_COUNT: + return comp->count_u64_read(counter, parent, value); + default: + return -EINVAL; + } + case COUNTER_COMP_SYNAPSE_ACTION: + ret = comp->action_read(counter, parent, comp->priv, + &value_u32); + *value = value_u32; + return ret; + default: + return -EINVAL; + } +} + +/** + * counter_push_event - queue event for userspace reading + * @counter: pointer to Counter structure + * @event: triggered event + * @channel: event channel + * + * Note: If no one is watching for the respective event, it is silently + * discarded. + */ +void counter_push_event(struct counter_device *const counter, const u8 event, + const u8 channel) +{ + struct counter_event ev = {0}; + unsigned int copied = 0; + unsigned long flags; + struct counter_event_node *event_node; + struct counter_comp_node *comp_node; + + ev.timestamp = ktime_get_ns(); + ev.watch.event = event; + ev.watch.channel = channel; + + /* Could be in an interrupt context, so use a raw spin lock */ + spin_lock_irqsave(&counter->events_list_lock, flags); + + /* Search for event in the list */ + list_for_each_entry(event_node, &counter->events_list, l) + if (event_node->event == event && + event_node->channel == channel) + break; + + /* If event is not in the list */ + if (&event_node->l == &counter->events_list) + goto exit_early; + + /* Read and queue relevant comp for userspace */ + list_for_each_entry(comp_node, &event_node->comp_list, l) { + ev.watch.component = comp_node->component; + ev.status = -counter_get_data(counter, comp_node, &ev.value); + + copied += kfifo_in(&counter->events, &ev, 1); + } + + if (copied) + wake_up_poll(&counter->events_wait, EPOLLIN); + +exit_early: + spin_unlock_irqrestore(&counter->events_list_lock, flags); +} +EXPORT_SYMBOL_GPL(counter_push_event); diff --git a/drivers/counter/counter-chrdev.h b/drivers/counter/counter-chrdev.h new file mode 100644 index 000000000000..5529d16703c4 --- /dev/null +++ b/drivers/counter/counter-chrdev.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Counter character device interface + * Copyright (C) 2020 William Breathitt Gray + */ +#ifndef _COUNTER_CHRDEV_H_ +#define _COUNTER_CHRDEV_H_ + +#include + +int counter_chrdev_add(struct counter_device *const counter); +void counter_chrdev_remove(struct counter_device *const counter); + +#endif /* _COUNTER_CHRDEV_H_ */ diff --git a/drivers/counter/counter-core.c b/drivers/counter/counter-core.c index 407661c6feb0..91af3f8a5df8 100644 --- a/drivers/counter/counter-core.c +++ b/drivers/counter/counter-core.c @@ -3,14 +3,20 @@ * Generic Counter interface * Copyright (C) 2020 William Breathitt Gray */ +#include #include #include +#include #include +#include #include #include #include +#include #include +#include +#include "counter-chrdev.h" #include "counter-sysfs.h" /* Provides a unique ID for each counter device */ @@ -34,6 +40,8 @@ static struct bus_type counter_bus_type = { .dev_name = "counter", }; +static dev_t counter_devt; + /** * counter_register - register Counter to the system * @counter: pointer to Counter to register @@ -60,6 +68,7 @@ int counter_register(struct counter_device *const counter) dev->id = id; dev->type = &counter_device_type; dev->bus = &counter_bus_type; + dev->devt = MKDEV(MAJOR(counter_devt), id); if (counter->parent) { dev->parent = counter->parent; dev->of_node = counter->parent->of_node; @@ -67,18 +76,25 @@ int counter_register(struct counter_device *const counter) device_initialize(dev); dev_set_drvdata(dev, counter); + /* Add Counter character device */ + err = counter_chrdev_add(counter); + if (err < 0) + goto err_free_id; + /* Add Counter sysfs attributes */ err = counter_sysfs_add(counter); if (err < 0) - goto err_free_id; + goto err_remove_chrdev; /* Add device to system */ - err = device_add(dev); + err = cdev_device_add(&counter->chrdev, dev); if (err < 0) - goto err_free_id; + goto err_remove_chrdev; return 0; +err_remove_chrdev: + counter_chrdev_remove(counter); err_free_id: put_device(dev); return err; @@ -96,7 +112,8 @@ void counter_unregister(struct counter_device *const counter) if (!counter) return; - device_unregister(&counter->dev); + cdev_device_del(&counter->chrdev, &counter->dev); + put_device(&counter->dev); } EXPORT_SYMBOL_GPL(counter_unregister); @@ -140,13 +157,30 @@ int devm_counter_register(struct device *dev, } EXPORT_SYMBOL_GPL(devm_counter_register); +#define COUNTER_DEV_MAX 256 + static int __init counter_init(void) { - return bus_register(&counter_bus_type); + int err; + + err = bus_register(&counter_bus_type); + if (err < 0) + return err; + + err = alloc_chrdev_region(&counter_devt, 0, COUNTER_DEV_MAX, "counter"); + if (err < 0) + goto err_unregister_bus; + + return 0; + +err_unregister_bus: + bus_unregister(&counter_bus_type); + return err; } static void __exit counter_exit(void) { + unregister_chrdev_region(counter_devt, COUNTER_DEV_MAX); bus_unregister(&counter_bus_type); } diff --git a/include/linux/counter.h b/include/linux/counter.h index eee85db8e332..3f0bbe4ff702 100644 --- a/include/linux/counter.h +++ b/include/linux/counter.h @@ -6,9 +6,14 @@ #ifndef _COUNTER_H_ #define _COUNTER_H_ +#include #include #include +#include +#include +#include #include +#include #include struct counter_device; @@ -199,6 +204,20 @@ struct counter_count { size_t num_ext; }; +/** + * struct counter_event_node - Counter Event node + * @l: list of current watching Counter events + * @event: event that triggers + * @channel: event channel + * @comp_list: list of components to watch when event triggers + */ +struct counter_event_node { + struct list_head l; + u8 event; + u8 channel; + struct list_head comp_list; +}; + /** * struct counter_ops - Callbacks from driver * @signal_read: read callback for Signals. The read level of the @@ -221,6 +240,13 @@ struct counter_count { * @action_write: write callback for Synapse action modes. The action mode * to write for the respective Synapse is passed in via the * action parameter. + * @events_configure: write callback to configure events. The list of struct + * counter_event_node may be accessed via the events_list + * member of the counter parameter. + * @watch_validate: callback to validate a watch. The Counter component + * watch configuration is passed in via the watch + * parameter. A return value of 0 indicates a valid Counter + * component watch configuration. */ struct counter_ops { int (*signal_read)(struct counter_device *counter, @@ -244,6 +270,9 @@ struct counter_ops { struct counter_count *count, struct counter_synapse *synapse, enum counter_synapse_action action); + int (*events_configure)(struct counter_device *counter); + int (*watch_validate)(struct counter_device *counter, + const struct counter_watch *watch); }; /** @@ -259,6 +288,13 @@ struct counter_ops { * @num_ext: number of Counter device extensions specified in @ext * @priv: optional private data supplied by driver * @dev: internal device structure + * @chrdev: internal character device structure + * @events_list: list of current watching Counter events + * @events_list_lock: lock to protect Counter events list operations + * @next_events_list: list of next watching Counter events + * @events: queue of detected Counter events + * @events_wait: wait queue to allow blocking reads of Counter events + * @events_lock: lock to protect Counter events queue read operations */ struct counter_device { const char *name; @@ -277,12 +313,21 @@ struct counter_device { void *priv; struct device dev; + struct cdev chrdev; + struct list_head events_list; + spinlock_t events_list_lock; + struct list_head next_events_list; + DECLARE_KFIFO_PTR(events, struct counter_event); + wait_queue_head_t events_wait; + struct mutex events_lock; }; int counter_register(struct counter_device *const counter); void counter_unregister(struct counter_device *const counter); int devm_counter_register(struct device *dev, struct counter_device *const counter); +void counter_push_event(struct counter_device *const counter, const u8 event, + const u8 channel); #define COUNTER_COMP_DEVICE_U8(_name, _read, _write) \ { \ diff --git a/include/uapi/linux/counter.h b/include/uapi/linux/counter.h index 6113938a6044..e55dfc9de887 100644 --- a/include/uapi/linux/counter.h +++ b/include/uapi/linux/counter.h @@ -6,6 +6,19 @@ #ifndef _UAPI_COUNTER_H_ #define _UAPI_COUNTER_H_ +#include +#include + +/* Component type definitions */ +enum counter_component_type { + COUNTER_COMPONENT_NONE, + COUNTER_COMPONENT_SIGNAL, + COUNTER_COMPONENT_COUNT, + COUNTER_COMPONENT_FUNCTION, + COUNTER_COMPONENT_SYNAPSE_ACTION, + COUNTER_COMPONENT_EXTENSION, +}; + /* Component scope definitions */ enum counter_scope { COUNTER_SCOPE_DEVICE, @@ -13,6 +26,70 @@ enum counter_scope { COUNTER_SCOPE_COUNT, }; +/** + * struct counter_component - Counter component identification + * @type: component type (one of enum counter_component_type) + * @scope: component scope (one of enum counter_scope) + * @parent: parent ID (matching the ID suffix of the respective parent sysfs + * path as described by the ABI documentation file + * Documentation/ABI/testing/sysfs-bus-counter; e.g. if the component + * attribute path is /sys/bus/counter/devices/counter4/count2/count, + * the parent is count2 and thus parent ID is 2) + * @id: component ID (matching the ID provided by the respective *_component_id + * sysfs attribute of the desired component; for example, if the component + * attribute path is /sys/bus/counter/devices/counter4/count2/ceiling, the + * respective /sys/bus/counter/devices/counter4/count2/ceiling_component_id + * attribute will provide the necessary component ID) + * ) + */ +struct counter_component { + __u8 type; + __u8 scope; + __u8 parent; + __u8 id; +}; + +/* Event type definitions */ +enum counter_event_type { + COUNTER_EVENT_OVERFLOW, + COUNTER_EVENT_UNDERFLOW, + COUNTER_EVENT_OVERFLOW_UNDERFLOW, + COUNTER_EVENT_THRESHOLD, + COUNTER_EVENT_INDEX, +}; + +/** + * struct counter_watch - Counter component watch configuration + * @component: component to watch when event triggers + * @event: event that triggers (one of enum counter_event_type) + * @channel: event channel (typically 0 unless the device supports concurrent + * events of the same type) + */ +struct counter_watch { + struct counter_component component; + __u8 event; + __u8 channel; +}; + +/* ioctl commands */ +#define COUNTER_ADD_WATCH_IOCTL _IOW(0x3E, 0x00, struct counter_watch) +#define COUNTER_ENABLE_EVENTS_IOCTL _IO(0x3E, 0x01) +#define COUNTER_DISABLE_EVENTS_IOCTL _IO(0x3E, 0x02) + +/** + * struct counter_event - Counter event data + * @timestamp: best estimate of time of event occurrence, in nanoseconds + * @value: component value + * @watch: component watch configuration + * @status: return status (system error number) + */ +struct counter_event { + __aligned_u64 timestamp; + __aligned_u64 value; + struct counter_watch watch; + __u8 status; +}; + /* Count direction values */ enum counter_count_direction { COUNTER_COUNT_DIRECTION_FORWARD, From patchwork Tue Mar 9 13:19:40 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: 12125201 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 A27C7C433DB for ; Tue, 9 Mar 2021 13:23:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B07964D8F for ; Tue, 9 Mar 2021 13:23:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230458AbhCINXC (ORCPT ); Tue, 9 Mar 2021 08:23:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231639AbhCINWe (ORCPT ); Tue, 9 Mar 2021 08:22:34 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBE52C06174A; Tue, 9 Mar 2021 05:22:33 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id l2so8754970pgb.1; Tue, 09 Mar 2021 05:22:33 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=pDzQt0/2+i/dQbypd4yfAA5WY7pXM4l8c8IBFX2FigM=; b=j0souLXbEhsLNkFUC5c7rtikOvo6LbXWLoqcm4VfAMtb403Ts4ro2a3CivgqabSNIM jRRSPDbOPAe2o8bz6SHFT65FL9Fxs/yckatKQ6E69Xr/Zp+3n3ONGPUPkbMXdJSVkki5 F7uRkiu9YcQmo6tGgsnx7YI3Xx+3EkTlj/S4lrGIZQSGD38fLYCmKLp12l5NlnUxuvvU wvHbJz90BMJcvqac7kaYvh43HzRzvKvGOLREq76sNRv/AV6mUu66GBnH8FpPrpDgmdSz sR0+c/3zaU0Y69Le1l6GROo/pgCm3hU4T/AFWKz48ou/o9NrTqI31QUcJwSepWiQA0xF dZ9A== 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:mime-version:content-transfer-encoding; bh=pDzQt0/2+i/dQbypd4yfAA5WY7pXM4l8c8IBFX2FigM=; b=Wi1F15J2RPC/yITLp9A+NRxQ/WDT7jqyOd/SYTnTrVpGbgyNAYP39t/ftafPFh8rlX iBFsl1c1ncIkVy72THPciLgu9wpQpBhgiKVfbSLcpSZahWfJ+EVluQZ2UWsu15CSXwHk nmudH0nmWMugGLSUU1/SWcFXTqO+NvcxKCN/AwbYHpi0CsrkJy/jsPzs4dGn7+rfTreb h9iPMV5NggXpqkfsOPPGaT29xitVdERD8u02D7BkpgEp0xxLimlGtBe6RZj7MV2Oe8x3 VoMqaSG+CzJHqyo3b9YifuMXVXUu7kwIV/IR8nk76g+kVgbX+ATktMSX0qR6byNO1suL Eg+A== X-Gm-Message-State: AOAM532NFm1pAU5l/gWEDmWWSWOxw/NJQi3CfbKQLtakqzVcZjJzmDej 5dlN771z8JMNu7YN4vswsdY= X-Google-Smtp-Source: ABdhPJxXWeuPjUpgcFDvebjjLuoxak/hT8ST39twicKI/nqvok1BoqLC2Lw8AepWgYiOr+gkPpq1/g== X-Received: by 2002:a63:1d5b:: with SMTP id d27mr20540612pgm.169.1615296153413; Tue, 09 Mar 2021 05:22:33 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:33 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 27/33] docs: counter: Document character device interface Date: Tue, 9 Mar 2021 22:19:40 +0900 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This patch adds high-level documentation about the Counter subsystem character device interface. Signed-off-by: William Breathitt Gray --- Documentation/driver-api/generic-counter.rst | 185 ++++++++++++++---- .../userspace-api/ioctl/ioctl-number.rst | 1 + 2 files changed, 145 insertions(+), 41 deletions(-) diff --git a/Documentation/driver-api/generic-counter.rst b/Documentation/driver-api/generic-counter.rst index f6397218aa4c..62a702e7f994 100644 --- a/Documentation/driver-api/generic-counter.rst +++ b/Documentation/driver-api/generic-counter.rst @@ -223,19 +223,6 @@ whether an input line is differential or single-ended) and instead focus on the core idea of what the data and process represent (e.g. position as interpreted from quadrature encoding data). -Userspace Interface -=================== - -Several sysfs attributes are generated by the Generic Counter interface, -and reside under the /sys/bus/counter/devices/counterX directory, where -counterX refers to the respective counter device. Please see -Documentation/ABI/testing/sysfs-bus-counter for detailed -information on each Generic Counter interface sysfs attribute. - -Through these sysfs attributes, programs and scripts may interact with -the Generic Counter paradigm Counts, Signals, and Synapses of respective -counter devices. - Driver API ========== @@ -388,16 +375,16 @@ userspace interface components:: / driver callbacks / ------------------- | - +---------------+ - | - V - +--------------------+ - | Counter sysfs | - +--------------------+ - | Translates to the | - | standard Counter | - | sysfs output | - +--------------------+ + +---------------+---------------+ + | | + V V + +--------------------+ +---------------------+ + | Counter sysfs | | Counter chrdev | + +--------------------+ +---------------------+ + | Translates to the | | Translates to the | + | standard Counter | | standard Counter | + | sysfs output | | character device | + +--------------------+ +---------------------+ Thereafter, data can be transferred directly between the Counter device driver and Counter userspace interface:: @@ -428,23 +415,30 @@ driver and Counter userspace interface:: / u64 / ---------- | - +---------------+ - | - V - +--------------------+ - | Counter sysfs | - +--------------------+ - | Translates to the | - | standard Counter | - | sysfs output | - |--------------------| - | Type: const char * | - | Value: "42" | - +--------------------+ - | - --------------- - / const char * / - --------------- + +---------------+---------------+ + | | + V V + +--------------------+ +---------------------+ + | Counter sysfs | | Counter chrdev | + +--------------------+ +---------------------+ + | Translates to the | | Translates to the | + | standard Counter | | standard Counter | + | sysfs output | | character device | + |--------------------| |---------------------| + | Type: const char * | | Type: u64 | + | Value: "42" | | Value: 42 | + +--------------------+ +---------------------+ + | | + --------------- ----------------------- + / const char * / / struct counter_event / + --------------- ----------------------- + | | + | V + | +-----------+ + | | read | + | +-----------+ + | \ Count: 42 / + | ----------- | V +--------------------------------------------------+ @@ -453,7 +447,7 @@ driver and Counter userspace interface:: \ Count: "42" / -------------------------------------------------- -There are three primary components involved: +There are four primary components involved: Counter device driver --------------------- @@ -473,3 +467,112 @@ and vice versa. Please refer to the ``Documentation/ABI/testing/sysfs-bus-counter`` file for a detailed breakdown of the available Generic Counter interface sysfs attributes. + +Counter chrdev +-------------- +Translates counter data to the standard Counter character device; data +is transferred via standard character device read calls, while Counter +events are configured via ioctl calls. + +Sysfs Interface +=============== + +Several sysfs attributes are generated by the Generic Counter interface, +and reside under the ``/sys/bus/counter/devices/counterX`` directory, +where ``X`` is to the respective counter device id. Please see +``Documentation/ABI/testing/sysfs-bus-counter`` for detailed information +on each Generic Counter interface sysfs attribute. + +Through these sysfs attributes, programs and scripts may interact with +the Generic Counter paradigm Counts, Signals, and Synapses of respective +counter devices. + +Counter Character Device +======================== + +Counter character device nodes are created under the ``/dev`` directory +as ``counterX``, where ``X`` is the respective counter device id. +Defines for the standard Counter data types are exposed via the +userspace ``include/uapi/linux/counter.h`` file. + +Counter events +-------------- +Counter device drivers can support Counter events by utilizing the +``counter_push_event`` function:: + + void counter_push_event(struct counter_device *const counter, const u8 event, + const u8 channel); + +The event id is specified by the ``event`` parameter; the event channel +id is specified by the ``channel`` parameter. When this function is +called, the Counter data associated with the respective event is +gathered, and a ``struct counter_event`` is generated for each datum and +pushed to userspace. + +Counter events can be configured by users to report various Counter +data of interest. This can be conceptualized as a list of Counter +component read calls to perform. For example:: + + +~~~~~~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~~~~~~~~+ + | COUNTER_EVENT_OVERFLOW | COUNTER_EVENT_INDEX | + +~~~~~~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~~~~~~~~+ + | Channel 0 | Channel 0 | + +------------------------+------------------------+ + | * Count 0 | * Signal 0 | + | * Count 1 | * Signal 0 Extension 0 | + | * Signal 3 | * Extension 4 | + | * Count 4 Extension 2 +------------------------+ + | * Signal 5 Extension 0 | Channel 1 | + | +------------------------+ + | | * Signal 4 | + | | * Signal 4 Extension 0 | + | | * Count 7 | + +------------------------+------------------------+ + +When ``counter_push_event(counter, COUNTER_EVENT_INDEX, 1)`` is called +for example, it will go down the list for the ``COUNTER_EVENT_INDEX`` +event channel 1 and execute the read callbacks for Signal 4, Signal 4 +Extension 0, and Count 4 -- the data returned for each is pushed to a +kfifo as a ``struct counter_event``, which userspace can retrieve via a +standard read operation on the respective character device node. + +Userspace +--------- +Userspace applications can configure Counter events via ioctl operations +on the Counter character device node. There following ioctl codes are +supported and provided by the ``linux/counter.h`` userspace header file: + +* COUNTER_ADD_WATCH_IOCTL: + Queues a Counter watch for the specified event. The queued watches + will not be applied until ``COUNTER_ENABLE_EVENTS_IOCTL`` is called. + +* COUNTER_ENABLE_EVENTS_IOCTL: + Enables monitoring the events specified by the Counter watches that + were queued by ``COUNTER_ADD_WATCH_IOCTL``. If events are already + enabled, the new set of watches replaces the old one. Calling this + ioctl also has the effect of clearing the queue of watches added by + ``COUNTER_ADD_WATCH_IOCTL``. + +* COUNTER_DISABLE_EVENTS_IOCTL: + Stops monitoring the previously enabled events. + +To configure events to gather Counter data, users first populate a +``struct counter_watch`` with the relevant event id, event channel id, +and the information for the desired Counter component from which to +read, and then pass it via the ``COUNTER_ADD_WATCH_IOCTL`` ioctl +command. + +Note that an event can be watched without gathering Counter data by +setting the ``component.type`` member equal to +``COUNTER_COMPONENT_NONE``. With this configuration the Counter +character device will simply populate the event timestamps for those +respective ``struct counter_event`` elements and ignore the component +value. + +The ``COUNTER_ADD_WATCH_IOCTL`` command will buffer these Counter +watches. When ready, the ``COUNTER_ENABLE_EVENTS_IOCTL`` ioctl command +may be used to activate these Counter watches. + +Userspace applications can then execute a ``read`` operation (optionally +calling ``poll`` first) on the Counter character device node to retrieve +``struct counter_event`` elements with the desired data. diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst index 96b2ae9f277f..bb57eac06f6b 100644 --- a/Documentation/userspace-api/ioctl/ioctl-number.rst +++ b/Documentation/userspace-api/ioctl/ioctl-number.rst @@ -88,6 +88,7 @@ Code Seq# Include File Comments 0x20 all drivers/cdrom/cm206.h 0x22 all scsi/sg.h +0x3E 00-0F linux/counter.h '!' 00-1F uapi/linux/seccomp.h '#' 00-3F IEEE 1394 Subsystem Block for the entire subsystem From patchwork Tue Mar 9 13:19:41 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: 12125209 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 154BDC433E6 for ; Tue, 9 Mar 2021 13:23:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92CC164D8F for ; Tue, 9 Mar 2021 13:23:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229546AbhCINXC (ORCPT ); Tue, 9 Mar 2021 08:23:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231790AbhCINWj (ORCPT ); Tue, 9 Mar 2021 08:22:39 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 080B2C06174A; Tue, 9 Mar 2021 05:22:39 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id n10so8754320pgl.10; Tue, 09 Mar 2021 05:22:39 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=eZxEvhMGZCqTsNrtNvPX14vIdsdyfKyaulgtb7u2koE=; b=t88Job9LMCG54W/PbLSI1mUCY/9s9IZ3JT8jYTwc8Kx1MLY3tIUuwFjasx+5YeNTOO UcGI9i8AHP8Qv22viAIFk9w1oLxU+slBF9d64iqwAXKqpg5Lk58JTmz9CIJ2cLqa32to NTw+cptzm5E29YfgxdfkAH8O1Wu4Z7+dg9D3c3KZUv0uZ39HouNlTX5iVQkItgJqCcsw T2SpDYc4tFazdXCAculkOVgtnvxHUsV7B/ja191cNFbeji2y6Y7nIncZnD2pTCfZvB9P 6wNK8947I1ElpTUT2KWKXfYiD91/5x/uGGrNMPHYI/tCrK0UTvSwciSM6n2E+Dsk8x49 Hacg== 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:mime-version:content-transfer-encoding; bh=eZxEvhMGZCqTsNrtNvPX14vIdsdyfKyaulgtb7u2koE=; b=jAjxO3nGZxi/lBlJWHpsWz9IY3+FaUSJxyMMkFhqHnvAVVKHONRtLow8LqMQmoSlUn IDHj4ZM6qb8RtPdr9oZamPOsnl6VkVreyS8q51MhPNZgquLXqJCDGjgmLcbCpHAOKYs5 34JKzjY166BnIWO6OVAAnYvs+MuL1MYlJ3mBNEBJlSsSZWiZ+pKdftg+nb5+uDfQfZWI mxUeMUv3/lhYomPUwg3hy4WGqfYXOL63MImmnr89R3kpTYiHt/8BiBaB4pRLcneKYis+ 4NNCApTjY9lgqVr3VPtxwCN28aLEERvgVp9EXYvhz2c2fYmBYrAGkIaK4oN8JnzrbEMs LR3w== X-Gm-Message-State: AOAM530le9+r3z8hma2Mifmp5wu0Ou8iLSAMdEVPVzlsOJTY+WIztUdv czaa+daWtFvHJGgH1LhYJis= X-Google-Smtp-Source: ABdhPJzxr830ZunUmE/ElQ4adbhtZfLxRtShFlanb+WvQjlTHY+cld4O0GWCEcCnJchsD30S/jJOZg== X-Received: by 2002:a63:1542:: with SMTP id 2mr25118957pgv.338.1615296158611; Tue, 09 Mar 2021 05:22:38 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:38 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray , Pavel Machek Subject: [PATCH v9 28/33] tools/counter: Create Counter tools Date: Tue, 9 Mar 2021 22:19:41 +0900 Message-Id: <2a8e81fae722acdf0c7d58fa5950ccfddd6adb75.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This creates an example Counter program under tools/counter/* to exemplify the Counter character device interface. Cc: Pavel Machek Signed-off-by: William Breathitt Gray --- MAINTAINERS | 1 + tools/Makefile | 13 ++--- tools/counter/Build | 1 + tools/counter/Makefile | 53 ++++++++++++++++++ tools/counter/counter_example.c | 95 +++++++++++++++++++++++++++++++++ 5 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 tools/counter/Build create mode 100644 tools/counter/Makefile create mode 100644 tools/counter/counter_example.c diff --git a/MAINTAINERS b/MAINTAINERS index 93233a07f5aa..aa61b40d02fe 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4582,6 +4582,7 @@ F: Documentation/driver-api/generic-counter.rst F: drivers/counter/ F: include/linux/counter.h F: include/uapi/linux/counter.h +F: tools/counter/ CPMAC ETHERNET DRIVER M: Florian Fainelli diff --git a/tools/Makefile b/tools/Makefile index 7e9d34ddd74c..4c26400ffc03 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -12,6 +12,7 @@ help: @echo ' acpi - ACPI tools' @echo ' bpf - misc BPF tools' @echo ' cgroup - cgroup tools' + @echo ' counter - Counter tools' @echo ' cpupower - a tool for all things x86 CPU power' @echo ' debugging - tools for debugging' @echo ' firewire - the userspace part of nosy, an IEEE-1394 traffic sniffer' @@ -65,7 +66,7 @@ acpi: FORCE cpupower: FORCE $(call descend,power/$@) -cgroup firewire hv guest bootconfig spi usb virtio vm bpf iio gpio objtool leds wmi pci firmware debugging tracing: FORCE +cgroup counter firewire hv guest bootconfig spi usb virtio vm bpf iio gpio objtool leds wmi pci firmware debugging tracing: FORCE $(call descend,$@) bpf/%: FORCE @@ -100,7 +101,7 @@ freefall: FORCE kvm_stat: FORCE $(call descend,kvm/$@) -all: acpi cgroup cpupower gpio hv firewire liblockdep \ +all: acpi cgroup counter cpupower gpio hv firewire liblockdep \ perf selftests bootconfig spi turbostat usb \ virtio vm bpf x86_energy_perf_policy \ tmon freefall iio objtool kvm_stat wmi \ @@ -112,7 +113,7 @@ acpi_install: cpupower_install: $(call descend,power/$(@:_install=),install) -cgroup_install firewire_install gpio_install hv_install iio_install perf_install bootconfig_install spi_install usb_install virtio_install vm_install bpf_install objtool_install wmi_install pci_install debugging_install tracing_install: +cgroup_install counter_install firewire_install gpio_install hv_install iio_install perf_install bootconfig_install spi_install usb_install virtio_install vm_install bpf_install objtool_install wmi_install pci_install debugging_install tracing_install: $(call descend,$(@:_install=),install) liblockdep_install: @@ -133,7 +134,7 @@ freefall_install: kvm_stat_install: $(call descend,kvm/$(@:_install=),install) -install: acpi_install cgroup_install cpupower_install gpio_install \ +install: acpi_install cgroup_install counter_install cpupower_install gpio_install \ hv_install firewire_install iio_install liblockdep_install \ perf_install selftests_install turbostat_install usb_install \ virtio_install vm_install bpf_install x86_energy_perf_policy_install \ @@ -147,7 +148,7 @@ acpi_clean: cpupower_clean: $(call descend,power/cpupower,clean) -cgroup_clean hv_clean firewire_clean bootconfig_clean spi_clean usb_clean virtio_clean vm_clean wmi_clean bpf_clean iio_clean gpio_clean objtool_clean leds_clean pci_clean firmware_clean debugging_clean tracing_clean: +cgroup_clean counter_clean hv_clean firewire_clean bootconfig_clean spi_clean usb_clean virtio_clean vm_clean wmi_clean bpf_clean iio_clean gpio_clean objtool_clean leds_clean pci_clean firmware_clean debugging_clean tracing_clean: $(call descend,$(@:_clean=),clean) liblockdep_clean: @@ -181,7 +182,7 @@ freefall_clean: build_clean: $(call descend,build,clean) -clean: acpi_clean cgroup_clean cpupower_clean hv_clean firewire_clean \ +clean: acpi_clean cgroup_clean counter_clean cpupower_clean hv_clean firewire_clean \ perf_clean selftests_clean turbostat_clean bootconfig_clean spi_clean usb_clean virtio_clean \ vm_clean bpf_clean iio_clean x86_energy_perf_policy_clean tmon_clean \ freefall_clean build_clean libbpf_clean libsubcmd_clean liblockdep_clean \ diff --git a/tools/counter/Build b/tools/counter/Build new file mode 100644 index 000000000000..33f4a51d715e --- /dev/null +++ b/tools/counter/Build @@ -0,0 +1 @@ +counter_example-y += counter_example.o diff --git a/tools/counter/Makefile b/tools/counter/Makefile new file mode 100644 index 000000000000..5ebc195fd9c0 --- /dev/null +++ b/tools/counter/Makefile @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: GPL-2.0 +include ../scripts/Makefile.include + +bindir ?= /usr/bin + +ifeq ($(srctree),) +srctree := $(patsubst %/,%,$(dir $(CURDIR))) +srctree := $(patsubst %/,%,$(dir $(srctree))) +endif + +# Do not use make's built-in rules +# (this improves performance and avoids hard-to-debug behaviour); +MAKEFLAGS += -r + +override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include + +ALL_TARGETS := counter_example +ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) + +all: $(ALL_PROGRAMS) + +export srctree OUTPUT CC LD CFLAGS +include $(srctree)/tools/build/Makefile.include + +# +# We need the following to be outside of kernel tree +# +$(OUTPUT)include/linux/counter.h: ../../include/uapi/linux/counter.h + mkdir -p $(OUTPUT)include/linux 2>&1 || true + ln -sf $(CURDIR)/../../include/uapi/linux/counter.h $@ + +prepare: $(OUTPUT)include/linux/counter.h + +COUNTER_EXAMPLE := $(OUTPUT)counter_example.o +$(COUNTER_EXAMPLE): prepare FORCE + $(Q)$(MAKE) $(build)=counter_example +$(OUTPUT)counter_example: $(COUNTER_EXAMPLE) + $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ + +clean: + rm -f $(ALL_PROGRAMS) + rm -rf $(OUTPUT)include/linux/counter.h + find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete + +install: $(ALL_PROGRAMS) + install -d -m 755 $(DESTDIR)$(bindir); \ + for program in $(ALL_PROGRAMS); do \ + install $$program $(DESTDIR)$(bindir); \ + done + +FORCE: + +.PHONY: all install clean FORCE prepare diff --git a/tools/counter/counter_example.c b/tools/counter/counter_example.c new file mode 100644 index 000000000000..71dfec673c11 --- /dev/null +++ b/tools/counter/counter_example.c @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Counter - example userspace application + * + * The userspace application opens /dev/counter0, configures the + * COUNTER_EVENT_INDEX event channel 0 to gather Count 0 count and Count + * 1 count, and prints out the data as it becomes available on the + * character device node. + * + * Copyright (C) 2021 William Breathitt Gray + */ +#include +#include +#include +#include +#include +#include +#include + +struct counter_watch watches[2] = { + { + /* Component data: Count 0 count */ + .component.type = COUNTER_COMPONENT_COUNT, + .component.scope = COUNTER_SCOPE_COUNT, + .component.parent = 0, + /* Event type: Index */ + .event = COUNTER_EVENT_INDEX, + /* Device event channel 0 */ + .channel = 0, + }, + { + /* Component data: Count 1 count */ + .component.type = COUNTER_COMPONENT_COUNT, + .component.scope = COUNTER_SCOPE_COUNT, + .component.parent = 1, + /* Event type: Index */ + .event = COUNTER_EVENT_INDEX, + /* Device event channel 0 */ + .channel = 0, + }, +}; + +int main(void) +{ + int fd; + int ret; + struct counter_event event_data[2]; + + fd = open("/dev/counter0", O_RDWR); + if (fd == -1) { + perror("Unable to open /dev/counter0"); + return -errno; + } + + ret = ioctl(fd, COUNTER_ADD_WATCH_IOCTL, watches); + if (ret == -1) { + perror("Error adding watches[0]"); + return -errno; + } + ret = ioctl(fd, COUNTER_ADD_WATCH_IOCTL, watches + 1); + if (ret == -1) { + perror("Error adding watches[1]"); + return -errno; + } + ret = ioctl(fd, COUNTER_ENABLE_EVENTS_IOCTL); + if (ret == -1) { + perror("Error enabling events"); + return -errno; + } + + for (;;) { + ret = read(fd, event_data, sizeof(event_data)); + if (ret == -1) { + perror("Failed to read event data"); + return -errno; + } + + if (ret != sizeof(event_data)) { + fprintf(stderr, "Failed to read event data\n"); + return -EIO; + } + + printf("Timestamp 0: %llu\tCount 0: %llu\n" + "Error Message 0: %s\n" + "Timestamp 1: %llu\tCount 1: %llu\n" + "Error Message 1: %s\n", + (unsigned long long)event_data[0].timestamp, + (unsigned long long)event_data[0].value, + strerror(event_data[0].status), + (unsigned long long)event_data[1].timestamp, + (unsigned long long)event_data[1].value, + strerror(event_data[1].status)); + } + + return 0; +} From patchwork Tue Mar 9 13:19:42 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: 12125205 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 4EDCFC43381 for ; Tue, 9 Mar 2021 13:23:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CFD86527C for ; Tue, 9 Mar 2021 13:23:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231408AbhCINXE (ORCPT ); Tue, 9 Mar 2021 08:23:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231856AbhCINWo (ORCPT ); Tue, 9 Mar 2021 08:22:44 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F06FC06174A; Tue, 9 Mar 2021 05:22:44 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id cl21-20020a17090af695b02900c61ac0f0e9so886104pjb.1; Tue, 09 Mar 2021 05:22:44 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=Pil4P2EiLTeNqa4+JCYgDjTol3Ay4ymexuC8jw3Zjn0=; b=vHWBQdDrLaykvvsgZrbdom6eyYce8unhe7aM985VIl5WEK8HbLU/P7l7zAp9gUfHla qm4eydAHJd2zCHWBhk7YlmHzbJMcMEA+rMSuNUuWhfbgHQxdO0l5YVwhPEm0q1Ks8Zdy wY0Wsf86dR+cd9rBADOg+/+4mxmMo1D6jg4NKIf9SZ+9l6uf4UtMRTZvepPVDUzSutKE FnqKsvZcCf41WMX9NXPp9ZSreVmS1WJPewO11tMj9R1qKp6HmEzMNP/1aDmcWr+wNDGA rSkPw5KDs1l4aGgb/yTNXDEPvFhG2F4Z4a5pL2WbxmBDQ6WcjfULPKl15Th+CClN87DG EM/A== 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:mime-version:content-transfer-encoding; bh=Pil4P2EiLTeNqa4+JCYgDjTol3Ay4ymexuC8jw3Zjn0=; b=Ehy8sAtHL6NAbVpTuLtiNGZo139d3EvKgwmb4G2fVikau/D8k+oVWuk4sZc3qfauUA GMrQOWjRkM2WU5MHkaHF12hzLaKZAe0MzT7TR0hN3u89tQa/RZtATskd8qBChrVrt8Tw ANfDVXs1PzUKghr1NZxN5I+Cth1JMNJ8j0tPplDSDw5/rX77fAW34PvOvWuFx3yTSiuu zB5aydvE+aSuuMVjmN+FkiQxqDRDYAgxAVT4S7BChLDblQA5i9FtJBNwVQSg/cgoG5g6 p3VtkMtdSvhrQ8yg0bJAtwSMwjJ1uP2EjQowrarcneFQNJCukBWHTPhfU0Z7i/JKlC7i AzRQ== X-Gm-Message-State: AOAM5338zqQYWpBhzb1oKb6/1ENoAIKqjT4nHG5km4MWmTVtqGSgzIHe 14pmjWif0T+eG0x1Zzv6wDo= X-Google-Smtp-Source: ABdhPJx2+7TMpxmPwB8f2imz2lq/HqwstME+VlB4l/4nqWHUym/jtWDawd5d6s35EUJ0Uz178tNZGA== X-Received: by 2002:a17:902:6bca:b029:e2:c5d6:973e with SMTP id m10-20020a1709026bcab02900e2c5d6973emr25715061plt.40.1615296163745; Tue, 09 Mar 2021 05:22:43 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:43 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray , Dan Carpenter Subject: [PATCH v9 29/33] counter: Implement signalZ_action_component_id sysfs attribute Date: Tue, 9 Mar 2021 22:19:42 +0900 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The Generic Counter chrdev interface expects users to supply component IDs in order to select Synapses for requests. In order for users to know what component ID belongs to which Synapse this information must be exposed. The signalZ_action_component_id attribute provides a way for users to discover what component ID belongs to the respective Synapse. Cc: David Lechner Cc: Gwendal Grignou Cc: Dan Carpenter Signed-off-by: William Breathitt Gray --- Documentation/ABI/testing/sysfs-bus-counter | 7 ++++ drivers/counter/counter-sysfs.c | 45 +++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter index 6353f0a2f8f8..bee9289aecd1 100644 --- a/Documentation/ABI/testing/sysfs-bus-counter +++ b/Documentation/ABI/testing/sysfs-bus-counter @@ -203,6 +203,13 @@ Description: both edges: Any state transition. +What: /sys/bus/counter/devices/counterX/countY/signalZ_action_component_id +KernelVersion: 5.13 +Contact: linux-iio@vger.kernel.org +Description: + Read-only attribute that indicates the component ID of the + respective Synapse of Count Y for Signal Z. + What: /sys/bus/counter/devices/counterX/name KernelVersion: 5.2 Contact: linux-iio@vger.kernel.org diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c index e65e6039a347..8f11499c8ec1 100644 --- a/drivers/counter/counter-sysfs.c +++ b/drivers/counter/counter-sysfs.c @@ -533,6 +533,46 @@ static int counter_name_attr_create(struct device *const dev, return 0; } +static ssize_t counter_comp_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + const size_t id = (size_t)to_counter_attribute(attr)->comp.priv; + + return sysfs_emit(buf, "%zu\n", id); +} + +static int counter_comp_id_attr_create(struct device *const dev, + struct counter_attribute_group *const group, + const char *name, const size_t id) +{ + struct counter_attribute *counter_attr; + + /* Allocate Counter attribute */ + counter_attr = devm_kzalloc(dev, sizeof(*counter_attr), GFP_KERNEL); + if (!counter_attr) + return -ENOMEM; + + /* Generate component ID name */ + name = devm_kasprintf(dev, GFP_KERNEL, "%s_component_id", name); + if (!name) + return -ENOMEM; + + /* Configure Counter attribute */ + counter_attr->comp.priv = (void *)id; + + /* Configure device attribute */ + sysfs_attr_init(&counter_attr->dev_attr.attr); + counter_attr->dev_attr.attr.name = name; + counter_attr->dev_attr.attr.mode = 0444; + counter_attr->dev_attr.show = counter_comp_id_show; + + /* Store list node */ + list_add(&counter_attr->l, &group->attr_list); + group->num_attr++; + + return 0; +} + static struct counter_comp counter_signal_comp = { .type = COUNTER_COMP_SIGNAL_LEVEL, .name = "signal", @@ -627,6 +667,11 @@ static int counter_sysfs_synapses_add(struct counter_device *const counter, COUNTER_SCOPE_COUNT, count); if (err < 0) return err; + + /* Create Synapse component ID attribute */ + err = counter_comp_id_attr_create(dev, group, comp.name, i); + if (err < 0) + return err; } return 0; From patchwork Tue Mar 9 13:19:43 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: 12125203 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 30FCBC433E9 for ; Tue, 9 Mar 2021 13:23:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E720364EBB for ; Tue, 9 Mar 2021 13:23:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231469AbhCINXE (ORCPT ); Tue, 9 Mar 2021 08:23:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231127AbhCINWt (ORCPT ); Tue, 9 Mar 2021 08:22:49 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 625B4C06174A; Tue, 9 Mar 2021 05:22:49 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id kk2-20020a17090b4a02b02900c777aa746fso5189206pjb.3; Tue, 09 Mar 2021 05:22:49 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=PoLaEjlOjTaQwbMALD2RFnapOU7EJm1z/oVIMUH9q/A=; b=LqozAFDFYYNf99e8w+zRIrHgYp9tgzrV/gwm5MRR23X0ip2OyPiTEBzg5H4cGfOD7o laKGsdA3dipNyTrjHXZdYaBDtZyRoaICq/8DphfKjnxTyzZeUxZgkV9PefoLRSRL71GZ oo69ns0+Ntd5zlOsWOirvKcoxqZKDuGgUlH89VdUGiaxg1Uvwt3GJU3GuaRY39BM72k2 LKsdGnQpHRBfmJxwL+qLBBXLCU5/Lh5c5gmZFm9wb3rZdX1v3ZAUTMXWupo5nAnFvXWr 5vc5xIO799jUe+RLiVQzVNc27AQhg/ve/TIPvrbDzhPwxWzACiO3QYFm5gPrmZ5Zg828 yygA== 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:mime-version:content-transfer-encoding; bh=PoLaEjlOjTaQwbMALD2RFnapOU7EJm1z/oVIMUH9q/A=; b=c/TVDNTFRRdMirQnLsDMbvF8OeJ3EUCceTohdQKSX9cSD0az8GypRkY9WHWU1wFfwR WzmDE0V/eMJyI2/mmwED2liJtN5ka6NFGNc9B/Y8+mGycsPgMm2eQoWAr4dcL2STEAaw q5nwYGw+842kuhz3R4qYZTQ8FWVmO0V8fsy81EkFoDbTW0JVUHacuyzeZ/SM4ba1TTnE ewgGD4yVQruHNfh2zETUYW+3rRpvYbPycXiRFNUlwdSDPezz0ZrXko0ZeGhHJGNf49uE 6txZS+Z6dzF+OmVgZaXDcQAZiUEcQI/glKPPQNjLgmrZpxLlcg3UeibKazi/DgXM7yOm VJwA== X-Gm-Message-State: AOAM530Es3bQ0fV9fnI9Ddtu6KqmPgktl1o9HgsGNcg9I3GNBM7l8dQ+ +DciSIhX7iUvnLADfXZLktg= X-Google-Smtp-Source: ABdhPJyEyvfPp8C+VGL/bFry1z9hjf8zNpN00O2FGi3o5Qj7xQPCvy9Z60EXYcCo9fE2IwKHz5RkZw== X-Received: by 2002:a17:90b:3890:: with SMTP id mu16mr4713032pjb.9.1615296168925; Tue, 09 Mar 2021 05:22:48 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:48 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray , Dan Carpenter Subject: [PATCH v9 30/33] counter: Implement *_component_id sysfs attributes Date: Tue, 9 Mar 2021 22:19:43 +0900 Message-Id: <9bca8f6c4202a0bb61db4f3cc0c0f53a06cde3e6.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The Generic Counter chrdev interface expects users to supply component IDs in order to select extensions for requests. In order for users to know what component ID belongs to which extension this information must be exposed. The *_component_id attribute provides a way for users to discover what component ID belongs to which respective extension. Cc: David Lechner Cc: Gwendal Grignou Cc: Dan Carpenter Signed-off-by: William Breathitt Gray --- Documentation/ABI/testing/sysfs-bus-counter | 16 ++++++++++- drivers/counter/counter-sysfs.c | 30 ++++++++++++++++----- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter index bee9289aecd1..57b051ba53a9 100644 --- a/Documentation/ABI/testing/sysfs-bus-counter +++ b/Documentation/ABI/testing/sysfs-bus-counter @@ -203,12 +203,26 @@ Description: both edges: Any state transition. +What: /sys/bus/counter/devices/counterX/countY/ceiling_component_id +What: /sys/bus/counter/devices/counterX/countY/floor_component_id +What: /sys/bus/counter/devices/counterX/countY/count_mode_component_id +What: /sys/bus/counter/devices/counterX/countY/direction_component_id +What: /sys/bus/counter/devices/counterX/countY/enable_component_id +What: /sys/bus/counter/devices/counterX/countY/error_noise_component_id +What: /sys/bus/counter/devices/counterX/countY/prescaler_component_id +What: /sys/bus/counter/devices/counterX/countY/preset_component_id +What: /sys/bus/counter/devices/counterX/countY/preset_enable_component_id What: /sys/bus/counter/devices/counterX/countY/signalZ_action_component_id +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_component_id +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_enable_component_id +What: /sys/bus/counter/devices/counterX/signalY/filter_clock_prescaler_component_id +What: /sys/bus/counter/devices/counterX/signalY/index_polarity_component_id +What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode_component_id KernelVersion: 5.13 Contact: linux-iio@vger.kernel.org Description: Read-only attribute that indicates the component ID of the - respective Synapse of Count Y for Signal Z. + respective extension or Synapse. What: /sys/bus/counter/devices/counterX/name KernelVersion: 5.2 diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c index 8f11499c8ec1..7c1f79766920 100644 --- a/drivers/counter/counter-sysfs.c +++ b/drivers/counter/counter-sysfs.c @@ -587,6 +587,7 @@ static int counter_signal_attrs_create(struct counter_device *const counter, int err; struct counter_comp comp; size_t i; + struct counter_comp *ext; /* Create main Signal attribute */ comp = counter_signal_comp; @@ -602,8 +603,13 @@ static int counter_signal_attrs_create(struct counter_device *const counter, /* Create an attribute for each extension */ for (i = 0; i < signal->num_ext; i++) { - err = counter_attr_create(dev, group, signal->ext + i, scope, - signal); + ext = signal->ext + i; + + err = counter_attr_create(dev, group, ext, scope, signal); + if (err < 0) + return err; + + err = counter_comp_id_attr_create(dev, group, ext->name, i); if (err < 0) return err; } @@ -694,6 +700,7 @@ static int counter_count_attrs_create(struct counter_device *const counter, int err; struct counter_comp comp; size_t i; + struct counter_comp *ext; /* Create main Count attribute */ comp = counter_count_comp; @@ -718,8 +725,13 @@ static int counter_count_attrs_create(struct counter_device *const counter, /* Create an attribute for each extension */ for (i = 0; i < count->num_ext; i++) { - err = counter_attr_create(dev, group, count->ext + i, scope, - count); + ext = count->ext + i; + + err = counter_attr_create(dev, group, ext, scope, count); + if (err < 0) + return err; + + err = counter_comp_id_attr_create(dev, group, ext->name, i); if (err < 0) return err; } @@ -783,6 +795,7 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, struct device *const dev = &counter->dev; int err; size_t i; + struct counter_comp *ext; /* Add Signals sysfs attributes */ err = counter_sysfs_signals_add(counter, group); @@ -815,8 +828,13 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, /* Create an attribute for each extension */ for (i = 0; i < counter->num_ext; i++) { - err = counter_attr_create(dev, group, counter->ext + i, scope, - NULL); + ext = counter->ext + i; + + err = counter_attr_create(dev, group, ext, scope, NULL); + if (err < 0) + return err; + + err = counter_comp_id_attr_create(dev, group, ext->name, i); if (err < 0) return err; } From patchwork Tue Mar 9 13:19:44 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: 12125207 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 6628DC4332B for ; Tue, 9 Mar 2021 13:23:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25E4964D8F for ; Tue, 9 Mar 2021 13:23:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231504AbhCINXF (ORCPT ); Tue, 9 Mar 2021 08:23:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbhCINWy (ORCPT ); Tue, 9 Mar 2021 08:22:54 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5BBFC06174A; Tue, 9 Mar 2021 05:22:54 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id l2so8755550pgb.1; Tue, 09 Mar 2021 05:22:54 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=2ImcimOQjpteeputqyYkCfESXcyDSfWhIx0TlBJ0SRw=; b=LAc0lWzR/uRULa/lND2735TKI21F3MRlGyK8UcuJRlO12n+7ByhrW5gfpI0nC5h3yS uuqgrunCElphTAIUpY5TwSZQMGisu/YRkQTqehyNE2BS0tJzE0NEqMOh1fRWBzQVXU0T 2bKl+pc5sXh0mx5NvSPQZZ18PW10rlr9MEoJKAh8agMJt/DrdbUnhyadvbgSKE3reVL/ 2TYOKnrh6Ottv2Fayaspay0aUJ0cvHDxRCxukrROCk+bkWmo62pY0RR1A57mx/wLRSzK LkPjq99tCyuEUGN2M5u4vHgZEACd7yMQW1ws94EyWSuy+Q9Cz1GLRFYfxTBtpDHw1uhc /rKA== 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:mime-version:content-transfer-encoding; bh=2ImcimOQjpteeputqyYkCfESXcyDSfWhIx0TlBJ0SRw=; b=Filh9CMeycdYbz0q1XMllzJMSGH2ggGZeWkfXW+z8k5L7BW+CVDpl1BIpBGWiU0mRW us3O4+LMfYdB17JGneQ0ITM5o19NkzpaWxGBuHAM8ZN+zgG/XsD+8cNZqxZV9qZu4RU8 ANieR7ulzPIYbVx3O8KWX1WKA//39KV8nV/CSxCSTD/Qf83hfKUbGuSJm1u/pV1LIEDz IznhlqnLwrF+BxZaJb/8LCd9Xemcw60bOsiz/BHUrg81eL5Q1LP69mAI86mF+wKdWA3s DFoGe44RHsf7fEl1fBZGkZgkBDnb9qDbrJrCuwGytli8xOw2fvyvwbVTP7Phn8KNSpGO v4yw== X-Gm-Message-State: AOAM533gyW5Jhc32MwuTWI7yNlkPl6+MA5jflTxDADxnn67vo4Mth8Af 1vSUuqcdKnmFYJ0/fQUmYWU= X-Google-Smtp-Source: ABdhPJwj7SaGxNLQagkdbr0BSwiMgB1gz6bYJykXMSqKVnYxX8jaPJ5n/kqnnXnzgotusvslKH5/dw== X-Received: by 2002:a65:50c8:: with SMTP id s8mr25035165pgp.68.1615296174343; Tue, 09 Mar 2021 05:22:54 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:53 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 31/33] counter: Implement events_queue_size sysfs attribute Date: Tue, 9 Mar 2021 22:19:44 +0900 Message-Id: <57ab5e4a4b273685ba9925fe7aaa520c4ce4be29.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The events_queue_size sysfs attribute provides a way for users to dynamically configure the Counter events queue size for the Counter character device interface. The size is in number of struct counter_event data structures. The number of elements will be rounded-up to a power of 2 due to a requirement of the kfifo_alloc function called during reallocation of the queue. Cc: Oleksij Rempel Signed-off-by: William Breathitt Gray --- Documentation/ABI/testing/sysfs-bus-counter | 8 ++++ drivers/counter/counter-chrdev.c | 4 ++ drivers/counter/counter-sysfs.c | 44 +++++++++++++++++++++ include/linux/counter.h | 2 + 4 files changed, 58 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter index 57b051ba53a9..a97d85e97184 100644 --- a/Documentation/ABI/testing/sysfs-bus-counter +++ b/Documentation/ABI/testing/sysfs-bus-counter @@ -224,6 +224,14 @@ Description: Read-only attribute that indicates the component ID of the respective extension or Synapse. +What: /sys/bus/counter/devices/counterX/events_queue_size +KernelVersion: 5.13 +Contact: linux-iio@vger.kernel.org +Description: + Size of the Counter events queue in number of struct + counter_event data structures. The number of elements will be + rounded-up to a power of 2. + What: /sys/bus/counter/devices/counterX/name KernelVersion: 5.2 Contact: linux-iio@vger.kernel.org diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c index d5f92b2d3bb4..d9f123ca0ed6 100644 --- a/drivers/counter/counter-chrdev.c +++ b/drivers/counter/counter-chrdev.c @@ -311,6 +311,9 @@ static int counter_chrdev_open(struct inode *inode, struct file *filp) typeof(*counter), chrdev); + if (!mutex_trylock(&counter->chrdev_lock)) + return -EBUSY; + get_device(&counter->dev); filp->private_data = counter; @@ -327,6 +330,7 @@ static int counter_chrdev_release(struct inode *inode, struct file *filp) return err; put_device(&counter->dev); + mutex_unlock(&counter->chrdev_lock); return 0; } diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c index 7c1f79766920..7d7f6cb44ca4 100644 --- a/drivers/counter/counter-sysfs.c +++ b/drivers/counter/counter-sysfs.c @@ -8,7 +8,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -782,12 +784,48 @@ static int counter_num_counts_read(struct counter_device *counter, u8 *val) return 0; } +static int counter_events_queue_size_read(struct counter_device *counter, + u64 *val) +{ + *val = kfifo_size(&counter->events); + return 0; +} + +static int counter_events_queue_size_write(struct counter_device *counter, + u64 val) +{ + int err; + DECLARE_KFIFO_PTR(events, struct counter_event); + + /* Verify chrdev is not currently being used */ + if (!mutex_trylock(&counter->chrdev_lock)) + return -EBUSY; + + /* Allocate new events queue */ + err = kfifo_alloc(&events, val, GFP_ATOMIC); + if (err) + return err; + + /* Swap in new events queue */ + kfifo_free(&counter->events); + counter->events.kfifo = events.kfifo; + + mutex_unlock(&counter->chrdev_lock); + + return 0; +} + static struct counter_comp counter_num_signals_comp = COUNTER_COMP_DEVICE_U8("num_signals", counter_num_signals_read, NULL); static struct counter_comp counter_num_counts_comp = COUNTER_COMP_DEVICE_U8("num_counts", counter_num_counts_read, NULL); +static struct counter_comp counter_events_queue_size_comp = + COUNTER_COMP_DEVICE_U64("events_queue_size", + counter_events_queue_size_read, + counter_events_queue_size_write); + static int counter_sysfs_attr_add(struct counter_device *const counter, struct counter_attribute_group *group) { @@ -826,6 +864,12 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, if (err < 0) return err; + /* Create num_counts attribute */ + err = counter_attr_create(dev, group, &counter_events_queue_size_comp, + scope, NULL); + if (err < 0) + return err; + /* Create an attribute for each extension */ for (i = 0; i < counter->num_ext; i++) { ext = counter->ext + i; diff --git a/include/linux/counter.h b/include/linux/counter.h index 3f0bbe4ff702..854fcaf49c32 100644 --- a/include/linux/counter.h +++ b/include/linux/counter.h @@ -289,6 +289,7 @@ struct counter_ops { * @priv: optional private data supplied by driver * @dev: internal device structure * @chrdev: internal character device structure + * @chrdev_lock: lock to limit chrdev to a single open at a time * @events_list: list of current watching Counter events * @events_list_lock: lock to protect Counter events list operations * @next_events_list: list of next watching Counter events @@ -314,6 +315,7 @@ struct counter_device { struct device dev; struct cdev chrdev; + struct mutex chrdev_lock; struct list_head events_list; spinlock_t events_list_lock; struct list_head next_events_list; From patchwork Tue Mar 9 13:19:45 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: 12125211 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 9E333C4332D for ; Tue, 9 Mar 2021 13:23:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EE93652B6 for ; Tue, 9 Mar 2021 13:23:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbhCINXG (ORCPT ); Tue, 9 Mar 2021 08:23:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbhCINXA (ORCPT ); Tue, 9 Mar 2021 08:23:00 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2B10C06174A; Tue, 9 Mar 2021 05:22:59 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id a188so9480499pfb.4; Tue, 09 Mar 2021 05:22:59 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=Adlthpk1aAH2oSwy9m6Zem8bbwU9WcVEQtQqzZI5TWE=; b=TcU9Cmc/8JDfsyTjSvIeZ0MFr0WOSQlDq3BphgGI8tkaAD3MG7Fsxkv8GKSrlTGVvp 29dRBVQHFa5NYtugsW0v4AmvrlPinOTRtIqgf4zRHSS+ZontD/ttEAuCggnvw7n1qHVU NPf+SY8lg4Px9waE9cjFx1yi22XLjxIPEmfPc9Gk8DRqHopPkMRmpu9Hs9yCagrsfOFy KiVMZRLWsIdq3wwyJ4xQzL3jm/3dWErUj8ZKJuF8Wq6/20/aUBNlnvUmjaknpqilfAun JvJkEaAgT4yvjEKEd0fw9FbC5oITQ0XkYBh2esAWfB0yaHImvz3IBrfYgdtVYM6YISGt hEsQ== 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:mime-version:content-transfer-encoding; bh=Adlthpk1aAH2oSwy9m6Zem8bbwU9WcVEQtQqzZI5TWE=; b=XqQqcx4UOa5XjOP649j87bW8bBi9XpFfriQJkoyANjaNEnVvb65DzEznbQwJ+k2YcR wfvyZ1m3hRInMrlQY6yBoX+rzhlRNjzIKSwuEtD31rXVNMBeAP70RR4SMIJhEwPN9QgC JOd3ryYwkx6taYpocJAsOAfhh0yb4PvNhpbY2G9ajAQaxBA9cTtIQ01DfCKOajvn5E+1 GEwmSNR4w9XBQ0eE0FiJt2IxfbWpIjKBaFHVzZaF80ZYjqNSCRFDowjbLKwNp2ILd/zW oHII3K0JErZa8a/eT+X3bGKV+aerZEhdJIf3Wm/i5vx/uVD9dPtpDsalZ7AZNCdznbK/ BScA== X-Gm-Message-State: AOAM530GUi53G+80NHj43fTgQ2g0ldrdw+q9OgdQ0kTmB1LG7DPls5d+ 8+ShFuFriyiACwLLbSp8uLc= X-Google-Smtp-Source: ABdhPJzJtGOQ4T9TyJ76b7HayNm4NUeRwST0Wiy3qP2wepJekCcgAMPcWZ6EcXrhtRa16vq1L9hnFQ== X-Received: by 2002:aa7:95b5:0:b029:1ef:272f:920c with SMTP id a21-20020aa795b50000b02901ef272f920cmr23700108pfk.21.1615296179318; Tue, 09 Mar 2021 05:22:59 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:22:58 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 32/33] counter: 104-quad-8: Replace mutex with spinlock Date: Tue, 9 Mar 2021 22:19:45 +0900 Message-Id: <49d48ab6b10744db6a8de8724912069af934e962.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This patch replaces the mutex I/O lock with a spinlock. This is in preparation for a subsequent patch adding IRQ support for 104-QUAD-8 devices; we can't sleep in an interrupt context, so we'll need to use a spinlock instead. Cc: Syed Nayyar Waris Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 90 +++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index eb7d63769f4c..d46b8101f207 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -16,6 +16,7 @@ #include #include #include +#include #define QUAD8_EXTENT 32 @@ -28,6 +29,7 @@ MODULE_PARM_DESC(base, "ACCES 104-QUAD-8 base addresses"); /** * struct quad8 - device private data structure + * @lock: lock to prevent clobbering device states during R/W ops * @counter: instance of the counter_device * @fck_prescaler: array of filter clock prescaler configurations * @preset: array of preset values @@ -42,7 +44,7 @@ MODULE_PARM_DESC(base, "ACCES 104-QUAD-8 base addresses"); * @base: base port address of the device */ struct quad8 { - struct mutex lock; + spinlock_t lock; struct counter_device counter; unsigned int fck_prescaler[QUAD8_NUM_COUNTERS]; unsigned int preset[QUAD8_NUM_COUNTERS]; @@ -123,6 +125,7 @@ static int quad8_count_read(struct counter_device *counter, unsigned int flags; unsigned int borrow; unsigned int carry; + unsigned long irqflags; int i; flags = inb(base_offset + 1); @@ -132,7 +135,7 @@ static int quad8_count_read(struct counter_device *counter, /* Borrow XOR Carry effectively doubles count range */ *val = (unsigned long)(borrow ^ carry) << 24; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); /* Reset Byte Pointer; transfer Counter to Output Latch */ outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_CNTR_OUT, @@ -141,7 +144,7 @@ static int quad8_count_read(struct counter_device *counter, for (i = 0; i < 3; i++) *val |= (unsigned long)inb(base_offset) << (8 * i); - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -151,13 +154,14 @@ static int quad8_count_write(struct counter_device *counter, { struct quad8 *const priv = counter->priv; const int base_offset = priv->base + 2 * count->id; + unsigned long irqflags; int i; /* Only 24-bit values are supported */ if (val > 0xFFFFFF) return -ERANGE; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); /* Reset Byte Pointer */ outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1); @@ -182,7 +186,7 @@ static int quad8_count_write(struct counter_device *counter, /* Reset Error flag */ outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1); - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -200,8 +204,9 @@ static int quad8_function_read(struct counter_device *counter, { struct quad8 *const priv = counter->priv; const int id = count->id; + unsigned long irqflags; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); if (priv->quadrature_mode[id]) switch (priv->quadrature_scale[id]) { @@ -218,7 +223,7 @@ static int quad8_function_read(struct counter_device *counter, else *function = COUNTER_FUNCTION_PULSE_DIRECTION; - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -233,10 +238,11 @@ static int quad8_function_write(struct counter_device *counter, unsigned int *const scale = priv->quadrature_scale + id; unsigned int *const synchronous_mode = priv->synchronous_mode + id; const int base_offset = priv->base + 2 * id + 1; + unsigned long irqflags; unsigned int mode_cfg; unsigned int idr_cfg; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); mode_cfg = priv->count_mode[id] << 1; idr_cfg = priv->index_polarity[id] << 1; @@ -271,7 +277,7 @@ static int quad8_function_write(struct counter_device *counter, break; default: /* should never reach this path */ - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return -EINVAL; } } @@ -279,7 +285,7 @@ static int quad8_function_write(struct counter_device *counter, /* Load mode configuration to Counter Mode Register */ outb(QUAD8_CTR_CMR | mode_cfg, base_offset); - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -405,9 +411,10 @@ static int quad8_index_polarity_set(struct counter_device *counter, struct quad8 *const priv = counter->priv; const size_t channel_id = signal->id - 16; const int base_offset = priv->base + 2 * channel_id + 1; + unsigned long irqflags; unsigned int idr_cfg = index_polarity << 1; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); idr_cfg |= priv->synchronous_mode[channel_id]; @@ -416,7 +423,7 @@ static int quad8_index_polarity_set(struct counter_device *counter, /* Load Index Control configuration to Index Control Register */ outb(QUAD8_CTR_IDR | idr_cfg, base_offset); - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -445,15 +452,16 @@ static int quad8_synchronous_mode_set(struct counter_device *counter, struct quad8 *const priv = counter->priv; const size_t channel_id = signal->id - 16; const int base_offset = priv->base + 2 * channel_id + 1; + unsigned long irqflags; unsigned int idr_cfg = synchronous_mode; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); idr_cfg |= priv->index_polarity[channel_id] << 1; /* Index function must be non-synchronous in non-quadrature mode */ if (synchronous_mode && !priv->quadrature_mode[channel_id]) { - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return -EINVAL; } @@ -462,7 +470,7 @@ static int quad8_synchronous_mode_set(struct counter_device *counter, /* Load Index Control configuration to Index Control Register */ outb(QUAD8_CTR_IDR | idr_cfg, base_offset); - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -509,6 +517,7 @@ static int quad8_count_mode_write(struct counter_device *counter, unsigned int count_mode; unsigned int mode_cfg; const int base_offset = priv->base + 2 * count->id + 1; + unsigned long irqflags; /* Map Generic Counter count mode to 104-QUAD-8 count mode */ switch (cnt_mode) { @@ -529,7 +538,7 @@ static int quad8_count_mode_write(struct counter_device *counter, return -EINVAL; } - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); priv->count_mode[count->id] = count_mode; @@ -543,7 +552,7 @@ static int quad8_count_mode_write(struct counter_device *counter, /* Load mode configuration to Counter Mode Register */ outb(QUAD8_CTR_CMR | mode_cfg, base_offset); - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -563,9 +572,10 @@ static int quad8_count_enable_write(struct counter_device *counter, { struct quad8 *const priv = counter->priv; const int base_offset = priv->base + 2 * count->id; + unsigned long irqflags; unsigned int ior_cfg; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); priv->ab_enable[count->id] = enable; @@ -574,7 +584,7 @@ static int quad8_count_enable_write(struct counter_device *counter, /* Load I/O control configuration */ outb(QUAD8_CTR_IOR | ior_cfg, base_offset + 1); - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -625,16 +635,17 @@ static int quad8_count_preset_write(struct counter_device *counter, struct counter_count *count, u64 preset) { struct quad8 *const priv = counter->priv; + unsigned long irqflags; /* Only 24-bit values are supported */ if (preset > 0xFFFFFF) return -ERANGE; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); quad8_preset_register_set(priv, count->id, preset); - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -643,8 +654,9 @@ static int quad8_count_ceiling_read(struct counter_device *counter, struct counter_count *count, u64 *ceiling) { struct quad8 *const priv = counter->priv; + unsigned long irqflags; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); /* Range Limit and Modulo-N count modes use preset value as ceiling */ switch (priv->count_mode[count->id]) { @@ -658,7 +670,7 @@ static int quad8_count_ceiling_read(struct counter_device *counter, break; } - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -667,23 +679,24 @@ static int quad8_count_ceiling_write(struct counter_device *counter, struct counter_count *count, u64 ceiling) { struct quad8 *const priv = counter->priv; + unsigned long irqflags; /* Only 24-bit values are supported */ if (ceiling > 0xFFFFFF) return -ERANGE; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); /* Range Limit and Modulo-N count modes use preset value as ceiling */ switch (priv->count_mode[count->id]) { case 1: case 3: - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); quad8_preset_register_set(priv, count->id, ceiling); return 0; } - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return -EINVAL; } @@ -705,12 +718,13 @@ static int quad8_count_preset_enable_write(struct counter_device *counter, { struct quad8 *const priv = counter->priv; const int base_offset = priv->base + 2 * count->id + 1; + unsigned long irqflags; unsigned int ior_cfg; /* Preset enable is active low in Input/Output Control register */ preset_enable = !preset_enable; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); priv->preset_enable[count->id] = preset_enable; @@ -719,7 +733,7 @@ static int quad8_count_preset_enable_write(struct counter_device *counter, /* Load I/O control configuration to Input / Output Control Register */ outb(QUAD8_CTR_IOR | ior_cfg, base_offset); - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -730,22 +744,23 @@ static int quad8_signal_cable_fault_read(struct counter_device *counter, { struct quad8 *const priv = counter->priv; const size_t channel_id = signal->id / 2; + unsigned long irqflags; bool disabled; unsigned int status; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); disabled = !(priv->cable_fault_enable & BIT(channel_id)); if (disabled) { - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return -EINVAL; } /* Logic 0 = cable fault */ status = inb(priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); /* Mask respective channel and invert logic */ *cable_fault = !(status & BIT(channel_id)); @@ -771,9 +786,10 @@ static int quad8_signal_cable_fault_enable_write(struct counter_device *counter, { struct quad8 *const priv = counter->priv; const size_t channel_id = signal->id / 2; + unsigned long irqflags; unsigned int cable_fault_enable; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); if (enable) priv->cable_fault_enable |= BIT(channel_id); @@ -785,7 +801,7 @@ static int quad8_signal_cable_fault_enable_write(struct counter_device *counter, outb(cable_fault_enable, priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS); - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -808,8 +824,9 @@ static int quad8_signal_fck_prescaler_write(struct counter_device *counter, struct quad8 *const priv = counter->priv; const size_t channel_id = signal->id / 2; const int base_offset = priv->base + 2 * channel_id; + unsigned long irqflags; - mutex_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, irqflags); priv->fck_prescaler[channel_id] = prescaler; @@ -821,7 +838,7 @@ static int quad8_signal_fck_prescaler_write(struct counter_device *counter, outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC, base_offset + 1); - mutex_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, irqflags); return 0; } @@ -990,8 +1007,7 @@ static int quad8_probe(struct device *dev, unsigned int id) priv->counter.priv = priv; priv->base = base[id]; - /* Initialize mutex */ - mutex_init(&priv->lock); + spin_lock_init(&priv->lock); /* Reset all counters and disable interrupt function */ outb(QUAD8_CHAN_OP_RESET_COUNTERS, base[id] + QUAD8_REG_CHAN_OP); From patchwork Tue Mar 9 13:19:46 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: 12125213 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 E17E9C433E0 for ; Tue, 9 Mar 2021 13:24:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FE7365244 for ; Tue, 9 Mar 2021 13:24:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231235AbhCINXe (ORCPT ); Tue, 9 Mar 2021 08:23:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231479AbhCINXF (ORCPT ); Tue, 9 Mar 2021 08:23:05 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9FA9C06174A; Tue, 9 Mar 2021 05:23:04 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id n9so7798620pgi.7; Tue, 09 Mar 2021 05:23:04 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=oWakiYpT0xXwfQsuTaJUoNlRwTEXD7Xbq7I9eeif91U=; b=p3/lhCup3JrB82x9/r4b91kWwLaLM+bP6/fUMzJzikNQO2K+Krcp1ogH4iRF9BD1wr KFNHjvax37//Jv8yzcRgTe9M1VWJA9RyIp1KlczKp8Wd4vzb+OlIeUMDPoiuZvvcDGiP PG34qtcb2dvTLlN6UHj0W5H8J/gU4M+i3plTn/949Rg88HWtIToQ4P6nv2xkG7KB9tWm PdJXrxYJdnGl8cI5qaUZEznl8+ypVD2zO5fjxCGcG3hrNlZmCjv+Rzr+wUSMcloEQpNu Qh7cyX0tj5dF8NN+VQ5jqrp0mkNU7VrBamLO9uClVHtRdePj1chkyL2XDaPa8UxRJPcb gczg== 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:mime-version:content-transfer-encoding; bh=oWakiYpT0xXwfQsuTaJUoNlRwTEXD7Xbq7I9eeif91U=; b=tO1rbtOb240JxPTZoF0Ju8nFmEcNbhA3xlbZU49ib4x0xR8AmZhblZc+3cEaq7I39Q eFk6S9VML2vUbhrmBQULe8HEh1VxZsL2LxD7qbEGp8+ArqapuW5xtJDOOr8Pm0kp5x/U jAnfdyCCI0bhASKSIBuQX8TH8RcEadUJZ39Y0CaG2YrjfvpIGigZMocs38T+UCyjVo3Q m8a6e0GOAAHWUwzaqlRPQ7WrBhCIeT/JNFZU26ZHLD+/20NodLMiSrHxRnbkIhjl+6la pnHBwLePcZZljjU+r1f2LLBHjAUQxoYIDtUvZGJ/K2Apn5NJZbvoxwccToVzBmV/4C72 /C3A== X-Gm-Message-State: AOAM53031p9VNcATbol9jTgPrvYdrTOkOxp2SO5OlXpODZPBV7VHCT6Z 0qLDUU9/+rHeS3cJvQ5MY9c= X-Google-Smtp-Source: ABdhPJzw5PB3n1upDXlO100EBSOSc4gH/Xl+cMUBNjlNOtjplbVGNWtl8FRYVugkBvoEfbNx3jg32A== X-Received: by 2002:a62:7708:0:b029:1ee:f656:51d5 with SMTP id s8-20020a6277080000b02901eef65651d5mr26195025pfc.59.1615296184322; Tue, 09 Mar 2021 05:23:04 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:23:03 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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, William Breathitt Gray Subject: [PATCH v9 33/33] counter: 104-quad-8: Add IRQ support for the ACCES 104-QUAD-8 Date: Tue, 9 Mar 2021 22:19:46 +0900 Message-Id: <2368417d253917b7a2c3e0e952dd6e4fa3815e8e.1615293276.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The LSI/CSI LS7266R1 chip provides programmable output via the FLG pins. When interrupts are enabled on the ACCES 104-QUAD-8, they occur whenever FLG1 is active. Four functions are available for the FLG1 signal: Carry, Compare, Carry-Borrow, and Index. Carry: Interrupt generated on active low Carry signal. Carry signal toggles every time the respective channel's counter overflows. Compare: Interrupt generated on active low Compare signal. Compare signal toggles every time respective channel's preset register is equal to the respective channel's counter. Carry-Borrow: Interrupt generated on active low Carry signal and active low Borrow signal. Carry signal toggles every time the respective channel's counter overflows. Borrow signal toggles every time the respective channel's counter underflows. Index: Interrupt generated on active high Index signal. These four functions correspond respectivefly to the following four Counter event types: COUNTER_EVENT_OVERFLOW, COUNTER_EVENT_THRESHOLD, COUNTER_EVENT_OVERFLOW_UNDERFLOW, and COUNTER_EVENT_INDEX. Interrupts push Counter events to event channel X, where 'X' is the respective channel whose FLG1 activated. This patch adds IRQ support for the ACCES 104-QUAD-8. The interrupt line numbers for the devices may be configured via the irq array module parameter. Cc: Syed Nayyar Waris Signed-off-by: William Breathitt Gray --- drivers/counter/104-quad-8.c | 167 +++++++++++++++++++++++++++++++++-- drivers/counter/Kconfig | 6 +- 2 files changed, 164 insertions(+), 9 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index d46b8101f207..09b0b0ba8fe7 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,10 @@ static unsigned int num_quad8; module_param_hw_array(base, uint, ioport, &num_quad8, 0); MODULE_PARM_DESC(base, "ACCES 104-QUAD-8 base addresses"); +static unsigned int irq[max_num_isa_dev(QUAD8_EXTENT)]; +module_param_hw_array(irq, uint, irq, NULL, 0); +MODULE_PARM_DESC(irq, "ACCES 104-QUAD-8 interrupt line numbers"); + #define QUAD8_NUM_COUNTERS 8 /** @@ -38,6 +43,8 @@ MODULE_PARM_DESC(base, "ACCES 104-QUAD-8 base addresses"); * @quadrature_scale: array of quadrature mode scale configurations * @ab_enable: array of A and B inputs enable configurations * @preset_enable: array of set_to_preset_on_index attribute configurations + * @irq_trigger: array of current IRQ trigger function configurations + * @next_irq_trigger: array of next IRQ trigger function configurations * @synchronous_mode: array of index function synchronous mode configurations * @index_polarity: array of index function polarity configurations * @cable_fault_enable: differential encoder cable status enable configurations @@ -53,13 +60,17 @@ struct quad8 { unsigned int quadrature_scale[QUAD8_NUM_COUNTERS]; unsigned int ab_enable[QUAD8_NUM_COUNTERS]; unsigned int preset_enable[QUAD8_NUM_COUNTERS]; + unsigned int irq_trigger[QUAD8_NUM_COUNTERS]; + unsigned int next_irq_trigger[QUAD8_NUM_COUNTERS]; unsigned int synchronous_mode[QUAD8_NUM_COUNTERS]; unsigned int index_polarity[QUAD8_NUM_COUNTERS]; unsigned int cable_fault_enable; unsigned int base; }; +#define QUAD8_REG_INTERRUPT_STATUS 0x10 #define QUAD8_REG_CHAN_OP 0x11 +#define QUAD8_REG_INDEX_INTERRUPT 0x12 #define QUAD8_REG_INDEX_INPUT_LEVELS 0x16 #define QUAD8_DIFF_ENCODER_CABLE_STATUS 0x17 /* Borrow Toggle flip-flop */ @@ -92,8 +103,8 @@ struct quad8 { #define QUAD8_RLD_CNTR_OUT 0x10 /* Transfer Preset Register LSB to FCK Prescaler */ #define QUAD8_RLD_PRESET_PSC 0x18 -#define QUAD8_CHAN_OP_ENABLE_COUNTERS 0x00 #define QUAD8_CHAN_OP_RESET_COUNTERS 0x01 +#define QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC 0x04 #define QUAD8_CMR_QUADRATURE_X1 0x08 #define QUAD8_CMR_QUADRATURE_X2 0x10 #define QUAD8_CMR_QUADRATURE_X4 0x18 @@ -378,13 +389,103 @@ static int quad8_action_read(struct counter_device *counter, } } +enum { + QUAD8_EVENT_NONE = -1, + QUAD8_EVENT_CARRY = 0, + QUAD8_EVENT_COMPARE = 1, + QUAD8_EVENT_CARRY_BORROW = 2, + QUAD8_EVENT_INDEX = 3, +}; + +static int quad8_events_configure(struct counter_device *counter) +{ + struct quad8 *const priv = counter->priv; + unsigned long irq_enabled = 0; + unsigned long irqflags; + size_t channel; + unsigned long ior_cfg; + unsigned long base_offset; + + spin_lock_irqsave(&priv->lock, irqflags); + + /* Enable interrupts for the requested channels, disable for the rest */ + for (channel = 0; channel < QUAD8_NUM_COUNTERS; channel++) { + if (priv->next_irq_trigger[channel] == QUAD8_EVENT_NONE) + continue; + + if (priv->irq_trigger[channel] != priv->next_irq_trigger[channel]) { + /* Save new IRQ function configuration */ + priv->irq_trigger[channel] = priv->next_irq_trigger[channel]; + + /* Load configuration to I/O Control Register */ + ior_cfg = priv->ab_enable[channel] | + priv->preset_enable[channel] << 1 | + priv->irq_trigger[channel] << 3; + base_offset = priv->base + 2 * channel + 1; + outb(QUAD8_CTR_IOR | ior_cfg, base_offset); + } + + /* Reset next IRQ trigger function configuration */ + priv->next_irq_trigger[channel] = QUAD8_EVENT_NONE; + + /* Enable IRQ line */ + irq_enabled |= BIT(channel); + } + + outb(irq_enabled, priv->base + QUAD8_REG_INDEX_INTERRUPT); + + spin_unlock_irqrestore(&priv->lock, irqflags); + + return 0; +} + +static int quad8_watch_validate(struct counter_device *counter, + const struct counter_watch *watch) +{ + struct quad8 *const priv = counter->priv; + + if (watch->channel > QUAD8_NUM_COUNTERS - 1) + return -EINVAL; + + switch (watch->event) { + case COUNTER_EVENT_OVERFLOW: + if (priv->next_irq_trigger[watch->channel] == QUAD8_EVENT_NONE) + priv->next_irq_trigger[watch->channel] = QUAD8_EVENT_CARRY; + else if (priv->next_irq_trigger[watch->channel] != QUAD8_EVENT_CARRY) + return -EINVAL; + return 0; + case COUNTER_EVENT_THRESHOLD: + if (priv->next_irq_trigger[watch->channel] == QUAD8_EVENT_NONE) + priv->next_irq_trigger[watch->channel] = QUAD8_EVENT_COMPARE; + else if (priv->next_irq_trigger[watch->channel] != QUAD8_EVENT_COMPARE) + return -EINVAL; + return 0; + case COUNTER_EVENT_OVERFLOW_UNDERFLOW: + if (priv->next_irq_trigger[watch->channel] == QUAD8_EVENT_NONE) + priv->next_irq_trigger[watch->channel] = QUAD8_EVENT_CARRY_BORROW; + else if (priv->next_irq_trigger[watch->channel] != QUAD8_EVENT_CARRY_BORROW) + return -EINVAL; + return 0; + case COUNTER_EVENT_INDEX: + if (priv->next_irq_trigger[watch->channel] == QUAD8_EVENT_NONE) + priv->next_irq_trigger[watch->channel] = QUAD8_EVENT_INDEX; + else if (priv->next_irq_trigger[watch->channel] != QUAD8_EVENT_INDEX) + return -EINVAL; + return 0; + default: + return -EINVAL; + } +} + static const struct counter_ops quad8_ops = { .signal_read = quad8_signal_read, .count_read = quad8_count_read, .count_write = quad8_count_write, .function_read = quad8_function_read, .function_write = quad8_function_write, - .action_read = quad8_action_read + .action_read = quad8_action_read, + .events_configure = quad8_events_configure, + .watch_validate = quad8_watch_validate, }; static const char *const quad8_index_polarity_modes[] = { @@ -579,7 +680,8 @@ static int quad8_count_enable_write(struct counter_device *counter, priv->ab_enable[count->id] = enable; - ior_cfg = enable | priv->preset_enable[count->id] << 1; + ior_cfg = enable | priv->preset_enable[count->id] << 1 | + priv->irq_trigger[count->id] << 3; /* Load I/O control configuration */ outb(QUAD8_CTR_IOR | ior_cfg, base_offset + 1); @@ -728,7 +830,8 @@ static int quad8_count_preset_enable_write(struct counter_device *counter, priv->preset_enable[count->id] = preset_enable; - ior_cfg = priv->ab_enable[count->id] | preset_enable << 1; + ior_cfg = priv->ab_enable[count->id] | preset_enable << 1 | + priv->irq_trigger[count->id] << 3; /* Load I/O control configuration to Input / Output Control Register */ outb(QUAD8_CTR_IOR | ior_cfg, base_offset); @@ -980,11 +1083,54 @@ static struct counter_count quad8_counts[] = { QUAD8_COUNT(7, "Channel 8 Count") }; +static irqreturn_t quad8_irq_handler(int irq, void *private) +{ + struct quad8 *const priv = private; + const unsigned long base = priv->base; + unsigned long irq_status; + unsigned long channel; + u8 event; + + irq_status = inb(base + QUAD8_REG_INTERRUPT_STATUS); + if (!irq_status) + return IRQ_NONE; + + for_each_set_bit(channel, &irq_status, QUAD8_NUM_COUNTERS) { + switch (priv->irq_trigger[channel]) { + case QUAD8_EVENT_CARRY: + event = COUNTER_EVENT_OVERFLOW; + break; + case QUAD8_EVENT_COMPARE: + event = COUNTER_EVENT_THRESHOLD; + break; + case QUAD8_EVENT_CARRY_BORROW: + event = COUNTER_EVENT_OVERFLOW_UNDERFLOW; + break; + case QUAD8_EVENT_INDEX: + event = COUNTER_EVENT_INDEX; + break; + default: + /* should never reach this path */ + WARN_ONCE(true, "invalid interrupt trigger function %u configured for channel %lu\n", + priv->irq_trigger[channel], channel); + continue; + } + + counter_push_event(&priv->counter, event, channel); + } + + /* Clear pending interrupts on device */ + outb(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, base + QUAD8_REG_CHAN_OP); + + return IRQ_HANDLED; +} + static int quad8_probe(struct device *dev, unsigned int id) { struct quad8 *priv; int i, j; unsigned int base_offset; + int err; if (!devm_request_region(dev, base[id], QUAD8_EXTENT, dev_name(dev))) { dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", @@ -1009,6 +1155,8 @@ static int quad8_probe(struct device *dev, unsigned int id) spin_lock_init(&priv->lock); + /* Reset Index/Interrupt Register */ + outb(0x00, base[id] + QUAD8_REG_INDEX_INTERRUPT); /* Reset all counters and disable interrupt function */ outb(QUAD8_CHAN_OP_RESET_COUNTERS, base[id] + QUAD8_REG_CHAN_OP); /* Set initial configuration for all counters */ @@ -1035,11 +1183,18 @@ static int quad8_probe(struct device *dev, unsigned int id) outb(QUAD8_CTR_IOR, base_offset + 1); /* Disable index function; negative index polarity */ outb(QUAD8_CTR_IDR, base_offset + 1); + /* Initialize next IRQ trigger function configuration */ + priv->next_irq_trigger[i] = QUAD8_EVENT_NONE; } /* Disable Differential Encoder Cable Status for all channels */ outb(0xFF, base[id] + QUAD8_DIFF_ENCODER_CABLE_STATUS); - /* Enable all counters */ - outb(QUAD8_CHAN_OP_ENABLE_COUNTERS, base[id] + QUAD8_REG_CHAN_OP); + /* Enable all counters and enable interrupt function */ + outb(QUAD8_CHAN_OP_ENABLE_INTERRUPT_FUNC, base[id] + QUAD8_REG_CHAN_OP); + + err = devm_request_irq(dev, irq[id], quad8_irq_handler, IRQF_SHARED, + priv->counter.name, priv); + if (err) + return err; return devm_counter_register(dev, &priv->counter); } diff --git a/drivers/counter/Kconfig b/drivers/counter/Kconfig index 5328705aa09c..2c2862dd46a5 100644 --- a/drivers/counter/Kconfig +++ b/drivers/counter/Kconfig @@ -23,11 +23,11 @@ config 104_QUAD_8 A counter's respective error flag may be cleared by performing a write operation on the respective count value attribute. Although the 104-QUAD-8 counters have a 25-bit range, only the lower 24 bits may be - set, either directly or via the counter's preset attribute. Interrupts - are not supported by this driver. + set, either directly or via the counter's preset attribute. The base port addresses for the devices may be configured via the base - array module parameter. + array module parameter. The interrupt line numbers for the devices may + be configured via the irq array module parameter. config INTERRUPT_CNT tristate "Interrupt counter driver"