From patchwork Fri Mar 19 11:00: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: 12150707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B85D2C433E6 for ; Fri, 19 Mar 2021 11:03:02 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2989464F69 for ; Fri, 19 Mar 2021 11:03:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2989464F69 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SQ8eZfyltByzrgcwsndNw0CU4McK02x/KLR8KXrXJDA=; b=TMlEsS4W8hBdDLfVf0AfTTVHc FONFr8lLSNMErbaJ0WqMCiehUwEPJkLjxXxjtKrt10prIrcji+3HhemFZM5AstrqcMzGnI4EM9Kit Zp9PVm3UPLFtMSNdELQ9J85yYOA67iVTVwDD866ahJWU7nRtsS+9KoB0+1x5l3ZeLOF4iH6EyCkNA 0mLH/eKEJUqR5wkMhgtdUKkRPuykQ1OdAtnGP7rflgbH9PCPaMTPGNdWxOzZQnFsoLQiq7euwUqtb MsNYk32k1A3UPBWPpFEsgVqDkW5saGv4hthfYCq6162gSdNhPK8mnvlf6f6SscYXFUPDWtS1rboXh IWjSkZhSQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCsW-007DGe-1M; Fri, 19 Mar 2021 11:01:17 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCsQ-007DFy-L0 for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:01:13 +0000 Received: by mail-pj1-x102f.google.com with SMTP id w8so4470297pjf.4 for ; Fri, 19 Mar 2021 04:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PqzGrUSHT2ODyc7JfjhfJrg9zplZK53Sny3wqrHE5Ek=; b=K/r/iTS/rRQFOSe8TdGfMXsdwK4GbGqFZpC6nQswW7ZOReIMo+qq2YMltfcUpTynIA bZhq07ygkFSkI6JvyePDNkpZbJX39hqrwrDtTExcjAHSQ3gDRFR4+K/oahrj/4reVDgR hTHHG/cVp25HO9OidHZPrZ9tU+OT9ToZWfz8Eb+Nvkd2slxt0hUVaAhWiritdT34y3rZ CWVl2ElXgav9a3HlCXKTgFDDYGD8/tnVXM1QD4iGaLEeILu+RrVHm42apjHXfcG1c5NC 0CR2sU52nQbYFG0F5JfvDMD/D7td8+t6RDU7MD5tyNGF/0NKrDRLDcV4G17fbXMv/CL2 g4dQ== 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=PqzGrUSHT2ODyc7JfjhfJrg9zplZK53Sny3wqrHE5Ek=; b=qu2ljeHiyHCgoEE/VGWtQ1tAcxN6wLDA3GO5Drdb0JHbycmoqkS+8T0tym/Tqzf3oz HNvBgsLQzurzjFGPgq8pWORlHBWObjFPdTqrkBbwVREunmtTRxStgtaZA+HvznZQmHdP PBACf+pBWgDd98li1rIUeRX5tss1UwNm+XgA4ISBocP9qOSaGujM0Sf/HnsSYXn5xjfq hqQF/2PFiAzuggSf+3haDHoUeq9CwLepfvNNWlElFbzdop4taD2vS1KUneDCAVLQC4tf XskKY0oIio2ez/+htFn0S92Td3tVDQ090wcHoAv6FWpw1KCITZ2Y95wEiGBv2/vBob5A BC6Q== X-Gm-Message-State: AOAM532YBlXK/aF3sEgymPmvI5PxtaxnNpWC2Tsz+mhKVOQUHaNpOzn0 YhM4hxj4R+BkxlPpcDumDWg= X-Google-Smtp-Source: ABdhPJxSPzwwwWvvlYz9H06c9bqwy0JIeXaHfcKYZ3niakgV/iHn3Cyw3BtXdgQ+ShT1h+CUBqkuUQ== X-Received: by 2002:a17:902:8c8d:b029:e5:e1fc:a587 with SMTP id t13-20020a1709028c8db02900e5e1fca587mr14078217plo.12.1616151669181; Fri, 19 Mar 2021 04:01:09 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:01:08 -0700 (PDT) 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 v10 01/33] docs: counter: Consolidate Counter sysfs attributes documentation Date: Fri, 19 Mar 2021 20:00:20 +0900 Message-Id: <50707642485aee45d6410a2dbd3e0b7ae420993b.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110111_247411_07B4864F X-CRM114-Status: GOOD ( 17.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Mar 19 11:00: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: 12150709 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_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 3F173C433E0 for ; Fri, 19 Mar 2021 11:03:04 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BFD1F64F04 for ; Fri, 19 Mar 2021 11:03:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFD1F64F04 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rbMm/N8XRG7mrN/2kaqR3jWyiGV/lXhPwEmgn67RGZw=; b=E6s1qQCAy1NIfaOEzGNYJixjV 964Mh0enypLv28g7nc0HP8+OELIpjtGhFmKsWkIkUDOFlp6FGEg12idmWOEOuJ+wwA8R5joUFsRwv z1XZpM/xkPkV/HYyonMNe3sjFGRS6pxn9pftOL1WxlkUVUEZGGYO0JVIFVT1vvzDHiLB/Ej+iZm16 p/vX4nIknBLZeKBEXaSMI4Vjhhhxn4SfmrZ7JY4Wyf+oJHQqJU71Kl2mZh3EiuDRGxwgFcsD3aRZi FsVRqW0md5bcnH/0Lybv8F4ylHJkEwk25DRh9PBw1eieY9vJ3CNr85bVDAZd3xTKlf1wx5sLNNT85 dCx6rSZ4A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCsn-007DIy-Id; Fri, 19 Mar 2021 11:01:33 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCsV-007DGd-DA for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:01:18 +0000 Received: by mail-pj1-x1031.google.com with SMTP id lr1-20020a17090b4b81b02900ea0a3f38c1so8316698pjb.0 for ; Fri, 19 Mar 2021 04:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zNHAzRgGiY7J7G+f8mmaWum3SKthte+B3myyLZXUAyY=; b=s02yFLPcTuICIO7+C+BcSoFLEftjPfweIg/sH113MKfHNgrEzsrKNyvl57Zx991Zns JffwM12TkhbgTzson9zRHyQKSGthzQpmLJz0PhC4zULJ97p280R246dAdVyjXaP1GQpH myWBIk8K5T5IokWp6IkefEMjawq3mX0O4OLv9V+JMno5CAcq4OMqyN2yUv4vlfl+nM+8 gIhsxUtpY+0keiQMZfN9UbuZ3M4rxMxHRO7GAgdR0YmL9HY8gE9fXpS0pS8MvKmeq8D7 rEAZT8Sw2YGQpUOcD63K+9pmeblQ7IIlwDkPM1URLEws02FJ+IW4lg73xbj9MWPrZ+Ag vnCQ== 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=zNHAzRgGiY7J7G+f8mmaWum3SKthte+B3myyLZXUAyY=; b=ek7nzf49MzYM2Z0fTa1o/nKYLNwXZGf3AGBsmRaCpDiJHcDNyp+k6dCFH6nRiAb/+2 P1iRBlkTYU6Y7QIyIODg+7DCNHyv3x+iC6K1fkXfqBqq1hQ9z6P7hwqknEgtujRC2c3l kfz6WrcIqN5tttmA+Imh4ZNwUOejNzVa4GDKJAv+DHAHg6XabjVS4PmKmPkeIaRbkRhI jz/K/ay5rPq03cG8MtyOJ9gwbwbk5Z1ETnav3MjIM5yLlj0z9Vz3BKBgwZ14RyuCVNe0 /Mft5KbmiIme6P8bwCCOC3WkXjeVd6IrVBbp08R/oSzj0kCiILv8EU0XFDk3auoKpn+k lS7Q== X-Gm-Message-State: AOAM530qZ7OmTRTHfPLX2tUYbqvnMS3qewD0xvKKc+3rlvrcPs7N1Ujw p9xAIYziGjE1Oxhzf4vWj/c= X-Google-Smtp-Source: ABdhPJwcq2BYLCh/FKajfLUwOFiyLFNcNr3jYX5SAAIA1CUfh2Eckv5FIvqSO9atPlmB9lma39Ql3Q== X-Received: by 2002:a17:902:b78a:b029:e4:8ce6:fb64 with SMTP id e10-20020a170902b78ab02900e48ce6fb64mr14236203pls.77.1616151674053; Fri, 19 Mar 2021 04:01:14 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:01:13 -0700 (PDT) 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 v10 02/33] docs: counter: Fix spelling Date: Fri, 19 Mar 2021 20:00:21 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110115_626698_13512B2C X-CRM114-Status: GOOD ( 12.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org "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 Fri Mar 19 11:00: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: 12150713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 68EB9C433E9 for ; Fri, 19 Mar 2021 11:03:06 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E7E3464F04 for ; Fri, 19 Mar 2021 11:03:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7E3464F04 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=47N9mIBAnzipDRmfI2gSbHie0wV4+8Y9OSjEuwMxPWk=; b=eMYidrvMIMq1xnUG4Qkr1yNzV JoNVio8LO9yUk/qUhSCAWG6NYEPiEdnnyV3+lLRgVOPhCAPvd+A7lth7+N8oKl1CuwkSWg6w4WhYN vducNclVo6ar0QeLCHbn4rJW6ON+r826w9AO2CGtloipbCEti8L84UjnPC8F2wJ9NhkKIUyFdtSUw S64AWj+Af+D5p8BmNFtcN9C4eJ/rvfS4BSV7zumPQBmnEKV/nLx7AORtrHH1HFmoXvpsqIZ/zcigb yxjXlXVHQeXjCNn/U8EZSFtJy/Yirc2GJLN1ZEAYSuB55wntD08Zz0OuxQIW/lZl0M4kE4377hA4+ ZiDH8TvIg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCsu-007DK4-V8; Fri, 19 Mar 2021 11:01:41 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCsa-007DHH-BX for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:01:22 +0000 Received: by mail-pl1-x633.google.com with SMTP id t20so2783464plr.13 for ; Fri, 19 Mar 2021 04:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YP6Y0iUlFGoxnb33nwnYEvQ4ZjRZgtWw9rrllhcAce8=; b=EfPTCnysQ2SO1zX7Yo4KRrKJd4T+NRxlDLzkn+xhVOtwG47MHAVbglbAXMQq/g7KTj e0ZUMRJrpemIZQRhRm4QevibXClI5xo33QBIsockGMprJ3UbtUz+b4lc2KcT2+bZserS IcUG/2q9s3Li/oSPW8Hha6ySTnMhg+/QIf0/mUIlYvT9NC15hMP9ZjenhUVJqenSXovu ZLj42xDF/jYkNMRWhGg+DD/QohSNPL4RKiEpMDMOh4wTaoBe6l05fEZ5ERgEMWnxjwrP FkEguiXLcwijo8aOSae1VgrxLrNyEKZkSumeOOEAK6CCH6+UHtFUul4dHZ17IUg+6gjB Vwzg== 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=YP6Y0iUlFGoxnb33nwnYEvQ4ZjRZgtWw9rrllhcAce8=; b=FNJ9OULghsntBYEi4SpHPEzJL/pLOpjdQU5Yf6Er7rflC+TcIi6Yz0s1BjQFyFM4xR sFDMGlg6BA8Vez6C9c2n2llIlOqRMx+LwcfI/sqbAxoF1qzPXTeXEpMuSQ3Z67nldBlS yFR8AFFCr6opIvjI4wum8Ygv7rf4JHUEAsGHvxXNZBLdNRnxoZmg/L3Gx0+oWNi98fUH b29Kb3qgbDsfu5sIEFSGGS2h1F27vuR8f/EgustmjkGWnbe784pfYd/IJDzXnScCiQWi ntJQWLKtGaYZux7pJQZc+Ldg0RPnCK97CQzRMxXJEC2RTwX8EZppOrJWlyIT/i02zCyC kRYA== X-Gm-Message-State: AOAM530XFbktntu6r1IozzNyx7Hx4mb9wViPzxpBUR+NIUXISGkB5iWr BSWUl8KuDlGMf3ZRvlt1WYM= X-Google-Smtp-Source: ABdhPJwEkXVpf7bCTq0t4YWhofrnRE9O3kVRUx9pwa8eP8pu6QtVdUaaJgXFqGgmXc7XvdKM4+CfGQ== X-Received: by 2002:a17:90b:344c:: with SMTP id lj12mr9432230pjb.208.1616151678943; Fri, 19 Mar 2021 04:01:18 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.01.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:01:18 -0700 (PDT) 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 v10 03/33] counter: 104-quad-8: Remove pointless comment Date: Fri, 19 Mar 2021 20:00:22 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110120_490363_8A8279E9 X-CRM114-Status: GOOD ( 11.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Acked-by: Syed Nayyar Waris --- 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 Fri Mar 19 11:00: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: 12150715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_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 95130C433E0 for ; Fri, 19 Mar 2021 11:03:19 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 24FA264F04 for ; Fri, 19 Mar 2021 11:03:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24FA264F04 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Utzz5uW1aM3T3iJsM4VgJah2XPnVmpwpzQ64rNbIADQ=; b=a1ZLiQQ1cWK4vBlrbH3ZfdEVJ LhM9hcs8jQDW3Wwy4P8iWm0ABA2ZVK8DGoZkWWduBs3sfqzMjazc1xLHmbJHoEr4DuHHxoPDPQ/So 52STN/YiHYURAjSGFQ0R241Q7hwyKAWv/5d5Rm6VzUByb41y+fmtgkCX3sGRhob/FGiwVufXR5tUI FvQrUswAkrMvmg0KYybMrgZnDPlpg7S/t2b1L8OPhY8sLWYUr5MRS1BRWdr6IUTxGRRe4J85RJwRO s9bs9X0aW7dM6MXNrz4IWAe69itME9Kw3wwVUt9xI3m1L7yaQ3azQIGhGn3SO7G9w7CpTYBruZomH TCenU4xcw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCt4-007DMB-Sj; Fri, 19 Mar 2021 11:01:51 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCsf-007DHt-62 for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:01:27 +0000 Received: by mail-pf1-x435.google.com with SMTP id l123so5631874pfl.8 for ; Fri, 19 Mar 2021 04:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1TpNtbXoxyIjRd7QIp1WNUGV3OlR+l0VzEx11bA72Sw=; b=bGsyS/ntHB5J/zGOzWa3dDyJ+RSrk0AxzcTTabPa/qWzSF3DAQkcBBYPCERu5rU5/L /Tpp7DtV9HaJHtMyRTwa9QF+cO1KFylnYYX0zCk3n0pCx8jDthkoiATd01qRCQl32SoJ rBFrtroMaqCCnK8fAh1FJhtZhtwxb5AdtpztX4O3YecnWYidtuMs+j3td9/dI1tAXP6l YEfWvLnIbxnmsj2t9dvTXyh//iJksnwS3T0AcYJcLvo+ZZziwXXeqaEOjXRlP28GXWMB qztwaapx0RSzcWGJBFDxMY5J3IDt3c1QgW459KejscA78lWdxtZxgJGXLYOXKCnTxLCI nYrA== 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=1TpNtbXoxyIjRd7QIp1WNUGV3OlR+l0VzEx11bA72Sw=; b=a1piSf8EjfqsBo1rGvuFlioz+Vz7GE0tR6PRx01LReP3xC77hfe4ug1ohA/dcab/C0 HCGi8HMUD9r95bXEjIHIpdnyH79Dg8q5+M6TJk7PFrWfPdSPv+BU6Qsz2Yx7IYn2ZskV 7IXi8UuPUQzpghV9jryEQg4oc8WFm4X6H2Gti1fg2zX/s1pj968FvoRJ4AH7VaVdhk8Y dNl0qtIMklgVyo6/lUAIGyCWuuDiXocBSLabdfXCXf34o3mKfXhdYicLS3CI86AAO9bD PWRbtbo1yapvMsA9RyBmT4M6BF/43D6DxLKJLeFTR81lbccCql7Nq16pqbBzWCkSkEWd JPQQ== X-Gm-Message-State: AOAM530e38NcesDrWAexY6HIRaMf+sLnD1TH6y/6vOZplAUipIj1aT8n x7zdqexRazMzrbARBe2OZBU= X-Google-Smtp-Source: ABdhPJzxh9zmvHiKp9AVLB5uChGOrHdkMdux+y77XRdYYBPJAs8ueovVpELDjCWf+ul14cb+iAaEDA== X-Received: by 2002:a65:520d:: with SMTP id o13mr10965823pgp.57.1616151683853; Fri, 19 Mar 2021 04:01:23 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:01:23 -0700 (PDT) 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 v10 04/33] counter: 104-quad-8: Return error when invalid mode during ceiling_write Date: Fri, 19 Mar 2021 20:00:23 +0900 Message-Id: <98676f9a2e9cf991d7a002b3b264cca774e5b3c8.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110126_165207_232DE03D X-CRM114-Status: GOOD ( 11.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Acked-by: Syed Nayyar Waris --- 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 Fri Mar 19 11:00: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: 12150717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_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 83B13C433DB for ; Fri, 19 Mar 2021 11:03:22 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF2D864F53 for ; Fri, 19 Mar 2021 11:03:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF2D864F53 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xX4m2tOdJMythDYcIXRetIofyuCu0sn/CdtLRWxRLw4=; b=E8TbNlzixBXhSK28hEiSSBbU9 3tPZrS+s1ZX3BblZsffHMo/IgGgfobf5kNglJKzIB7rc5yU1m7AtH6HFx8nECUgsLiuCp3YWPEKbC NxeUFZ37HftODxKTHLmtExctDhr4sw8Mw+xGNF5jtvEGfG+XyyHlV0BUJVCmZLXZfULNWBeGdCA4T YLw3eu0C6hBINBLsaSJXU6TMh4U3RBnO2+1vyKDgYHOJ2shzh/nCJp2vmcvmCgVy2Aje8lmB2R043 w1rri3BICE/J/uwR8DOkZTTPNBii/Cwj1vwUK7c1t2g8R5TCA9cxN2MrtCz9Ot3cTlGC4HqrAqXdL uh9sV6t+g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtE-007DP6-1v; Fri, 19 Mar 2021 11:02:00 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCsk-007DIP-5V for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:01:31 +0000 Received: by mail-pg1-x52e.google.com with SMTP id h25so3421497pgm.3 for ; Fri, 19 Mar 2021 04:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IHsMXHlvFNbqoAQhdtfNE0zKBykgUvZF86//Vvt93y4=; b=uRIytIxxH0fuSwhbhHS6b4YfjvyuWeiqfnWivka6MFy9ceMr5uyzm+sQ3oPn0ZAMox +fCxTTZuLgrukUbOZpVNuNzprxd3A8676IqPEloktxufGhRUXDhFjlc9IgQ48zOWUny5 kSUL9qKC3IGQhQON4sjpQd5ucTuEpLUDhp+LzAH0JHTQJS2JXK1IJvGF/laM7UuxVGD4 Mqk3d/EIrtX1uRUPQqhJMLxnN0zNLYN2cC5rRh9zS+AjkqKn3T2DDN7tGNJcachGYUVF 44J6hAorf3/jy4z1Q2/WOetkupBcJktiZhzlrltpm3j5LMY3P0RsPxFdMSHJ9tqPenuV GnMQ== 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=IHsMXHlvFNbqoAQhdtfNE0zKBykgUvZF86//Vvt93y4=; b=X7B9m5ve7/emMukSOVne9HotrGMs5GzTD9xsDqLQmUX0IWCs6gy4BEYAsUSmSmd2EB wUu1+VZhRQdKCSZpLTvVtbZm0nqLYZmmcltaE4858f8wrAehoYS3+0dGwfBWA0cgpec/ sA+/2B3h3nB1nfj1e/cMHokKnU6f9O+9sbZCUc/8RMPsUireZcDVenXMHZ5wsrePeFbT n3DgS7Sl5MjEKPq+N6vstPrpChfI/jXoFH3BFhnnnHh0+7LeSbexsn4BUAErCXPFHjUf 10avG4kdYs24Ozrs2j0qAq0ElpOtJH3Lve46eEyS5p7Ch9l7h4cB1NKEWIwtKjWYAyzi KhYg== X-Gm-Message-State: AOAM533XqBTpoZQNENuLEm/Drn2naz6gdQtzg/ZC6ivg+ZHkgZHkmBHR GSazolDPEzYiVDTfirn5wOw= X-Google-Smtp-Source: ABdhPJxSWirRoocy1cgAXwgyeqnrSHox94o4V8L5k6ly6ZQmLV2G7nSUjtsEllB2Jw0UZ7t0/O3OyA== X-Received: by 2002:a65:4942:: with SMTP id q2mr10660452pgs.34.1616151688818; Fri, 19 Mar 2021 04:01:28 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:01:28 -0700 (PDT) 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 v10 05/33] counter: 104-quad-8: Annotate hardware config module parameter Date: Fri, 19 Mar 2021 20:00:24 +0900 Message-Id: <203f1b6084ed86a6696eb422bcadc0955c6427bb.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110130_350972_B10EAF20 X-CRM114-Status: GOOD ( 18.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Acked-by: Syed Nayyar Waris --- 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 Fri Mar 19 11:00: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: 12150719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 34F05C433E0 for ; Fri, 19 Mar 2021 11:04:20 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 522B664F04 for ; Fri, 19 Mar 2021 11:04:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 522B664F04 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=V0m9UxbYcADpCJ+l1gOhWjB+ArtOPcYQbk2fzQegjeE=; b=cpkCWH9CilT/tgVai3+JbhgLv ZGLVNakQfyhyKESoSGIdmjIIo9tq0RiD50NIRpSd7MbM+BF9SfauXjWc0Y475w/eOsl6wsEqBkfL+ y6yAv1QVaBWa6zmKY+4XXQ2piSse1hh5t5JphA2QCR1BCkg2QEDflgvNLv9M6WzeFOApouCjTszzF DskXsyyVNHtd/lry9i1w3XYDoOdnpny3TiEunO50y95QBkOCv3W7pSrIr+SKpLt1IP13vewVFhhgM gNzM9AaJZDZhZXv3fBGIN229QxHzuBfHkNeZXrjyD8SA+Z7S4S3PeGTP8644RlIhaQCIG35kEUtb+ xour4As+w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtP-007DRj-1l; Fri, 19 Mar 2021 11:02:11 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCsp-007DJ9-9X for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:01:37 +0000 Received: by mail-pg1-x52f.google.com with SMTP id u19so3426476pgh.10 for ; Fri, 19 Mar 2021 04:01:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eeVMUELsSRVxeUS6ro8QPXwbMLileU2G6rPw+jVjGYk=; b=X24pb7+dYFtj2mM5k/2cLtbb+JoOMN6PVCV5K2nU1mFYA8HUghz240ARKjWBo2R6oL nW3SfEKupdMjFc4Y0HVfnVTWQEyUQ/h9gsR+JfPJ3XLjBcpfyioM5fKW0TnxZsSVAGQh SiTcftcT+mI5TJYGdvMP05FD/OdACJVIqc9uQE4jw6CM99rbxmSW9z9W+egHJAFsoBTZ xP2D4Hg5yIRu2d0zTN6+xtaMgcC4aSnOmZy3JwRVmoAh97w5cZFQqLEypsXsRcftXWRA MInGS+KjZhIElejzH+LUouoOZ7dahXxwuu4lSxlM87f7rucczOA6HD3qWbHKq0m5VldZ 5UoQ== 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=eeVMUELsSRVxeUS6ro8QPXwbMLileU2G6rPw+jVjGYk=; b=A7VlemZw/QC6llsJ2hVhpaa36X8MaUmmAHgo3LdOKEPd7jM/uVcbFh6gjL4N9mspZy mWkqFzONm24mC5S4Y3AogfRboWW3mCN4jRsiJQGpcGPDYoZuUM7nTSjcaO9WpXxpQvEm UPJCVJ2CZGvoo+ZawP7Q2ZVRjoxn2Zyh8jX/Stmq1L/ADwLD496t58UX6f5LPA+nyi9/ 6ht+opznWw2sznti/TKu/xipVunCKqUSQFesMGFxkD1uoaAlA3Wf6680Jov0GtcfWop3 N3S2UHw941/O/78FaefOJ9Kk/FetbXFmPJMQ/AIyHcELytshrTcPI5zuJE9J1/NTkbuI oJNw== X-Gm-Message-State: AOAM5313Qo6oWzVxK3YiUKKvWq0zKpecRnJanzTfNh8YeyLFixtkJ6WP 4ObaGu6uxBv3dA8+uF9wCVI= X-Google-Smtp-Source: ABdhPJz8LoFhKaWgFy/KKzChvQwuknU/7/8FINs7N2t4xXiUnnQdM+uove8u0VdoRkUHpy37LHB9Lg== X-Received: by 2002:a65:4c08:: with SMTP id u8mr10701760pgq.203.1616151693937; Fri, 19 Mar 2021 04:01:33 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:01:33 -0700 (PDT) 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 v10 06/33] counter: 104-quad-8: Add const qualifiers for quad8_preset_register_set Date: Fri, 19 Mar 2021 20:00:25 +0900 Message-Id: <4a227eea6fa6aa1648fb0ccba6e924b6f95b2752.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110135_519063_82F639C3 X-CRM114-Status: GOOD ( 12.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add some safety by qualifying the quad8_preset_register_set() function parameters as const. Cc: Syed Nayyar Waris Signed-off-by: William Breathitt Gray Acked-by: Syed Nayyar Waris --- 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 Fri Mar 19 11:00: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: 12150721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 3D07FC433E0 for ; Fri, 19 Mar 2021 11:04:33 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B1FC964F69 for ; Fri, 19 Mar 2021 11:04:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1FC964F69 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tHTBFgpKrkoYBnF4wFjmVJJFMfH8IWvKgoX3JrglG+A=; b=iLtyCM5RfmQpeke3braXtOKWM lhpPjQ8fDldERflpbGybnVmFjF6q2nOA7QM42kYQK9LC7GbK3AMEhu+8LFNypEs+deqLGG5cvM1+A B6al8EbKaJC6EErTN27IwHaOdM6pW6oeE3OIkbGd9he6SSrIDhBInotuuz1o/nRx0fLVEZcd/SfVe bqHPKOV/1oyBTeuRtVlXekmAS85IBfENaWz9oEFZdNPlzhsvR4IxpWCV8oBm/cklLdP+HX6MSy5ro dfJPNyep8IOhX3rnGlicA0wVbRzA4x2QcvxihuEqtXVlFgbal4dfke1H70ipCVIrXfcPKURWuH+uP m/DLa/ESA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCte-007DY2-6s; Fri, 19 Mar 2021 11:02:26 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCst-007DJZ-T1 for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:01:41 +0000 Received: by mail-pg1-x52e.google.com with SMTP id h25so3421839pgm.3 for ; Fri, 19 Mar 2021 04:01:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XSocH1pEsSl5GXfkgGEmzp3nM7R7NfVZbOAEiTfnQJI=; b=kjOcLKbCFtzL3WRZ+TMUVvMnzsHKXNVNuCHl+oo/fV0dipngNeeNES1u/UHkJEUIml JyNwebt5WfgbhZmvTperffY9h84hMNYEP06UtCLJ9T1v0RpU1hRDzD+XI1A/BYGnt9Lc MfCI6WX5r71fnHUV4PPxjLoproqN6KLXMJn6aZ9Q1kAY7Ss74bngKQboFwr0VTX/GCYa ej+x9hIjxQpoIgyS+vVJ0zi9bVzHFRIVfnblEGgNGTHXc1k0T3UuFMdWkidJr06aYdjP blwfMp7eW9R6K6ZNgCiM2bjzxp+/YJg4JOvwt35Wd2S0MMCUewYFiHtnzhfBvPuM+iHQ ghqw== 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=XSocH1pEsSl5GXfkgGEmzp3nM7R7NfVZbOAEiTfnQJI=; b=ebVjM3NxOLFJVfTefVu+r0lR/VdX84yZJVXlvA3ymcq20eeEyngjxkEgxZ6uZTwa2f f12QUCqEsLK45S8Rrjh33XxigFDx3lE5FvXMbL0OSFTAAXjRFqQ0FivcyTjBZS7xs3k+ HPJET3HCg2FblVfW1ZU4Q6GERB9bD1wvhZKsKutTjGcZkcbGJ/RETCpWVvbSwpGXyf8L tyfxht8QjuddGUmp99ge4bf/SvI9lxhk/iHxN5LmkccEm2rgQNJ/xuPgJGEvp/3FUjQ8 DBLjURey3fwC4RRtDlmyTH1P997lg4wXRaDKnvKp7TNGcgOM0c9M8O64nHqGiKfzIt5J sK6A== X-Gm-Message-State: AOAM530yuTsJ2RacJ1gPD5HYnQ3q8cyKgJ/kz1SNsbGWNvAzSV4alHXf 3SLd7Ms9UY0FP+0LDlLsDJE= X-Google-Smtp-Source: ABdhPJzRoI1fHcE1ZAKUXQ3BHSbmbZz4CqkRJPGAcm7nkR1fgIQrZY50i8oPgAoFDMztWakz8atzYA== X-Received: by 2002:a63:1d26:: with SMTP id d38mr11288574pgd.385.1616151698789; Fri, 19 Mar 2021 04:01:38 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:01:38 -0700 (PDT) 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 v10 07/33] counter: 104-quad-8: Add const qualifier for functions_list array Date: Fri, 19 Mar 2021 20:00:26 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110140_024772_B8239E0B X-CRM114-Status: GOOD ( 12.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Acked-by: Syed Nayyar Waris --- 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 Fri Mar 19 11:00: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: 12150723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 1C85EC433DB for ; Fri, 19 Mar 2021 11:04:33 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B89464F04 for ; Fri, 19 Mar 2021 11:04:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B89464F04 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8kB5iAZsc8CW8gF08Gjj9nEXSFRvqAQpxvWuDOBfsSk=; b=Yo/3kiv9TPxLiX/Ghgw1dT/R3 bFItPUeAXWmiYQUAD2IRhTck+Bx/RCfrXKaHxoRpMwMMyzejiCQ33henxMnNEv3E/Vpdfmm921yxV HOhQYjDsQNPOcFoIcaqisJvw3Kq39Fcxug3+FJy7pRoDhmjU/QJtvbYtig3CnBEvfyqJQlCY3wAIS jXWYh8o7f+Np5rZA0zTP0wq5LstF0M3UrliPZnsiWXwcCsA3mTku6+4K6Mp4+IuIVY1j7CVKvkwue +nHfkIU8QOt6bd++5iRy0Djva4ojApqSu7uFVHmbK856rKkf1FyTt1sMZG69RSw1yQJxyYRDIbItm CISn2f55w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtq-007Ddt-K8; Fri, 19 Mar 2021 11:02:40 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCsy-007DKg-Vp for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:01:46 +0000 Received: by mail-pf1-x432.google.com with SMTP id h3so5622713pfr.12 for ; Fri, 19 Mar 2021 04:01:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mCIsrz/xNvA8l6ynJhWaN/C4nkgE8ErMLRxbZcB8jd0=; b=am/M0nVLA6ftbdIkBJC85jGx6ceAzyM00ClgAXBg541rE5bK6A+wFcQfakS/ZWqkg1 gamQ9xCPIsmi4YpN0aQqREqPnl4PS6Q35iX09W+AJD+ypBMZ+Z0mpi6waAoh+8/MARTT cc33HDM0mNeAMW4lN2dVsCVp1ZqWvKxU32LqbchgFLVV10rVNmfquOneDsNtgilXi813 d8r4ROtk5bKf/LpcDkE8NOpzLDgvcDuGEsGRH4os16N2y7bPQN0ZmETIYRF5xB4LO2f4 JsixGDErfCTV+au9XB15Uusyu3pFn9SjhTT7a40KRd1ZsxoyiNIANFKs/3Ecrsy9ejwH 9trw== 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=mCIsrz/xNvA8l6ynJhWaN/C4nkgE8ErMLRxbZcB8jd0=; b=CfPUW1W9CKKz4ogh6+uu2zLgKqs5pxO9b3tJp8cv53P8Xy1X3LhvqQnn00ymoZThY3 yOyCzsTU4MR1+r7qvdefSqqIHk7/EciEWX8bX4x+DKu3GNf+h7KbV6uOPYB987G1hxvj xNs/WAJSWk7p2g64+OuobQJr0sgwo45rALt3cQAhNkRc6SFVzIabVYIIPAtGZSYpfAGL FukL0nGLRkc8SA4JlmsJwUNsGMJxesYLgj7osoUdFlYfHVnghI135PfMvUT1XQeff60T YW6xmRM/ZjWBmfPilOQzKkEqm/EgUHMGuVp/0zupn9FEfqRe9bNKfUSEu3CIGujfM4BY c7DQ== X-Gm-Message-State: AOAM5338jJ0SZcdpZM9w0eKxthZpWsFyb6tU5wq533JcSseHtotYmJ9+ +kax/agYLmbcv5MbFxg7+TE= X-Google-Smtp-Source: ABdhPJyKv5HtcVkjQgECZi+ZwlOiOa96Ec+AS01yofO/WrXx2aXH4fKPJt8mdlUA9B36kq6B2dkFgg== X-Received: by 2002:aa7:95b5:0:b029:1ef:272f:920c with SMTP id a21-20020aa795b50000b02901ef272f920cmr8767965pfk.21.1616151703668; Fri, 19 Mar 2021 04:01:43 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.01.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:01:43 -0700 (PDT) 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 v10 08/33] counter: interrupt-cnt: Add const qualifier for functions_list array Date: Fri, 19 Mar 2021 20:00:27 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110145_132696_5A64D0A9 X-CRM114-Status: GOOD ( 12.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Mar 19 11:00: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: 12150725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_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 32C96C433DB for ; Fri, 19 Mar 2021 11:05:07 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 68A3A64F11 for ; Fri, 19 Mar 2021 11:05:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68A3A64F11 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Oy75tubZPzfcJXbW6jc67lXifMW3y+bCGjjXWPM4QQo=; b=gGEysiQyphZSN2/lyH1OW9qEf cer/o/LeG9oonO+AV9k7Utw33T2h0aGoCYxQ2FwpS40C9QTihbBpiDEHMTJHKOljW4wkh35CI06Nd MoO983ifQAZFhUJ8BpAxn+ELabW8lEm6eGklAlqg/zbiHZhejHv4GnXBSjDP2do9t2G7qzrrEJW/B ZEJyYCd1YwRhCC3NnQzKGt5L0vDRYILaIAJ7UUJ/pEOaj4vHlaMx9PB00Qn7kJpHTiD0pmnb5MGtP Dqem6tK/kJawHaE9qDryp22M1X+jdgGm8g4PkbO2ZpEl0gjUhYSAK5tJdKJFik3j1y7+f8XZEQ0AU iyxS2aD/Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCu9-007DmO-6A; Fri, 19 Mar 2021 11:02:57 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCt3-007DLo-Qv for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:01:51 +0000 Received: by mail-pj1-x102d.google.com with SMTP id gb6so4484920pjb.0 for ; Fri, 19 Mar 2021 04:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wYRkXjsb1PVUWcJtSf+4c08/zRkX/J8HBJAhSg6Bbvc=; b=n7oeCws7sjZvBebyHE7fBiK6RqTLulu55vDhMPuOzayEz6rz+d1gs3fVWFOtfrJ62e toRYYupwhq6QMZ5DL/ZttFp2LB0dIA4DYRM8vCsiVJBqibRMSZJ9aKWhzqptHY2Uu/e2 OCWOrGDxQ8lNJyRInF/2dOcoyCNxLFJx7Op7QtC2eSoui30LlusueFXfj0813mUgDO1s Cyle8ufF1veYYkQltfkhXjr5Zq2lMjcsaOvqM4H2osxFTnzc6gE/RRMgf5IXRAPb8+l9 QrBSx+4OsUTFOd/rRATdLLUJ6IKwYArS0AZEJ5j7S+L3tJSJ/GP1mejYNihDbI33ikBq pmng== 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=wYRkXjsb1PVUWcJtSf+4c08/zRkX/J8HBJAhSg6Bbvc=; b=YJgFZNra68jFb+OqIiMt9TNWdJsvRsA6I2wcp4zV3E+BoWED8cfkrI2wp09uC6O/gI DvRz+bLH55Gw2rvWIbbV5G/kN0tBAxQ03FyikVwQ+YdUv3TH7z8Bgg5icesLRF5Ci6Df 2TN2ORMEesqFHmicP0i00LYaOX0Ei0lOXNOhFiacEydu7d6Z2hLAH2DiOVcdhoW0V5UE 7TVUt9Uj9FmgLq0mNNAsMZcgt1cpdVia3Cqj7/5Pm1PE7IE6IQxIHQQemPqO6FWOKOYk iKORh0DD53TOjkmrT8hhHiu8JjBLSYXPed1fMLIrxkZXJPlkH6gqJG8oLwY1g3Rih4OH pAtg== X-Gm-Message-State: AOAM532593N5371jB/U1qG3L7kTLxE5FmltFY3TqPtrz88hNWZrG9CqR D7880ZlokWr0osLTaQ7ZXuGmjen+DAh/Ew== X-Google-Smtp-Source: ABdhPJzLKllTLseOaGqWk7ZaQmgb/qzKLLE1uT5g8JgA/XofhROJiz2cVxQ4Lv0hd09wd8lboU/QnQ== X-Received: by 2002:a17:902:7609:b029:e6:9f29:625f with SMTP id k9-20020a1709027609b02900e69f29625fmr14284842pll.80.1616151708526; Fri, 19 Mar 2021 04:01:48 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:01:48 -0700 (PDT) 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 v10 09/33] counter: microchip-tcb-capture: Add const qualifier for functions_list array Date: Fri, 19 Mar 2021 20:00:28 +0900 Message-Id: <130ef8380b67430aed17ecd938e6460e73f80058.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110150_139743_9C82F5EA X-CRM114-Status: GOOD ( 12.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Mar 19 11:00: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: 12150729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 3FFECC433E6 for ; Fri, 19 Mar 2021 11:05:37 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96F3A64F04 for ; Fri, 19 Mar 2021 11:05:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96F3A64F04 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6jbB/Wp30iU5jFsjecxAERlwModDBszhllyk4Es7xm0=; b=OlWWs7BPiRy4m9sfSohOY5XLo EfRJoZKGYLV/0Rd5ysggsFbyZcZXqxvh4G/VOgWag8nVBoN//loy5dKFeOl1zoYY0c+jH7jlF3rTd zeB1EcD+uoQGs00JE0GGIBEej21znhS8LrPz6en0+kFJgiySZn+T9aUrQovRTGcpfx1VH2+lUDl0i FojlS0I1mSxZEGN734J8cYMRMKtyico/3oQPZO3PY9PsW8GmwMkfNnzQi4tbOkJ0hM3XpTHNgSKk8 Ch9fsTpKVpg6N79TZzO94P5jqDeAO+ZFiHY1NHHEZoszixlRGomRqEwXDX2ZIYbN4V777+RPB5+AT QvMIgjZug==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCuO-007Duc-MU; Fri, 19 Mar 2021 11:03:12 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCt8-007DNT-R2 for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:01:56 +0000 Received: by mail-pl1-x634.google.com with SMTP id k4so2783721plk.5 for ; Fri, 19 Mar 2021 04:01:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CjJQUNTwsBa+RZPOzEy/Sih/eBggOo9hBH9OJm4YwV8=; b=MkepcUzFZogp8zB2PNJuWmigI/5LesD3IUw/sJfRQzB0wwWDPN2B68iLLpurdR1PlC 23YaLOV5bj7v1kw1cMApbc0X/pyIXCcElFFarf+j4sPzHc+tx8zuBtOQ4c3qCWNC/5Lt 05cFWeoLzkV2rUjlBaW2nYTAf8d+fM6eo8FoP+xYxMVnyAK2Q6jGAp830LeYJ2AYZkcc 6I3dnDKWWuSMhU6UCtFZXrP/kCQkPZ6eXD5zOPjCO965p6fagAdyZ/YA3//Bd0A2TFml /j+OEFAA/OFVAl0JiwokRoDye5rzYz/Htk0+SZSycagbQXl0qapDLqtUgJSh7MIEyEu+ PjZw== 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=CjJQUNTwsBa+RZPOzEy/Sih/eBggOo9hBH9OJm4YwV8=; b=Tfem+KoPM1fi/G3Tgrgzixaz874+jAo34bmyUj0eNx97THDmxgDNtAnFgNQhAkJFmd xoDTj1sdkKKdpO3OrIHcPfY5B/ITW9Cb64imwK5K7nlerkCHVK2I9Ijto8EuuFoVFD3z uJerQuDka9fYq0nphwkwzIQP5I345biGyXBXxjHtVcwiIxSeVtmFevg+MJ/ox5dDYJ5v ra48NoPxVA6tl8bWx25pGndPsX34wP0FOsX19hGL7GqwQmlFBodaxPc7fDlgjQohHAgx xiHpTSQLh+Z0Sh69FENG7xwSUnGKp/+KNXJpNmszGC9cU0XOphcJZsn9bbF/AEAXGYOs QoWw== X-Gm-Message-State: AOAM5323nXF4ZjDAIofz8WItuAtM0+tcWkq8keOl4uZnrct61W4TAmRl t8oCiyxcUY3HGwf3XDGbMu8= X-Google-Smtp-Source: ABdhPJzh7KmTVF5c/eWnSvJBwidUGWNTKqwczSwnvsTNxu/q0mMuF7gvIYCDa+BqKEltXK4+qmPpMA== X-Received: by 2002:a17:902:d4cd:b029:e5:dd6d:f9b3 with SMTP id o13-20020a170902d4cdb02900e5dd6df9b3mr13540874plg.43.1616151713477; Fri, 19 Mar 2021 04:01:53 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:01:53 -0700 (PDT) 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 v10 10/33] counter: stm32-lptimer-cnt: Add const qualifier for functions_list array Date: Fri, 19 Mar 2021 20:00:29 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110155_013746_D28511BF X-CRM114-Status: GOOD ( 12.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Fabrice Gasnier --- 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 Fri Mar 19 11:00: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: 12150733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 C7033C433E0 for ; Fri, 19 Mar 2021 11:05:51 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C168C64F11 for ; Fri, 19 Mar 2021 11:05:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C168C64F11 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Q25GWibaaav/0eXPVymNAfHdcK8xmyypEeiYWw83CuA=; b=U0KMXKYQAZ6/DxJHVipcQVfP2 dXu0hlDIDuUNcKs9+eROfN2YY6w8OCWn+4BAWBFWIgj2X+aTOUoQVHbJNAVPxVdOq1RxEBtQlhyr1 xzkaqoprzIG9CR9KgchwSZ2iY5aw7eZOoJYCCASOK4aOIDPehCb+nh9DZTLU5vCcrJtUCG1OIxbWo nzWId8gq/vfcX1L9yTLH1CNJVt2cmUpS5m8BulUv21F6XLo5BHCIdJSEbGfO/M9VPJYQAYin2WEO/ UYco12lDOtx9cr5wvKIjEcAwBhlyAb1Sr3/Ga0E7iOW8z9ih/gCowigy7YlAgTpuQkDLtDP88/w3D pXlMGnneA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCug-007E3j-Q2; Fri, 19 Mar 2021 11:03:31 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtD-007DOl-Op for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:02:01 +0000 Received: by mail-pg1-x52f.google.com with SMTP id o11so3422380pgs.4 for ; Fri, 19 Mar 2021 04:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2r+hb4QLBinjqUWBtvalv2ZNlSEWr0t8LgbnD3rkGXY=; b=H51BuvBk+d+VrafWjiNmYuhXP7SH4yFn00mnwg8b97GELTFmQGDRHkiyl3cFn2Du8H iWdGT8w0g9J31DJ5Cediv47FGjuMnN0brALAyV5qutKgiyTRrWt6cnr9K9P4qAvY42uS odgf7DXOOTPORiEcmIVEiNWzL3LvvJC042qtOR3WoPClXPiC05+8SR3a4hrhbJYM8U58 /FTBmCjxLdoE6ydhBNWZrIBpCJya8vha05aBc/bGwLcFXv0PBKDhRXj28uaYVv3GGi9r 90btPv0mGImHFMNNFp7ji6CM7sjqsxsmaok6UU7JjI9WyGPunAhcRIowDks2smDYvJHP vmfg== 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=2r+hb4QLBinjqUWBtvalv2ZNlSEWr0t8LgbnD3rkGXY=; b=UXk27EEoAJX8R4osd4YUP2GbFOSaLRyCtLMXLgoU7+dtS9WulDzdqz0MWIzT6VMWkK hMLG6e/NrlXOA3v6Z9yP/YgGC5MXem+HMeoJc+KiuLD5Gc6uJ5yTfmw3qY0UhS+xS1IB zCOsLehYLr2f9iwI5Irzw9bdUgCzLPg9OOvx5F0enEyoL57ujjrtP0HM2kRKICBzPdj1 5T9PiG4pj6wL6JAeyhOV7kGrKGqWkSEF55g8gUJeN5j719VRlmz2yqo9QFAfy23NQAMM +OwO+2TkUFGJQW0ZDJ2l/wl7pnVlhcUWnqMmGzPwqRxdwCdwxdLmbUS7XzGZXohSKXZs 9Iig== X-Gm-Message-State: AOAM531NWuh8yYjMWiGpV+VGMzni4SfGU93r/AukGkrFmsdclGsfs72d t9gxzKKEWhDcdimrs2bapo0= X-Google-Smtp-Source: ABdhPJy7/4zKHODKQrPCYa79oyG0kmHaS2DclyVozWj+lMVQ0xUggA++2YKGb1mbTv1owgD153DeBQ== X-Received: by 2002:a62:3384:0:b029:202:ee3:f83b with SMTP id z126-20020a6233840000b02902020ee3f83bmr8759016pfz.77.1616151718601; Fri, 19 Mar 2021 04:01:58 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.01.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:01:58 -0700 (PDT) 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 v10 11/33] counter: stm32-timer-cnt: Add const qualifier for functions_list array Date: Fri, 19 Mar 2021 20:00:30 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110159_833426_504B1DBB X-CRM114-Status: GOOD ( 12.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Fabrice Gasnier --- 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 Fri Mar 19 11:00: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: 12150727 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 BF70BC433E0 for ; Fri, 19 Mar 2021 11:05:36 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F004C64F11 for ; Fri, 19 Mar 2021 11:05:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F004C64F11 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=COMn93/BUjYhBed2HH/NGoZnSxHE/VmUTje6v6rH/cs=; b=RzvUPhs1qoCHQ8OWhLaENnqKD c4WDtQa/MSOdQIUTzGaC+evtmz5lGbgPsCmRaRlCsgWbEEpjI03m9Qfq8/i3BmLCbOX+mTIFAqhUu pDxT7VuZbUm2aCg7PD5+GGGz2C88q5eVQSGPv6J06g7WjqUoBX242rwCDKhSb5yjuusI10QJNiVY/ QLoY1ZFO1EPFA+Qf/hsUat+v7/tfwOpM9CbfNNLQmCvASdjSNT42bbv9r9e1Wwn1kNKXZ9JRaCfAt i84OB88hRObBvu42VvGQ/IA4plOH/i6tONbdnLJPUKQ3dKwRGBO9mAMDJA43NGbpAY6Q3EPXui0hW KHar2QFGQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCuz-007EES-IO; Fri, 19 Mar 2021 11:03:49 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtI-007DQR-S8 for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:02:07 +0000 Received: by mail-pf1-x435.google.com with SMTP id x26so5622093pfn.0 for ; Fri, 19 Mar 2021 04:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/u2CPhZ6rUOBCIUNBfUVUJzsOfzYQHrAipQY//P3glw=; b=M6FbohQN6QUpKcRcTQtXxctZgSYOg32ch1cIus2E17bA6hd2xMpvKdX+ycavaIlFrQ S+GGz2U7BOzk1dN8RRwOMWr4NW1le+2dEx3EJkSuT762rwIHCmfuZiPiUSSwfwsmlPKE F4laZsH/rzuyYlmfMPUIDbKkeXatKqP4COm8b8+OABaJ6SVK2xf5PhXJ80QdsLr1bgU5 zmXn8NsMzlZXTh5Alnf7Cxx5q3QsZRa9asMPdJI0gGzl8lJLYTirsH6rPEpTf5aiyHTZ 367j4q8x1MDEYISdNpkXK2Ku7ldTDQx08nNoeuMV2+bhDryD9PGEl5C7dtQIfbmKcQ2Q g04Q== 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=/u2CPhZ6rUOBCIUNBfUVUJzsOfzYQHrAipQY//P3glw=; b=dRdUcO2W5ITjTB3Nq58kJS17lcynQoue9kA0K+GHz4t+011S/88wxF16fGxVFzApYs TjTiSFH+Qq0omaigtfIIi1f+Db5ZZiyd4EpE9di39Z6RM2Yn+UK9rOVwgpcClLi5LRoz uBBxvqnjhAdLJK3ZumorFaxfHd42LK8153IKrr5xwsCcA+AwF+2mnK4AWyWLRxgoYslP Edwn+lOLJgNuP8VWiASqgkCPyq4tooycx5ZiT9bdAcZf7SWawzbvbdaYhzBMPtzFTaKX vX0fnmHLYuXaV8TmPtWdq12D0+2oExnSurIfEUtLkGGczj/HV7YaRANp+III/xv4OtMV p7xw== X-Gm-Message-State: AOAM532cp9U5HwzzH00nF3/4atHE33gFHhUzOZlifJIFc/X3imwIzRkN 9kKBmT5vBCfNFMXCKjZ7Qv4= X-Google-Smtp-Source: ABdhPJzoGuapduW8n7o3efs8G9ZXNqL+hMHW/rmBLdctPnuOUR+alBxNVTO0yFqiValIFXrVtJS4aA== X-Received: by 2002:a63:3705:: with SMTP id e5mr10731684pga.318.1616151723687; Fri, 19 Mar 2021 04:02:03 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:02:03 -0700 (PDT) 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 v10 12/33] counter: 104-quad-8: Add const qualifier for actions_list array Date: Fri, 19 Mar 2021 20:00:31 +0900 Message-Id: <92caedb694b4c66d9a5e9190f8c4545ae28dd418.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110205_968034_65FB8580 X-CRM114-Status: GOOD ( 12.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Acked-by: Syed Nayyar Waris --- 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 Fri Mar 19 11:00: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: 12150731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 762EDC433DB for ; Fri, 19 Mar 2021 11:05:51 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E90464F53 for ; Fri, 19 Mar 2021 11:05:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E90464F53 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pbDWPWSMhYkS4xQakQ7bgisI4DkVdkBKZy86k6NFWM4=; b=JejsA6nHqqCI03uc4s/Yr+Pb9 s04Xk2UWVqmoatkNkcR3Vd+PFcq9tauTHdcUdNr73u6AoLAqKIiJcdKAF/n5fkUoOkn+gtfrsvy+a jpJUFgfmMFP6jG3C/mZ7zEDrlZl64A213W5Fze9v81K8950iZuUoB9WaYfIiGyqfTy8vBePOSw63A LiVqcCh7pGDWvKlrwKWjU/1fojc35XEwPaBkY0S2puy/gztOnzVcbKwK8fgNPLmTZZ5aWTRB6hY2N KlOQEXWTFL4tXiSgZ7P6fwlm7kFmMhqIiuZjw+qhp1HRPSvb05ZG+m12prpj5ATRmX0z1iTDwquHT JooQNyS5Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCvF-007ELY-7U; Fri, 19 Mar 2021 11:04:05 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtO-007DRF-8d for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:02:12 +0000 Received: by mail-pj1-x1030.google.com with SMTP id ha17so4485332pjb.2 for ; Fri, 19 Mar 2021 04:02:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o9szktyqVt36+WoTRvGFyjpFpuwX5mGOXWZAwxNI2o8=; b=EMmwrsrPY2L44xoGNJiGwrnlZa+lwCO8CezAqpflW1G8p+ctWLKic5p2ddU7hWwSfj AoqInfEQicqM0k1Kp5hbJ0YYztbI+LSnP5MRSbibyFqFcwdrT2JYDpYBAprhKkQDz9JF PXAcwaPTqcSE4451deTVvkHAs58NEg38VmsOK1vvUVvYIIO2EoRH1ouqFWt31kg77drP tsGPHvE0VL1P9ple9PkCaThQPxIcLWrDueIPEFUG1n2QYCayBsOxL8nEGyAqcn1/DSD4 W7bpY2PjwNKI8UTJgmtik4Ueo/86b2UyJ+gOVIqa5pY+/ChN1bOx0kFxtEIx1UTk4NYT 3jVQ== 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=o9szktyqVt36+WoTRvGFyjpFpuwX5mGOXWZAwxNI2o8=; b=g3dFA3USYLllQIHPS51G00mTR4MnOGpPyplGdqLKFqQnVKA1FlaTbF9xPznYHaxfB+ S3g1p3L6mMD8PaBMDPoKHDkv1/okR+fe/d5Oa3bW4o4CxDifvTKn6H5PyyI3+qSB6s2c RwNahcsmRadkBWxl5j2LQh/+Qs5uNWNUImGafMcKNSY7w7jRLUKlZwG1Istvlm5tyr6E kIQUP2pCkZBqvUYVaQLQu49SsGh6cWmcu9WcsssMtRUtqpbUoL4dXgeu3T56kCfttV3S JBT1lp94LxBi6Y35ditpoDChVH8ZrWZCwnd+dJfHKXXHQJRR8pvB1hXz5K5l+AkHMawU acsQ== X-Gm-Message-State: AOAM533CCmjPi4FaHD8VR/5N0+Y+W5vbd2UI6U84JJEdA3dhpQgDZqGH bJ8NTx3hKt9iJmL8XnzvdM0= X-Google-Smtp-Source: ABdhPJxL8b/9G2djwsqj4texkb9XQeo1yDBgnCWHkTsY9yJ9mzWyPkA7BuNdLizCBhAJs7phJW3isQ== X-Received: by 2002:a17:90a:d911:: with SMTP id c17mr8789491pjv.98.1616151728644; Fri, 19 Mar 2021 04:02:08 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.02.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:02:08 -0700 (PDT) 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 v10 13/33] counter: ftm-quaddec: Add const qualifier for actions_list array Date: Fri, 19 Mar 2021 20:00:32 +0900 Message-Id: <26cb41a51178856fa99e2d8e1912dc9e4a37b605.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110210_718722_94144B40 X-CRM114-Status: GOOD ( 12.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Mar 19 11:00: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: 12150735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 4DA26C433E0 for ; Fri, 19 Mar 2021 11:06:07 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F8E864F04 for ; Fri, 19 Mar 2021 11:06:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F8E864F04 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=837oGcxPyHbKqOPReQgPOUcQpXGcB36xP+q+A8Bhxho=; b=dXyLxorxwFdT6UHlPALw2NXmD X3eHp5vHhOCtxqSOuY/8UR9mJfXswfuQib4bxCDhuawT2oFZjBgwn2gPTizJjx0nHXsX1+hIeWJYJ UY7EoTKQ1IpiP1B0gjTx9JurqqeLuXQYecD/66icPpUkGiNr9Bf3Y1yNlahDpN/CZWY16sNfUCPZ4 8yX+a89v+IVk+Sz3hReTuH7p4MVX8++zZQW3xZCYoq19IgiDurdex7XzSjQl/VwL3OXSin0ytPnmQ DCvrN3eJhQDWqSYJAN73SGhpcWQSxWQzQVYFu7BJSqfz3sAQnCJVZoZKP+lu1g6fWUzr8G1oTxJ9g 3DeDKAXqA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCvX-007EVY-Kz; Fri, 19 Mar 2021 11:04:23 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtT-007DTR-0x for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:02:17 +0000 Received: by mail-pl1-x62f.google.com with SMTP id g10so2784379plt.8 for ; Fri, 19 Mar 2021 04:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CzS3NlE62IcJjUyZ5qk3czC9f+XUZUeA9uXPPXXnAM8=; b=dtjQRf0CP07sJ2z6Eneel0Gon/lsArlDmbRz3ilHaaIf6tLCjQ75zJ+hQMh90HxX7+ Im7ilddYq70zNTOEkZLRerrCW6QT+mlit1re7YhLWszt/dg8BNF5l/0t2BhlmT9DAUt1 pWc4sKTXeqHAUym9rdNfJjrIuUjaLSKAmPUjt+fgSVi9lZCyOY6lqnevZj2X8cmtD+FR miZoYmsDlr3U/4i9GhNt5If18c1KXoect8VRsOkuembFBKk/MYFcpCe02muVPltNyr+C qZ5EY2SwIDq0UQW9G8kF8t5wwbZ8N1Mfa2Xilw+RXrmSlIJZgVspwC6uXCfF3QFy4vp1 3pkg== 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=CzS3NlE62IcJjUyZ5qk3czC9f+XUZUeA9uXPPXXnAM8=; b=fhnkhuXbHAZbN7mKLVaaqxCw9Di8DJOWpze/piD0WPbknjXmttX7xgd0cRj0t11bn3 lELbfqpLywcPm8KyxAnbcRVfbf9078LkTDCpFfOl0yeENujhAvSWStthqEfnj7qxOWb8 hDvgXAnoE2oN6hnSOaVNRDX10aED2VCl9DLwygp7XqG+9b2uPoUHTh1INQDi39PIwyEX DOSmn3SxKLRIoQ/Mxjla8SxRCldeNfDp2MjUDjemAWQVddf6cslpOZGEz5apdtgYrNJ4 3RaOmSSN8fRBlgBCFOMIAlquNYSpHvV5KMlZI+YLyva5X1K0DnIAe7CVHqB4/AUX3lX3 ZBag== X-Gm-Message-State: AOAM532oiVhpNg0QcHzqsM9bIXM/IuzMBe7ks3XUAjxr2qwKRX+ioyrI 4GttSrhlbcaxX5ob9RxrO7ArlvUi4glowA== X-Google-Smtp-Source: ABdhPJyq+X+ih+kVYAP/TinmHgoIzLZQepjdalrkaduhO8V2BqB+ieMb4gPKsDDBHOEkNy1Gvl3YLw== X-Received: by 2002:a17:902:70c5:b029:e6:cba1:5d94 with SMTP id l5-20020a17090270c5b02900e6cba15d94mr11170116plt.84.1616151733578; Fri, 19 Mar 2021 04:02:13 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:02:13 -0700 (PDT) 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 v10 14/33] counter: interrupt-cnt: Add const qualifier for actions_list array Date: Fri, 19 Mar 2021 20:00:33 +0900 Message-Id: <961bd5450371a32492d5cb189ccfdbe7d9160975.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110215_193423_DD12A6C9 X-CRM114-Status: GOOD ( 13.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Mar 19 11:00: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: 12150737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 80A4DC433E0 for ; Fri, 19 Mar 2021 11:06:29 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8452D64F6C for ; Fri, 19 Mar 2021 11:06:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8452D64F6C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=on5dCnAatjOEjI1OtjnA8nTzEmrRjGVSnO6hz0oy28k=; b=paIvhYXCo9u2+dCiL3POMcJv9 0QuyVhrX3+0r5Hf+MVT38DPsxmcPXsEWW9FZE1JHboMjxSKFm0aABSctVGi9C0C+O+E+oVp4jyIB6 GMCPEz4s0TSZJiDD+2gdj7ywMFl0oQMjkhRWeT2DdM5RirvbGKmv1kN1xl09grypb5+iqAuQDfq3s nEESzTbKaWtOF3OyA+rNDRElI6Q9YfO0gXCQkYz3dQDRqvwYEdtQFLiRikXN/6T0qwClrQayQELfl E05K7/PFvzGAmaH2lfejXHXmWtRGTjYWGFNBPb3A0ycTpt9Il3DXYvTDnHzHqa7KdqfdYIalCPfd9 UQxMvLBaA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCvp-007Ee0-VL; Fri, 19 Mar 2021 11:04:42 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtX-007DV7-N9 for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:02:21 +0000 Received: by mail-pj1-x1030.google.com with SMTP id a22-20020a17090aa516b02900c1215e9b33so6528002pjq.5 for ; Fri, 19 Mar 2021 04:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lP4DMV1k2SKwBGG4XgbDMs9P1GWZ9vtwOGQw009rdwI=; b=KXlYrHJXMRHv6/1HCs2KIjiBVTKWFcJfWoq67AacvPXMLIx+iRiPEyXQpwMIqLG7ou Wcd7Zj9VztkSNbvD3Gehrs7eVsyKUTEwfZBgHJl3cYLBe0X6X1vTdIMuiLP2wpzXSqRY Rlm2iL0l0mtBWVcW5IHqZcpor5yYkorjL9n32skrpRf0N1Uf5OgO+cCKI0VKIY7+c0du VPNSz3dd+Il5jrGCtorVnVWMKLrTPn7HmHaGqs7FhZH/j6zG7Kzr+g2AW8UNE61/BLY0 nq/D1ajtYgjR435gVplkiX57/0+lormJ9Nm8RgkTghuZGJisD4o/AsiBX+cD2+lzwHKo EkKg== 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=lP4DMV1k2SKwBGG4XgbDMs9P1GWZ9vtwOGQw009rdwI=; b=lpKYPh3wKILdwujAbMQ1QgntA0K9ykNbHvAUL7BbV+7p/+XnmbZ88iIWcXMNB6KqAz 9MQp+Rlg7fokAtYZyeBUklgn1T1iFcFJF8xFPvMixiOFhyXdnuvOHOpqaRRHUgx67D8k cGWVMJpPQFskqSoSvpxwv4ei0n2Iwi1BY2S0nPmN0nLaX1YHIWqdtBOwLNIJOs9Io44t 86sDy6z1zXyRKRSu+5a8cUwMqdirY8QVUyrBnCaOI7fxayRxsMV/lbk+PSDopne9UrB4 fkblUENgO2ksX9rLoxk/wKDtiG115FDp4wyARukcnBOuTf6eOScVw39vrvnUbjpjO98C 6aQA== X-Gm-Message-State: AOAM532QjCYOsGmfQjwzCsEMAMaZZJr/uISP54l6rEHAAlJqjXYCnGl0 FXI8Nb8haYsdSJ2G2Q3wsNs= X-Google-Smtp-Source: ABdhPJyLCSHLBNb1i1M1D6923w5s3KUyG3J7/Ct9odrQ4EqOHGCrgICCXj/iH02jQFwP21RlrYmnDQ== X-Received: by 2002:a17:90a:69c6:: with SMTP id s64mr8922168pjj.37.1616151738483; Fri, 19 Mar 2021 04:02:18 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:02:18 -0700 (PDT) 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 v10 15/33] counter: microchip-tcb-capture: Add const qualifier for actions_list array Date: Fri, 19 Mar 2021 20:00:34 +0900 Message-Id: <5043d74887ca245274e535633a8eb472f690bb7b.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110219_836293_73ED6325 X-CRM114-Status: GOOD ( 12.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Mar 19 11:00:35 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: 12150813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 704F9C433E0 for ; Fri, 19 Mar 2021 11:07:09 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 898D364F11 for ; Fri, 19 Mar 2021 11:07:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 898D364F11 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dkRakgnMKO11+roEY9WVAaXGu0C0HrG2zUeV57bp+S8=; b=PaVY0L59w9QYQedfI0ZhA0WMn lu0kOfEKy9OMo4T5JHCNt85L+uxG1SZ/RbV5m8KUadmWHRKNeKZgvsc0oJSgByWjFo0aINB2zqHCD P1XQNEcWpNoVGbemqQRFkiUcJWJJtXNCTQWPtGNFTD5k6SjKFsWG4OCrwTsyG9O679ZQD1JNbNrIJ TEXGGKp40RgTRWTyS4af1gk2lSMEvdS4aWxWU9dCJUiB4SS0kZz6ZwrrkgGd5+YfD5D6bwhTZHVfk Qu8ZyZIpPGTlyHeaxPfELjeLMb9riCOLZBR69vzYe6cnRr0e3zM/+QYtaBTNwGpTnG/T4Xj+50+B5 Bvc6CNDNg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCw8-007EmL-CG; Fri, 19 Mar 2021 11:05:00 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtd-007DXS-1J for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:02:27 +0000 Received: by mail-pl1-x631.google.com with SMTP id v8so2787891plz.10 for ; Fri, 19 Mar 2021 04:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lSxNdunUcfVjOwF1Ukve+wpGCmUe1GqXnjLiDip7r60=; b=Ijjt5X33sHG6VLfr/X33ofH/zw3C83x5jF2PbSQDxSentiAHZIdiWspxk+4wpX/j/k dll2UbF/VnvXh89Ud178c7zqeR+G4sJ9kXGUWQys5Xo57/GUxwevKvql1vB2pRI9s2O4 D8RA3+HfIXxAwA2e9r37NxLzuu0F4RH2HJ9DmslDfOAp/DbJnmv3SEbR0U2UxXmHN7Mh saPQ19ko9HehDeewr55u+I6ikxva25/lNvth/kyOEKrC+9aZgJ43NxDjrjcpXa9VJMcJ jkHyArhlPzf/2CaRZ/kRVPzG2TZFzLvwSofJeOfhmkx4TFT9uXwU4TAvQfYNxBBCq6a9 FT9A== 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=lSxNdunUcfVjOwF1Ukve+wpGCmUe1GqXnjLiDip7r60=; b=GNDBipMKhlpNM4sgMhgYpWOaq8QT3myljLkMyAAYO8tN/3YTfNXfDJ+XoxGMvhcau2 hOnzgvFA6F7/eSluJebDmeHzAdEcPkH04BuobGmDa6ZzE5Q4G1rDh+QddjV9yvpGLSzd WHt+qZmteJdHjLxiLtwDV1WI6+7mouR4DLNxd2T87aWtnDWnHkyUrUa1pV6RL6ANYoGS 7Gf5VqmRX9CcKWzXmy2gkoHsLWwpRinyKfswo6nc8YP333IJRLc6OUWABI4VYWPTIfok 75Df8xVufG0vG/TuhP4nSLFkCGb+CRL1K4UuOIa1goFDbGYTR+3oVMoBsgy2Wj9MMPzK xjIg== X-Gm-Message-State: AOAM532V7RufI1W0rGWUsCkLhVG5d9gHToMT96/kgE/pI6D5Cboav5XB ihNXpkhX91CeC44QzqId3MA= X-Google-Smtp-Source: ABdhPJxakjll3igoMgwm09QbKi+PEN8Sji9wqQ7cN5cp5slUO1v+w3Ri5WLxTByTWvLWd5tA36ZOJQ== X-Received: by 2002:a17:90a:1b0e:: with SMTP id q14mr3596346pjq.41.1616151743496; Fri, 19 Mar 2021 04:02:23 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:02:22 -0700 (PDT) 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 v10 16/33] counter: stm32-lptimer-cnt: Add const qualifier for actions_list array Date: Fri, 19 Mar 2021 20:00:35 +0900 Message-Id: <1a454675b256daed71e0c0053377f36475f920d3.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110225_328533_D211CEF4 X-CRM114-Status: GOOD ( 12.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Fabrice Gasnier --- 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 Fri Mar 19 11:00: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: 12150815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 B3007C433DB for ; Fri, 19 Mar 2021 11:07:12 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7551164F11 for ; Fri, 19 Mar 2021 11:07:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7551164F11 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rppOkBciRygqp2xTxhXatj5Jax41x+VOgIXgF5JTHnY=; b=LLB3qZ9LAR3xgH7abd0CLUhTj BHDS75ugafGQZSFNCyXVw9I/RQNoZq5SmCL3aNbqA9HhxwggmYaZvlm2Y4qHZchdUz1R2V3BmLjGQ fjzLfYhB+Ueb83+Jh8f0BG+bK0OQQDYPDYb3notBNTw0PM6FToicsxPTQjjvgI1xpR6exS7xo7KBr kva0gtXTqNQBuLeBhh6wuropItkyz3zbQcP0n7y7iYg3LHMqw+AJDaa1Lm5Ogm7Om+id/diKPBemx DAgn80N3DVisLqu1PXEXA1zycSjPDegb0B4giYrnPRLL7YlEdRx4+vCcY+WLEtCBXwLe9YOIt3m7w 7y6LzRvvw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCwS-007Etk-Nk; Fri, 19 Mar 2021 11:05:21 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCti-007Da6-1A for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:02:32 +0000 Received: by mail-pf1-x434.google.com with SMTP id h3so5624062pfr.12 for ; Fri, 19 Mar 2021 04:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ecJ7k92m0DfcFt1BeccNAFge0TH40D/RcDRWwVj9l7I=; b=ZuFxGxChMhbMQg9PTqZGvyF/6ZSct7w2HVa1tbkOA+RI4ELbrcroE/QsWUJ8FWGtav VAH9QUmbHgYiMQddnw8ql5IxvAxD7TgqqgnG8Hs19A7eXklWhQ5xK8IzhhEhQYtccTt3 uQ97mMm1YymTR/PXHxCeXl6rgwDy/JVPf/TJpgM0KSs8XSbx97yInEYiw849KHrcfSq1 j22A4M8j2yf60az58Pvgi/61KLi1C+dnQS46BWdpD8yeV8hyKSAhHVYFIW8VLVCT1Hmw U96wffI+Doe05LNhBAKYs2nvluOuk7rlCkcXwrv33GNw8Nv8Bzp6y33TN+KJN59ldWhS K6Yg== 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=ecJ7k92m0DfcFt1BeccNAFge0TH40D/RcDRWwVj9l7I=; b=AZl0/6P8G+mYeahBjinigA9Ru8djY2VjrVpcEne9AZZawsyXPNSYIcV6t0EpLD65gU F1GsDt+Vx9N5BX4upberN8AlYRQOGBDgIjdIW+hRibwTdZlFopJ/PTwOJYQ72IiDGfgI peuP5z02qwGSWXesAxyaLpm9qbUk50DP5kkezqwKe50hbbEyUNv1urJuKuOZ234hONCt 70RpK0NAlmbtNaJnPszNKyIGVZwgrYcHTr1JOQPkjFCCEBuEBSpnWvApSa/r2z917PzL evmZS3EDy6y8kVY5N3hI4ag2MKOE76VOicyMRFrTLU1p5Vc24yu8pPtFE+hbD+72szvq 3Pww== X-Gm-Message-State: AOAM5307OaietGu4unG0bPY+c84pIWAzUNVxRwPnLlwR+0Cyt+nPRR6J 09zvg1fpgVLg6WAbIErSWz8= X-Google-Smtp-Source: ABdhPJyZPrMcXR4vbb26JH5SvHP8Hfz8rE8wKT84uf2aNvKA1Glc39Sz/S7jRC1NXOOl/uy6/t8c4w== X-Received: by 2002:a65:6a43:: with SMTP id o3mr6751137pgu.297.1616151748594; Fri, 19 Mar 2021 04:02:28 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:02:28 -0700 (PDT) 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 v10 17/33] counter: stm32-timer-cnt: Add const qualifier for actions_list array Date: Fri, 19 Mar 2021 20:00:36 +0900 Message-Id: <87c00aa93ef03c058cbefefd5b8ab26ed51098f4.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110230_414557_5DF465EC X-CRM114-Status: GOOD ( 12.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Fabrice Gasnier --- 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 Fri Mar 19 11:00: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: 12150821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 218E5C433DB for ; Fri, 19 Mar 2021 11:09:08 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E9A0664F04 for ; Fri, 19 Mar 2021 11:09:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9A0664F04 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dbyAHlaoA7a0BCrn+Yr7CCAZp+1RLo/RM2bCbuYtYAo=; b=nZPly8hU1xJg4WzPmohGpALeO qTEFsIVLETYfUZeTJArktTSTHN3v+muAUQ4Y8mvwyxWI8fHR9nDt+buhq/0SE80ab2lYbQibTnhgg dmimsakxb3L3OFlc+voWeKKu4EUBRASclZQYEWQd0qxGbBtRpzK/UsF9EUdf81pRUWhk1/yXrAUO9 vws/Q21ctO071g5mGBGIkI1xUGSgWQGQFN8+YarrgWJdW1mRVrc9TPMIH50ePf8+GWkFGwAb2Ud4l ZP/lV+cDTT8QLM2DYs7Rw11ZCreRXdN6+Da6fAttu+81eqlS/IF+b/eLStmqjqQnq3YczGqu10E8f 5uVRKQmfw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCwu-007F53-KJ; Fri, 19 Mar 2021 11:05:49 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtm-007DcA-TB for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:02:37 +0000 Received: by mail-pj1-x1029.google.com with SMTP id w8so4472265pjf.4 for ; Fri, 19 Mar 2021 04:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Xk7hx4CP45xh9O1Vg232WRw4BJvrvGXGictZm1LHZcs=; b=HZpAcOUeas1WLraU3Dq/9eMHhwUFtukhTVUBh3R69NgPSTakXvsfgq8jXJs7JAlJoO +akjLu6Xku8UmH6KA78P0dp+oHuWb+4yRmiM2Z++tV7DNnahsRahOp7c8Jyms1wA5DhY u7nuSZTgDKXWgLgDNPVDR+nx6euZUMz+PmtsE1cdgCnZZJJfH3rDhxpXqSkdUN6HYhTv RSKBxu73sna8Oe65TmsY4TLk4x4ELoMUzLi14z+kQTLQed0nISJRO56gPsXCPF2wXCaN fkLmHKLDObiTYPdrF364OuHwrTUeNPLsacR0DWPpvR75J0S/VHJBqujn4W10iAgiE8Aj Iz+g== 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=Xk7hx4CP45xh9O1Vg232WRw4BJvrvGXGictZm1LHZcs=; b=HqFq2iQXSLVywYsx4Vt51/fvNP3zUGu+gs9ig1m8qn7Sq0smJVUA/W1H+Y4eACjINM k+RUUgwQs5ZjFdPk1r/AOQGpNG7D6/e4AVnoui/A2niBX1clT7m8UsQXz9RXUrFdShdL H/MYXUVsEJCezegk+G8/quWslvxSoovwjXTrlaLkIltl6SwCcNBjt4opalZnCCO8cC3s SqmObuBi5T6fzZfLIL0YU1+h0J/tReX/Y8Gq4DPrhAbPEQjLhltlAr01SGBmQvxYC2iG HvyhJS++qyWzB0KrLX3ocDOSdCbz2gA6e/cvN1nZkr8ZMefciRUs4XiEP5boG9dOCk7C NkDQ== X-Gm-Message-State: AOAM531DzCXz1PU71ESO3SGHDjRVgZXJ7myHpz37bhDYiZGW2Yby9l9e XiB4O/Sh533CbW9do6uzbeE= X-Google-Smtp-Source: ABdhPJxwxgNF0AcplgAXCJ67C6CiSsfPX+LuP3hspwX2ooclnwEh+pRgChBqYlPxefg6/SYhTNO9OA== X-Received: by 2002:a17:90a:d184:: with SMTP id fu4mr9122607pjb.236.1616151753492; Fri, 19 Mar 2021 04:02:33 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:02:33 -0700 (PDT) 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 v10 18/33] counter: Return error code on invalid modes Date: Fri, 19 Mar 2021 20:00:37 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110235_125373_3F5AEDB4 X-CRM114-Status: GOOD ( 18.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Fabrice Gasnier Acked-by: Syed Nayyar Waris --- 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 Fri Mar 19 11:00: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: 12150819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C539FC433E0 for ; Fri, 19 Mar 2021 11:08:59 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D68364F04 for ; Fri, 19 Mar 2021 11:08:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D68364F04 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lvnEgE8yP35wCC3USZ6cnIzUgY6l+Z2t67QaBzY+3f4=; b=TfJvkPyo/oFDt3MmbK8o5BHzR D6jJbEFejKZYMN6l2M8iaosQI6AndJaiq4D3qtEtf0E+rPC/ReWbuReLvJs3dmQZn4BIckD557UGn JcFZToORhI1it4lil7k8/1eDrEF2WAxIylruqGQZ2UjZsobjyiJEgKmXedJzvGcEp62t2Aj+ZTRtG zzmKiEDfUvOI5hl+gmZOu6rgdEryKWioajamOOqwSPoVEndWIBo2W92wWhwTmErVOhcmQFswTeDQD 6bGZwJbUMz9o8/p/ysb/qmqcjQTdBbwxxK+Ort+cNKdmjcB3O66gfxmFy6KxR/uIsRIhJXx7117ZV 4ImEWdjaQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCxL-007FHl-83; Fri, 19 Mar 2021 11:06:15 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtr-007Dei-WC for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:02:43 +0000 Received: by mail-pf1-x430.google.com with SMTP id y200so5626906pfb.5 for ; Fri, 19 Mar 2021 04:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zPb+gWSSK34KYiB/GIEQN8ZRP7v+HVonTQM6Ywh1zp8=; b=GbwBST6OLctHRPpje6CQQ6A0Etw7HHv1ibi/PtZt9dyNRoMGuT/crP0iLQKj+aLj6I K/IwLftAjimPHfvY9mp3porI9HYjP7YXlIOnP1uJkPtYFabbNtskz2nJXNmU/rnVqQ2x 6HKZl7I0BLC//HE9GOXCad+5TGP1HsfWiGMnmOdcxhxnFB7qLpBLLEh5OiojaBuHNPUz ARmLhaNGvylVdtTbIT0UTfCa5UdaEJ2GwiQGtRgh3J0tbKxm6RjyhHxIkhkg8psrUO0m M/WP+Jnw1swX2FmDEitAolGz7NkD0SupqG/Y9GOTNuL5ZYt1Jq2JigRVC+rrdrnu8nq9 yXxg== 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=zPb+gWSSK34KYiB/GIEQN8ZRP7v+HVonTQM6Ywh1zp8=; b=ckwVrhtbQFhQ3wysRnaEnDNbiDLWnv0fXPY04Dc/quijt9rWC028NF6OZTIOaLeRdR XNB4jUbNLp05pi04Cx5Q4aNZSCuq5nXGQUzZKnjPYPFd8Qc2N0naWSRVzRct+qdUmtQB hFz0BMaDfMxbijjX9B+LFr5G+ny6wY7dA/2/6KfHomO++ldQkyiRadj2Q2z3hNc1/TgJ sFIgj1cK2HYkueUqL+fOJDoeGh8pnf8LfoS2VuSez7qe/Jqh/dwXh9q9bzwm/gqnqT3/ BIZcqDSBirI/pK86auCcbOzoyfAF+hvy76xlnrXPLyryV9IgzkaISEpd4d9OcorQnOQ2 +ijA== X-Gm-Message-State: AOAM532M2IM7h9qzAbNvl6W+y63DdGFhTPmkXP3m//F87srRQTGdjzwe TLyH22a2lsVoa4tJbMteR7w= X-Google-Smtp-Source: ABdhPJw5U90GgbXrwB9X3j7ERBM6UKrmDzqcszz+pkiLkuNCUFc69EhY4Lrh6+GU35xS6cCocLbUcA== X-Received: by 2002:a65:520d:: with SMTP id o13mr10970910pgp.57.1616151758644; Fri, 19 Mar 2021 04:02:38 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:02:38 -0700 (PDT) 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 v10 19/33] counter: Standardize to ERANGE for limit exceeded errors Date: Fri, 19 Mar 2021 20:00:38 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110241_473065_7F7EC702 X-CRM114-Status: GOOD ( 14.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Fabrice Gasnier Acked-by: Syed Nayyar Waris --- 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 Fri Mar 19 11:00: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: 12150817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF23FC433DB for ; Fri, 19 Mar 2021 11:08:26 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 524BA64F04 for ; Fri, 19 Mar 2021 11:08:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 524BA64F04 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bsg0CSbEoijQ+ISinza3rCNoN3GDks4W7svQWP9wq0M=; b=c6Rnn71z2DWeZP7rvClESaLI2 PrtO7bw44EEc3pUQdQKoBKgV7aqEE1ozXHLVfXZMwB2XSBmTutW1v6lp3s2i4kQRxVXJlp7sz2Wfe +Y6tyW8dqslto+pe72W60rKazxQ8qmnRQBWcu2vveZQNrY4+pTrxEjXsKqizL6tTbS+HhpPgtYQ+9 SSq9+USVLd++gvNJyHXy9PvdAZWZNfNfG9OqZDdz6E4OzU3YiA9SqmWOSfrCIiHPPXRLFdWbq1yUh spjelYT9InKkCn/ZimjQKViHd6EnaiLo8ndSXfxMP7VDqT/+0XXY9AQ+oNRieXc5uk+2du1X8fljz zqPccIABA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCxn-007FTA-6j; Fri, 19 Mar 2021 11:06:43 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtw-007DgM-Rt for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:02:47 +0000 Received: by mail-pj1-x1031.google.com with SMTP id s21so4486133pjq.1 for ; Fri, 19 Mar 2021 04:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7uG25tGn2JhqwJiUclZHnqYPnHyNkYk3KKju2ZGjPnQ=; b=gHSCIIqZ2dC8Pl0KFE1gllQycw2NMiKpfuDLXHDEBdrXGnHSk5mE2tWRYnqtO6wAVl FI88PIRkBkPwMA3v9a9u5gyDi6tlIbc27dlRx4yLfj40JQu8sFSVlDecw3DX6jVLWPo6 5ypHM39Cu/yenLUqQ5hPm5/0KqEsQdxGPLOC3iRrVsHHBGlc/QIIbx48WPNMDw6iEo5S cz313ENRVAvKzrAsLepAOBCpB29r9vQCmvjONu4dVs3D+4zXntV04YPTO+bd8xxwEEd2 SJlJkGLjp6z4wGUgGzWOLPCgVTaQa5lVjHh0XFFQCmXkkJ5EUvRXFUm3ZSHLH8BxCdrV uBKw== 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=7uG25tGn2JhqwJiUclZHnqYPnHyNkYk3KKju2ZGjPnQ=; b=IAmX9rHsxGMyAvkT/iOGTcd/NyCUM0ff5B0c4XSK1U6IgiMx9OsZq6VZ+mwD4HX9Ld r5HB3cR01ttEycZNlwfgye/Yn9qo11/Dc7yUDEmM8LB1U+KSmVv2/JuEcW0eQ8E9kbsH rSSegK7e7zcROqDkYg28G7aofCvWQFym0utIGcL47OURuxOsT0GR+lbQS87DcgW0kQZl aL5WB+RQF1oCwhOldt880fib5rcx9XJJAAF7IhY2tlknEuFErzsiszX1BsQPzDZ8bHuf WyEjfEVumQ6ta795Byh3ASE/r4YGuNDGxrRAfdoJ5oN2uiQMWQ9/Pfoag9ZfCkfnZO4V MR8g== X-Gm-Message-State: AOAM5302o0PylHVUeQ3/iFg3H1UM7m6VkGodxWT9ekxSzMFHoar0RF3V 2fE/jXfYlAR4Rv8xCXw0siqlvIJqVGKUIA== X-Google-Smtp-Source: ABdhPJwB/FYVSaO/f0ehvVulIWm4eJ2TXGYTFgBRc11ItxxCmYjPVA+7MuIWmA0zT5FFS5uQjvzTQA== X-Received: by 2002:a17:90a:cca:: with SMTP id 10mr9089500pjt.103.1616151763546; Fri, 19 Mar 2021 04:02:43 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:02:43 -0700 (PDT) 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 v10 20/33] counter: Rename counter_signal_value to counter_signal_level Date: Fri, 19 Mar 2021 20:00:39 +0900 Message-Id: <33a89af04c3dbba1c9d2f97927b7c2ffcd921af9.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110245_148395_DEAEA2EB X-CRM114-Status: GOOD ( 18.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Acked-by: Syed Nayyar Waris --- 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 Fri Mar 19 11:00: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: 12150825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E659C433DB for ; Fri, 19 Mar 2021 11:10:07 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AB6FE64F53 for ; Fri, 19 Mar 2021 11:10:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB6FE64F53 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EgyyVLEPz0XXaDfkh+ET63rkUGlcRPe1SPcj8rOVTuM=; b=AAUxaFxS4O7WUR4JINzOrGzzA MjmgZzQBvV5jLHyUv4jEUX6lVX7SKm4XGzN6afoO6i8K6iPcVRtTsQQ7znvNzNurbLHQJoaCXlpTZ /CLIjFVf3mBhlL8gJkQbBHzgcEQK18vavQmZfmhw2/ieI7btRIMewU+3fseDrgqEwdyacKCK8w0WY L9Alr/dbWPKdA1OlBNw46t7Rqp7xjcKf8cTjO10Vpohr251oGfpVFHG9iurkoIZH3O8zR0l2/TNb1 aLEFh8WAasZQ9FByO8zLJYW/cYOxkibhTRs1aJP5UtI4hS/kpNU21847raQlbZDVsh1s0oaxSDee4 8sDss5oOw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCyM-007Ffp-Ue; Fri, 19 Mar 2021 11:07:19 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCu2-007DjO-4S for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:02:54 +0000 Received: by mail-pl1-x629.google.com with SMTP id f17so2787496plr.0 for ; Fri, 19 Mar 2021 04:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EdaGW4hBYsYQZG7L/6NFxLh3mGh/Uh/dq8sSdQTz50g=; b=PwTD/f/IOZ9yykZCi3yNNUA/4PRbwEPUA2lN6zBVStfY1Pm7Go1+0aj+wEnd16Nm0A ZOr7hOFErZwhms4tCfHiousPz8KAcE4MEh5jKXrHMEKOVBL09NeNhL29Epp9eraDWqpF Q6XBPLwjg/5qntdwyEQS2uM+Xi1DLYS6hyGfaG4fr+9/bUBfStl7se//4cIn4ZazZsYT b3QLTRPqTVU9duvCQRVWPihvxBUC27acnEUjc1tWPfyhZCO+E9kdh1yoxDKCa8Ik0jS0 V2mr2lAthe3nZBZ+XJJ1oBgAnAmT4fhYdY9GgbMou7Z01NCDO3QCGzX35g3SXAn4fOrN K6VQ== 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=EdaGW4hBYsYQZG7L/6NFxLh3mGh/Uh/dq8sSdQTz50g=; b=AwEAFVeoxG4NjNeFlq1INx6R2l4jJw+4ewaWufYV6xlSxaXLHjhlZhsEVJ5QeNQB1K ZdEJbEV/fokD03SOZDSd2EwMeCZh+vaQPJkcq76PNofV/zBhuX1sAvZFwU6qSaGELfVd ug4t27/rFVlxPX402XVdhDHN4mS7OWhQPVBdGAcxwMTKNrl0wxnkRvhwXreFAvaiQLkN EYT5HIq6WKCxwAYgFVzgQ+Y8nkdkOsWLwUgKZAQgwDM6sBN80mEOgbmgD2Lt9Ak1YRjR wjgBN3fbLsLXRvMOi2Nm0rqJxmiUN/CfO8CfW6cA5Zv02QbMvZel5k+kAugwJqeiRhjB 9QEw== X-Gm-Message-State: AOAM532bh6WQCnI+0IzokJk0F3pw03Rwe6b7dKEmZ/zc91jZBOJFfPzV b52Lb6LHIKHfc3OzA/SttL0= X-Google-Smtp-Source: ABdhPJxbfRYGm2aYhfytasGqvP6LxO+uc8/U1Bpqv4yFN1skWOJK8RtOMwSfSqSk1fUCOE5pE6Opgw== X-Received: by 2002:a17:902:780c:b029:e6:9193:56e2 with SMTP id p12-20020a170902780cb02900e6919356e2mr13777973pll.39.1616151768673; Fri, 19 Mar 2021 04:02:48 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:02:48 -0700 (PDT) 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 v10 21/33] counter: Rename counter_count_function to counter_function Date: Fri, 19 Mar 2021 20:00:40 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110250_781664_358EDD7B X-CRM114-Status: GOOD ( 18.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Fabrice Gasnier Acked-by: Syed Nayyar Waris --- 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 Fri Mar 19 11:00: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: 12150823 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88230C433DB for ; Fri, 19 Mar 2021 11:09:54 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B5B764F11 for ; Fri, 19 Mar 2021 11:09:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B5B764F11 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=a4PJwgp4UwYqaeQzyCc6jg4v52KljGzmQ07zPYFdwts=; b=JQ5o5NYBJy0JtkDU0oEelOu20 03q5Xz0j6/W2BpQzWsKsdoyYpOALckF546AqTfYXGsfu/b1M2qz8CzuIPwsB1gSdQPnu7E9I5AJnC zKQl7s4Rs8jM5Jwc2mXEky68pAPIb5sLojX+zUeOgbMT0+kenVkIFmvZG44zC8O72PEgwC045yzwL P/HDVqproCTuGXHtr9sY87rFxCZqH4YndPlTX8nz8+7anvKY55BJrfWj3x+2sm8Lzp0sht5iT5Trb Nlctac3DWh4+8HYuuvWSMKYBr0Yl8yzrLg8rbUzMCSZlXiEyLg6wDCi4hHnrqOC8X9HopaDXhWmI2 sn0EPuUpA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCyy-007FuU-SX; Fri, 19 Mar 2021 11:07:57 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCuD-007Dok-8m for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:03:07 +0000 Received: by mail-pl1-x629.google.com with SMTP id h20so2785246plr.4 for ; Fri, 19 Mar 2021 04:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4tcESTYG+Q+wtlieN7sDSgCHsiQUUS+79HIQLrQg5rs=; b=J21BnrqJHpV+AM7Wtm83gn7eepWxB63hJ7NockTW0xnljY4G/Q8rDxylDO/t8+EEO+ GM3TvWFbatL1Ls8O3B38cgjFhhc7XCH4XEqb/Uzmd2ecuBLpoycYdO4ssu7RnbADYIf9 8trkovvyqz4ySUKnSUwkTTDogA8MWXERP9ucFKUY6lrwWCBVDCpSjOOT3I0hg4xRbe6F CrWs/1mkVY41rBhcqnWLW0mV7OOEsODC7Zh5Ah6zG5U8JyC5vm29zUm8GWG7Rgqq54B5 9pBYbd8+V3GdGFnDT6MSgCnfo2X3AUsA+q1ObTvJsSX8TotE2MTp0ZqlB6se5LoX94ik n68w== 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=4tcESTYG+Q+wtlieN7sDSgCHsiQUUS+79HIQLrQg5rs=; b=YMspXx8D51eGI+kfl11KRy5qJxAIJFs0tMFShy4dObzi7CG+PZasxadYkPwB3nRtBW 9pjmsMr81WrHo4IoH9v0QVceZvXjermY2obHBbXPaU4KsHPPtp4ATAw4yw1TnUXC/2Kc jmpUWftPvPzwrLG4d8NR5CvmfQFInYsC6RGSUxLbit53Mjp/gophRuLipfCAV+43QRRc Wr5e+TyDmyajdCruISIyaEyBb7u2jOvac78PBjI+/KKuG4EuNNKc67NkD6OJlYNlkw5g L4hkzgqadiMj6ogLscWs41/257uNzNVOJHNTecrPose7v6CRJbMjkKinbcCyEuQNQaQK 9jDQ== X-Gm-Message-State: AOAM532fFCpDXMkG30Chg+jRmDy5fr9h41AShKJznVpRiQY/MaljBXIb 10LLC/rjGVK939IZk+1efUo= X-Google-Smtp-Source: ABdhPJwXFmip/iYe7tRt8scz59n+KTk0vY40omuBd7na3cbbvJJPI+ZzpMv7hCLc+aNA+xiRI3CFQA== X-Received: by 2002:a17:90b:228e:: with SMTP id kx14mr9250409pjb.71.1616151779954; Fri, 19 Mar 2021 04:02:59 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:02:59 -0700 (PDT) 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 v10 23/33] counter: Update counter.h comments to reflect sysfs internalization Date: Fri, 19 Mar 2021 20:00:42 +0900 Message-Id: <6cc4a2c7c16810addbb072be37022b331e3585cb.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110302_477101_38B93A02 X-CRM114-Status: GOOD ( 23.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Mar 19 11:00: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: 12150827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EE61C433DB for ; Fri, 19 Mar 2021 11:10:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E88B964F53 for ; Fri, 19 Mar 2021 11:10:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E88B964F53 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xl9d4bMjq/TFM5S/IPBkfgwuja0TjRBrJUrXiwCuvzQ=; b=fTn2EHLvmMT0T+X8zG68m+g4c nKq7VyQBTPTQjwaeo/FJW3jm8gWGQkGRfH1o/jBgOYiRu7O/diMa8lN8xqVWvfnY9VHtP/piQsIC5 p9MP7IVHYLYbySadEyiPl3RUZ62KHJZkPSjQ9tnTK/lPTwCLbVvMkpaKOCGMTvV1s5punSOHyJIaS bh40EwPfGUuorC9mbT76bBZ4N9mdSw+F6i6pWzYRrDujmL9TlPTHnXGgtqBqfL6YXR68xAqbW/b58 YM/U25kbyVqK6gWNuRJQWm6mgEg2KkS/Af6YSLCV/96LzO6+bNl7kOcOEYcHRVqq7YOuvIQoenf8x 1BRMO7RIg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCzf-007G9E-CF; Fri, 19 Mar 2021 11:08:39 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCuI-007DrZ-FX for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:03:11 +0000 Received: by mail-pf1-x431.google.com with SMTP id y5so5631745pfn.1 for ; Fri, 19 Mar 2021 04:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qv6xOBgt9KRkpYqC/ZUydayeBsZAtW7A4xuBDWMF5wM=; b=cDb6CDMZU32ztlfv7bhGyaeoQ9SeK4TXshLQxh2N+A5rT1iZNjnP+W9/JGU2Me80+i 9I5aV1CJ3qZAp3tJDGhPMqWUQfYO8EU2BN9GBfQ2PpQc3aPj7ZSISGrpVLG9cgpaV/0F +mBJr18uAovgS8W0rTCP+wbYPv72+ZWUT3ZUYkTvjL1sGMdbfR/otNksJTWQibEN8oZr 5/oyeLP4dHTJe83/0x3HbFuKUfEfOXXR9NO2p/xxFRiQoI+5ONisTUyS8YzT5AW9A7F+ 9rp5dpEnpoq6wqG6vCUj9IjL2385sSoqbGXYCsDLVHB9hk48boc6sKMUM1TmoatHdj1Q AT9A== 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=qv6xOBgt9KRkpYqC/ZUydayeBsZAtW7A4xuBDWMF5wM=; b=tIwEh3onWJ4JmJDTMwZzzN0uCG4t62lTdyphZJrGMe6R+44n9VLvKlFaVhkz/X/75Y mvlPnbjo+cCEfZqnaQPKHTUcwQbNiW41lYEVj0puN2lSaTAkSEYLffTDblLLvooezXoE E2yjasOYQ34+nZIJSx34IQSqdCVOdJdjPA5XSUpOuWpC5vUBV+Tx9xTdHrH2Bfdt1qhg Sw9IZmTmZfOrJxRPNe5WLZhZ8/zAe8GKg6V5seVonwHzISqnYURdy4yzMgU0iRU9Wizd mXsZCyzv3WyU3MfGAgS3Mwey4/Yv1KtIYpUIr1c1v+1ngXbFb9hJ3+H77aubWF1OTQ4i 5azg== X-Gm-Message-State: AOAM533VkydEMqLOT+STloN2un7U3+zlNvk21Df5W1i3s9RSYJJFs6Nc l7ZYryRu8JVozMk/1b1w5NM= X-Google-Smtp-Source: ABdhPJwQ9Gv8WbMVRmnEs4uLJ9l7GWA86p9wyi4C9g3zQ0ouHHj57ZgyfyGShGFkV5SpOYwZlU+Xqg== X-Received: by 2002:a63:7b4e:: with SMTP id k14mr10870257pgn.261.1616151784874; Fri, 19 Mar 2021 04:03:04 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:03:04 -0700 (PDT) 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 v10 24/33] docs: counter: Update to reflect sysfs internalization Date: Fri, 19 Mar 2021 20:00:43 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110308_384786_FE9E4F68 X-CRM114-Status: GOOD ( 26.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Mar 19 11:00: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: 12150829 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 684FBC433E0 for ; Fri, 19 Mar 2021 11:11:28 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CC2364F11 for ; Fri, 19 Mar 2021 11:11:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CC2364F11 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vgU1opaqT68OSK2WOcSDsl5VoR2hACLjbrMvCKT62AQ=; b=QbUPRPIMSDdOAKj6DDfXvL4Zv oCoHiNo6Gq4Q3vnyv+1cDo8VSMV6XDckFpSps7Rf0wfcJI70tHNGjXdPB5bkzP8K53Ni78RgLFxFB 0qILESV3H9urxInkgLQhrEWl7XN3rq1RuOVd2z3NuWu8+dha7sKqcxakAgCQ0P/cn0Z1HNBiM5z5n sREExrs26TnW6/EvdTgGFHm+rV6QrctkumP9HMfTOQqZZLuG0+0c5ZMtZxmjnMxF+bfraQIyXG+ed FzbACiZ4Tam0j2Xc9ud4yW8ioWZEpjLX6IfKSRlT73c8h32IJyO+XcPa8LxdBViIeTaZlz82Q3Isn 3FZBQ0MHA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lND0G-007GLA-Go; Fri, 19 Mar 2021 11:09:16 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCuN-007Du5-9G for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:03:14 +0000 Received: by mail-pj1-x1029.google.com with SMTP id x7-20020a17090a2b07b02900c0ea793940so6548092pjc.2 for ; Fri, 19 Mar 2021 04:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PpFvI7Hr2xnxZZJp2f4SLiB8ePysZG2/PXUscKLYdTM=; b=gTvA3Rk2UCYebE1TVVgbqZDlJZMGTNotD3E0b/waW/Ra43vwNvnBt/klOyNt0kSzts 09F4yWVqE7EcxuuGpuUZo4pj/f9U9LikUcKqLKUX0Ie5J91GtdPzD7W7MQNY8qChwl3o 0KrwsHAg5R5F0nOoyQ6LcAbS5UOy3mLA+27GrWScs8JnHMmGUf362wrxDjOPusXVOwJg it8pfXrUCMXKTuW3uYWe/bwqiyOJAZplC/doRHwshOCi0E1dKh2nEI2P+hbicDZzjiSf MKKJJVjpTuRfjiDkqk3azGwNdg7Ys2kSFXt+L+/gKcGMO6B1BQTKajEnwV7yWO719EF+ X2sg== 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=PpFvI7Hr2xnxZZJp2f4SLiB8ePysZG2/PXUscKLYdTM=; b=T/AXDFrAk2BLxx+nhNSdv37HOqb5V7w72giNqZlLhRVQKJUR7kS4HBO4Q+w7KWGxoO a/fWnFGGgI/8GTurSJG78ihtDu6NYqdbMR4TA2EjO3OsGxQq/kTDtqpCP4oeCUkbCe7d gSJqLL+h/h1bgBMcFkBe3TA4uGwMEczca8sC71SBDHGBtog+l47vCIzPdXOwmFWHA+rG DBNuJVRMv7UIgCynTso3PYJpvAYiwpM265NUR3hGOpvO/EqB5NG42RTOK+wK8AhrpEI0 p2ozqWX9jaTz/hnwtWRRUWKpoxpNklrePf/mrt4TRZCEuDTx0o0poesTaDNhEh8NTnZG h9Wg== X-Gm-Message-State: AOAM533eh/C8wfYTX1sky5QdSiiecQgYhDC/NkGqr/kwLKABPhKXER7c lws8vsnOxHJ/vr+ItvpcwRE= X-Google-Smtp-Source: ABdhPJzkOB8WSdT8am3pdoAQWkCp1OmHCwNZK6vBKQVREzmBLXf4IJ0tqJOZvJOQcfJVOIvrGW1/2g== X-Received: by 2002:a17:90b:e01:: with SMTP id ge1mr9498567pjb.117.1616151790035; Fri, 19 Mar 2021 04:03:10 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:03:09 -0700 (PDT) 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 v10 25/33] counter: Move counter enums to uapi header Date: Fri, 19 Mar 2021 20:00:44 +0900 Message-Id: <06e8a19be3e71b1da55c1e2813b669fcfd6bbd34.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110311_820825_A6647D06 X-CRM114-Status: GOOD ( 15.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Mar 19 11:00: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: 12150831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30A41C433E0 for ; Fri, 19 Mar 2021 11:11:56 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2D24864E45 for ; Fri, 19 Mar 2021 11:11:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D24864E45 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=H8SCU27n98VBCmhOKfk/WNjoGv4R4hHAu0PzNOvdI1Y=; b=Tc2f31GYJTJ0WAhEmoOlX/Csj hAsmCtfDwY1qgompxXT0nszoiQQJdebHpAP/n5RugfylG/5sgye2u+DK8gL3oYhssIBKsynQ7Lu/g 2qgoffwFPsluH5tv8jlHiXibateUxuKA2RP6DkiLRMhFTwZ0X4PAaHJRyVHvDmr4X9XYJQ52JrVaW 5swIZ6O+qxje/2CFAcMMdU0o/GGPU2r0IbzY/w3XSsf1tRO6VaUPfJcnfur54ZFtiUZAs8GFGTaly mKUETdHATM8cMoUV8gVw7zrRhyqzZnKJLZf7gMidmF18pGbi+y/+pT0VKy+Dv0hwl28T9QTnB9xl9 JSlsDW+/A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lND0p-007GYL-2n; Fri, 19 Mar 2021 11:09:51 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCuT-007Dwm-3O for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:03:21 +0000 Received: by mail-pl1-x635.google.com with SMTP id l1so2787279plg.12 for ; Fri, 19 Mar 2021 04:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vSQ8Ad0r9eC9lwkn1WJ+ECEK4xcwADJBID+tOsRjHxE=; b=MnwAUjh0mk4k9yAuM0LhLWGpF6NVQe31xGSLpdD3cF0c/BX0XKa1KKYF73+MjDxPhf 1wXuJ8GAeYboXXdo6kik8PPg9eUR29nGKKbAqArMz150YcDYbTvfDFcp2wvvkddD2ADc ADDtctnjkgr5YlXo8MSCXWMP8XYABFQOyHksZ3WDdky3AiKXWLltl3L6y62vw92mJucx D7Yl2KkE/vg0i4ewZbUrgspDQJ4ktaMp+65dz+8rB4CLa2if1Ibt931D54JfD6WgX58K if1Yz0FnpDKG562ddkpxYGs4ccIkfoa8b+KaoRuqYNwFSHr4hGC79m8XTK6eftzMNPEg Y7JA== 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=vSQ8Ad0r9eC9lwkn1WJ+ECEK4xcwADJBID+tOsRjHxE=; b=t58yJrH/5a/ucKnNg79zSbKGLr0GIK64Cuk8tEqQSgwEHeDWxTXpu7Y04imb+N0s4P NgFd076BFWWbuAFb/7qzb3Is2jXDJf+gPnNvgYi16w3Ki+Qqp0q33KrCHNXb7XlRf/SZ uFudZS2NzhQXhNS/UxPqb74zkEPj9x0g2LDGI1Dbdp0qYItNEKvjl7s5WTWIRLJhor8F h9wVn3Sft6HCYbX3ZQHQfdko19ERyrj+5Zu5ThS93nb4aCxIC4hKF6gn7KtiUAl/V7ck dqiqdB6MCyK7cQaOVIcyphKHX2ZxE9s4IZIHKD0sZTXEjuM81xvMHJ3YzBpja1fpdRM4 WY+A== X-Gm-Message-State: AOAM532RCCHXzln9SlAHKpxCxjB45NMGKw2OVqgHdnlnKLQFDODRQIrk mlIEKVcsj5oYdQofW4I3nrPyfhmjd9/HbA== X-Google-Smtp-Source: ABdhPJzYFC4OUqM9rYiSJKNMei6Q4rBjfPtepylvw0KDjZOmWZDJYLXZzVCZ/IloJyL7V98ftA6msg== X-Received: by 2002:a17:902:8482:b029:e6:325b:5542 with SMTP id c2-20020a1709028482b02900e6325b5542mr14050346plo.70.1616151795428; Fri, 19 Mar 2021 04:03:15 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:03:14 -0700 (PDT) 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 v10 26/33] counter: Add character device interface Date: Fri, 19 Mar 2021 20:00:45 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110317_637935_B12D827D X-CRM114-Status: GOOD ( 29.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Mar 19 11:00: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: 12150833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77468C433E6 for ; Fri, 19 Mar 2021 11:12:52 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B98164E45 for ; Fri, 19 Mar 2021 11:12:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B98164E45 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3m5BM34KLbd08XupFbyLpG1JXKGbDjyWmi5VzAI34fY=; b=QUYCoRf+oulDaC9Trgjh3q8aA J8gsRQDDTdAYvm/OzWt+fbQTh7jCt+FpRzsuYOE36QJOb2MdBeIukRXj+cmAJms/LPb5J5jcp7tse ja9OZIOUbRIhISPM/T2R5hC9Rn6wMvMcnViafAxP90VfPLpJgUvybW7Jdugdrd4o8szV6+hO5zjID DzDYUsBXbThjN3MWNnXK/vLG3Ios7kNlxFGIkE9DJ9bD9GwumBO861mcKHN+74F/LPAdLwWYY01uK I39wa1MyuUV8cz7pnzwumYcMubB/GbGlD3mt9PgIqzFaR8QxqOkpqqkIuhzqChX+aBpHyeyxTVAws 61r78PSig==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lND1R-007Gkx-4h; Fri, 19 Mar 2021 11:10:30 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCuY-007DzG-Ne for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:03:28 +0000 Received: by mail-pj1-x1034.google.com with SMTP id gb6so4487006pjb.0 for ; Fri, 19 Mar 2021 04:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qfBy20t0xI6zB3lks2ke3zCFkHNH96tCN0m1kLgEiJI=; b=agpYO6qpTp9CmQ9Ivq0mKYpB7LcRFxWNp4HeJsPnMRCskwHmsmoFhr4s2VN3q4O/LH 9nDiKDVEuI33O6JhCq+31909c3O28IDCyF+BoUT5Aau7S064/0AS7Rz4VIWH/faclpTF Kkv2Tofgo/QczyYAh6e2ZSfcrOG++ix2W5rg0fDtlOEfPTKCSzB3HXSX2vbD/rCO7MbY sl5UX8BWqBGph8knYOWZ21U+fujYNdhYITCBzR+UXgJRCzFdBZT1WgpexMAfNZ3kV0Ud F9Z1SoRjcUnX3FgtFMxXvHtMVMBjOYDrkfVHkeImobaVWWispN0O/hQPoM5OlyEdayPQ xfRw== 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=qfBy20t0xI6zB3lks2ke3zCFkHNH96tCN0m1kLgEiJI=; b=Ls9ldhJd+JnPvJ7MRD9LzarhPvf9DsbgR0ecXfPV/Gs2wYmxbpqGcuqFzgsXnP6qW5 MpCBiywz5sV6XGS4PNzKISwcpzoh0yyxTBRkz1QH947EmAzIXqx0MNB+Nk6e3nr31YHw 4951X1PT6knPQDTAyolaEwYKgfxTZKbz77RDb2XTRNDuM02qq7+JDnuZa8g+abyrB4Ed RTv2d8/5Nb7SNNBJooZxiD5v7nncp5OF6zIEcW3Y/iDph7kPybu0gROKsipR5YXDzDD/ rlfN0yR00eBGK4C/ML7ScJkOmFVwDT4GDD0Z+bJ6hVpLzkUX8V6QmNT9dC09pE1IjzvU qG+g== X-Gm-Message-State: AOAM530mdo72fJXBiHw1GxLdzTMIiscU5AxNkLOAxH2ch0jE33mruKh5 z4g4QV8yLovXWcdIo80sjg4= X-Google-Smtp-Source: ABdhPJzQhjGMekbr+F9XaDqYxgfQpKReUANW6Tjzx7xHkZeDKekLP3tQ7zyPF/5SwHiyFOpPe66Y5A== X-Received: by 2002:a17:90a:ea91:: with SMTP id h17mr9165828pjz.66.1616151800346; Fri, 19 Mar 2021 04:03:20 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:03:19 -0700 (PDT) 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 v10 27/33] docs: counter: Document character device interface Date: Fri, 19 Mar 2021 20:00:46 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110325_625835_32443C13 X-CRM114-Status: GOOD ( 23.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Mar 19 11:00:47 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: 12150835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1026AC433DB for ; Fri, 19 Mar 2021 11:13:07 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 43ACD64E45 for ; Fri, 19 Mar 2021 11:13:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 43ACD64E45 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jEd5xHo2mq1J4BEqYbTWtwe83WbX1cTEU/bQJq0p3RA=; b=K+xOMOxFXqP0VOJ4hPWWjv2Ym 8eQHg1bGykkCF9nXpBvT/iNLK+gwasGP0rRNJen6Cipvu2eZ6gwhfmOYBkZws53Up9rRMl7K6HqOK ddxVJftZy+dVw8wSFCJUaG7UxM90zEhYTA0DgU/OHUoymDTq3Wr8Fq59y4RC+Nm5q0s9NGNUDzmEN 4LTioTd3cZwcEZSbEwHvhpxKWV5gT8l1iXSEMJRkGWfRVHi6I4NAZL2dImtCalnMjf+WZxKmjQ08d bQqzg7D9Z2UaD8GhaQD5meb5Dn59PjmQx5H5VKs4BONM9VVsizWasXkG14htQKuC1pBeezVpAtQpQ qMl60JH2A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lND26-007GxT-0x; Fri, 19 Mar 2021 11:11:11 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCuc-007E0w-Vl for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:03:31 +0000 Received: by mail-pg1-x52f.google.com with SMTP id v2so3427074pgk.11 for ; Fri, 19 Mar 2021 04:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j+1g2ZB1H+Ri6g9gRzWlX42EEiO9f1zC8oGPskt/AFo=; b=gLvNrp/Y44fWlS8gP2NnjmUT3w0hb/3+RSj1Ucwx8iPeR0K0VAByOSFxNWZQ3Ly12n 68OmjfmN2PzNlyxpgH0fCfRrHwhPzgW2ZzxbzZvlMsLybLpX4bPkbbOPjBgfwaLS6sJr fng3JeGJuvhhyWgQI5dh+CiHvClObNS7YMPJBNSlFdrtFgu5f88KGraWTfO+L01IBfOu fwQYM3CpXrOhGnS01+OtUMuiNtRdrtSe4013eBxgd8qpSyRwLP0STj846O777tvbSu22 gUDXOKnRu5tY1uSscdb1e5SP02tEp1LZmIuSTT7zqHdWokkjuw1PQYrBSVcOpclBNXGZ nUYQ== 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=j+1g2ZB1H+Ri6g9gRzWlX42EEiO9f1zC8oGPskt/AFo=; b=GdkUagmix1Ov4R5sibQreRTaZXRrPHiqia/cOIU0WqY/wEeujXrt7YRYV7mhP1uVRG mkn9XYZ0BYerlKU2B7M4bQ4DAtrTMA1lZ3wX6l9rbOxyYC7Kf5CqB1Y30vR7Q0dXrJKg RrBtGU7+faCWcxXLQqtj6UQwFi3E97wwaAlE9hZVa8OqjyuwYeQF9vG8fi19oIOM+OFb 56QASqs8UVFfBZet9I8nridzzZQbdRp9tqR3asgS8FKwIRT5TPGN8MHdcpTqkQAmuxtV PcxP0xhLEN/88ov8YbMdiTp1/PaHBXUEsf6Xa7ofTJ1qbY80vBd5eBN+04/tlQ9Qgan4 EbqQ== X-Gm-Message-State: AOAM533WkRA4rLAr3uHz7nIJvBt3Iyc3ks8OsEAxjf4f0c58S6HgXAun YanxAsQJeMqHNw6brqGZujI= X-Google-Smtp-Source: ABdhPJwIGgS4HBtbLP3pNv+0exmP5Zw3LYumGfGoHJnURlknqlk36HIb/Tzj8mQky4ugkcs/pHok2w== X-Received: by 2002:a62:160c:0:b029:20a:7b41:f10f with SMTP id 12-20020a62160c0000b029020a7b41f10fmr8470459pfw.67.1616151805635; Fri, 19 Mar 2021 04:03:25 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:03:25 -0700 (PDT) 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 v10 28/33] tools/counter: Create Counter tools Date: Fri, 19 Mar 2021 20:00:47 +0900 Message-Id: <02e714df9f8cace5631f1699a488169885fe4dff.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110327_692756_11A484C6 X-CRM114-Status: GOOD ( 22.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Mar 19 11:00:48 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: 12150837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1398BC433E0 for ; Fri, 19 Mar 2021 11:14:19 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7FB5F64F69 for ; Fri, 19 Mar 2021 11:14:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FB5F64F69 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=eo0ZuzVHXgvV4jq3pgzuowxv9CnA4flS/YqBV51Hh6E=; b=jPgwe7o3spIZiq6QZQ2rjwxqL DIffoK/LGe4NiZ2JtBj4exEnNCJOnZWMwO9xtf2TAr2Bj0sef0fhCV3nBpIvsm49VqB51ONFPhSKi Gr+DbPYmwe/xj29b0RLj5EBy1kRl1vDefufo+VPdpO5g7Rp03Le9qSr8Qcw8KtT8jfvI/QtbaI8mt 5VaBUh9JKgwf3zLztjAScOuj/eULzYac+VHwcHeWMUhifzYWj/IEpFdqhuY764Yh3WclmVsf0BZ0D s3yn6GX6XnJpfYrFL6AKQwC5oQ0Z0aCtdJ+wn25SjFr3iIh4tZUxNB1FnatAdDny7N6i83ICRYHHx +SLRGq8xg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lND2m-007HAY-1N; Fri, 19 Mar 2021 11:11:54 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCui-007E4u-2P for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:03:35 +0000 Received: by mail-pj1-x1030.google.com with SMTP id lr1-20020a17090b4b81b02900ea0a3f38c1so8319363pjb.0 for ; Fri, 19 Mar 2021 04:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HvvZ2pFbiubk/RaFwxqoeYMzhVunEOAm5oGM3eeUGTQ=; b=QJV7fv95tRRdF9dMz2rMqAh3PXAvZhzETCESyHORpq7x8zaFNohYd+hcP9fOE5yOWq lk90CY0uPOLq9ALlpUjAcKv8rVibRlqvUd9Kn/fP93rV8PAANO23klH6qn3imFYw1LGx nj0Khb283VbK6JHmRMPXFkvFvt68CivKVNdq3emh26UT1e3bSM3KdoMaswBNbOTfh52Q 83x9/PX6yL0I/N/MwcdzPKlHyK26Z/AWQrWrr4g9rpjtJ5Zk3/raOkkKPI/maZ9E6lVT eSngc/ZSbSYu0q30HqpIGgiPzLxrbV+hs53seao99ATGuNJSvJ4hyp2xiX0OQ2hQxBrp Taow== 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=HvvZ2pFbiubk/RaFwxqoeYMzhVunEOAm5oGM3eeUGTQ=; b=uBcONL+gwvDa6P8wdcsVy/tlguqBdDtO4l3kr/INEC9fOuLWna+wWRnIjSW7STvzSI vD86IgRGG1BcYw49nIN9LrdtPsJlmU5qtsbetV8DvZUfuFbazDsFJUa+AmMotMXA/cK/ rR/7is/ofmshObRt/Q3sBa6muiWRU6oQQJv4aQYA9b8W5PsMNHE+sTp3h2euIfYR146b utDfxrHxcRHtV9mzG+nQcaaxi3ARO9aOWzxfQPA74AWVvImlgm7SOyOV0qEHDkVUsm2w a54La5LfiNMaRKohWFmPxAz/iL9rsVsSbd1cWIzmNdIWzA/DDYrZzMelBLPaiSKgAWfC mMbQ== X-Gm-Message-State: AOAM530bLFB0hGkBlFNN58iJU/knqdqjM1z6XcSCcv/+68zXug77lK5l 9HNG2oCn3TiAnBKW8OkgSM4= X-Google-Smtp-Source: ABdhPJySR2eEoe+Yo+Lcvmnooi8jbrWZVxfL4eFoFxMkwGBmYvLZpUrXyf+N23OZ20WvIBCDGS3XPQ== X-Received: by 2002:a17:90b:4c0a:: with SMTP id na10mr9561896pjb.227.1616151810858; Fri, 19 Mar 2021 04:03:30 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:03:30 -0700 (PDT) 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 v10 29/33] counter: Implement signalZ_action_component_id sysfs attribute Date: Fri, 19 Mar 2021 20:00:48 +0900 Message-Id: <699de2bee70cbcdbafd7ba652849fc3cf77b0e34.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110332_733041_20DD509B X-CRM114-Status: GOOD ( 14.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 07588130600a..bb49a10f160b 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 sprintf(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 Fri Mar 19 11:00:49 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: 12150839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08FCEC433DB for ; Fri, 19 Mar 2021 11:14:50 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5A1AC64F69 for ; Fri, 19 Mar 2021 11:14:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5A1AC64F69 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JNBQ9c6xRGinwYh9vr6Blh+Up4nPNqPBZIfUSwpuG8o=; b=Ixub/eCfZx8SR40JHHSQZspVR NiKvpOE0NAKv7n7xqRaXKa9D4So3NzRyY4KQ35VCdlLYeFXpmJVIwzea5LgFznVz8+KZpvZ7mmmwI gmxfStELdED0iBScnHIaSz5hD7tbkN7Ml8kBH9mIwDh6VjHrhqsJDSvZeKXun7UB6hYYeMCDdXwle /6llq5nQKEORIXg57ISQxx9OPd/1Kp1oI66zu8JuzLQdgANBtDC2pDHtmi1XYRNgAO6Yo7aJ8h6Yg llda0r+IlE8rfU1NvTFLbsuX0ZHCumNK9TVjuCYLhLWYlqiupBOpSXEeugq63ljD9di4NA9qstE1S rRF5odNOA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lND3V-007HOT-Kx; Fri, 19 Mar 2021 11:12:37 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCun-007E7n-1y for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:03:40 +0000 Received: by mail-pj1-x1034.google.com with SMTP id s21so4487363pjq.1 for ; Fri, 19 Mar 2021 04:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l2ypzjt3l7Y0nIjnP32LrmztjmBKkmNybVvXBUFclWg=; b=Ct5N0zQwwau/wFdCMsBwcHx1SW2FTrRIOW9OPaAmlHY5nydVmUDy08Y3Ml5h2iOfit oSu2GBts/Ri6XmgryW8IM2g+OetTNE9VCy71AvC/ub8lupKGxUepkRm7skL448rzW6MF 73XkXJUGuidut0R0t0bt8sql5E/PGhkoGYgVyVbUOQSev7bSWXL+5kduKRGquWMRQ0B1 lbC749z6pnw7yszCynIE+0ql+qt0h8x3XfAdoBv1ercGzmPePUnkgesWKsp8EeVwwQEo zqBPvhT5Bg8ahCQfZyueyx2cim8zre+oTyMUEwVY3Tzqd4G59i6JXEaRVjPyxxV/87tc ZySA== 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=l2ypzjt3l7Y0nIjnP32LrmztjmBKkmNybVvXBUFclWg=; b=hBoqTYzzednwwiHf6T643PQ0HZlqa3oufLO+XeSpEkN4bb5XHODHSDB8jSTW6qfKrT a4aOx4MYgANpcjPpjVCuNj/U6mmq7wdB+2XqYVEo14BcPEUNrR4ektoA21Wpw8aC9be0 F7yIm5AYWojTWryLII0W2UD40tynncX9t+Z4QPPacZ2SZaX1Bhf8inpUHvmPTX7VXcXS 16DIEHn9q/4yHb0pkpndpiZzV9IU0KJ4OTq0ACXJ6X9Gl0Z+NIR90qUvUEuHKMAEjobi WoyWY8BQs/GkVH9QyzQT5FC1HEcTIag2CIUaFoGH1sMFh6ee47DjSaUZcB5Qn2s4y6eb PL2w== X-Gm-Message-State: AOAM5335dYKVGfbz5hfctqn3O6q9OrgljhbiijJ7yHjPB1zQ2jAjAfm9 WGtW5Fl6HHCgiGbL0xWVf9A= X-Google-Smtp-Source: ABdhPJwiIe+r6Tkd9+7/IUbMKDsG3DSeVMkRjTdmJFeGvVrhXtld2ODT29zmT+P84/yQzi4GOJOLqQ== X-Received: by 2002:a17:902:8bcb:b029:e6:a4a1:9d7e with SMTP id r11-20020a1709028bcbb02900e6a4a19d7emr13796290plo.25.1616151815779; Fri, 19 Mar 2021 04:03:35 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:03:35 -0700 (PDT) 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 v10 30/33] counter: Implement *_component_id sysfs attributes Date: Fri, 19 Mar 2021 20:00:49 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110338_038229_780A739C X-CRM114-Status: GOOD ( 14.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 bb49a10f160b..eb1505bfbd89 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 Fri Mar 19 11:00:50 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: 12150841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D16C2C433E0 for ; Fri, 19 Mar 2021 11:15:17 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2023464F53 for ; Fri, 19 Mar 2021 11:15:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2023464F53 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MlDeMqturIM/9ZvhfV17+I8u1A8rbHIEE7TwEvNnBS0=; b=kb3yw5XbvN92HxGPNVM1L0EE3 0RbPRx0aeKHOXpXZXla2TZnsF2Q2TEA1PNHU6v2dH6irT7nY39B2cSIMKbUTbrppN6ulGViuYtcCz K00SgP+g6zj6/YgbgeNlMSXz+4c+CCXkIs8dtnDrK5vqbqljBNM3vrwfNJPQDEA3A5sc02MeVDGDy ZiB6C2DXKq9PyqMhm6ZpJpp2GPgaJYKrn+bLWoxaaYms+kMxT4Ij6wAgbTx0Fl/cJxMRuh8hQOvmK STA4r4xJq4KTzpcZDfYnl5aGl5qbYXzVcht7fj8V3cIFzHw4EuT+V8iiSFp2Qu9mLJrnQ5DrKCVmE IwiSmcR+Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lND4A-007HZu-2W; Fri, 19 Mar 2021 11:13:19 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCus-007EAs-6T for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:03:45 +0000 Received: by mail-pl1-x633.google.com with SMTP id ay2so2785012plb.3 for ; Fri, 19 Mar 2021 04:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JO7Cai/fdh2OG/2z/jEAyOqlk0B+zcvIGOo1ydjYrlU=; b=kzohCOpglxzV1kXC5qUGQUCvk+GCMlVbLjAYPRxqjYKEnGWoZgizl0k1YyUa8BEQUm Vz27/RFavf8ytskVlz1c+hFyg2r1KKKCE1RuApeQ4syWoidHMGpb6wrCnd/B/74wZRAX IJen0AjcLDzHyJZ4X5g/O/RNnwz6Sm4aM1IVdNjYHnV0F9WZF12O8RRfgqH9qlq2Z3wF H4ZpjcDX2D7fN+X/9V/5Ty/zC1uXIpOUGuUpBXqA+Wq0Jy6oLye/YUduvJMnS0LvQ34U 9gl2RIwFT8UFfx+lT71pNuBBtQcIPOxyyzD6uxSC0l1tB2cLKWkh3Ksfs+rxpqWgDdDT 8WDw== 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=JO7Cai/fdh2OG/2z/jEAyOqlk0B+zcvIGOo1ydjYrlU=; b=ZyQHuquccHyMUIPs+6AQxmGhe1u6SBqWLcccTEdJhLSqUqKCKaZaR7azf+rhnWCQdm RGWmIqWhlqvZ9kp13irvdiVNigMuyE7q8dnhWdx8KpVjuOgdCwvNs+g5h/rAQs9VEv35 7IUwI0yslUpjCqWYo0f6qH2nbD2rWQjKn+yTx9V6Zbruge+bQymSwg0n9qbjMjZ4uXgX j2TDnZRGVKg6yQ47n185KK89xmThc5DLVU42JmC3Y3nnoJD8GanL0TMwi9IdAqA/TzPB RJoBVAZzCV/BFpG3DaLE2y8y/PoriQDCVAiCc1OOxxRTZgpJ1bFe0Kmhkn6OWW7Aa0HD MPdA== X-Gm-Message-State: AOAM530NYPuK9vdbPLCJLPW4zdRzy+XWcnfnJiABv6Rq2FqkhN72oDkn hWRxsy3DM2opAM7X3szXkMM= X-Google-Smtp-Source: ABdhPJz/8DhQcL5BjAJcQ8VSJhxHchRYFNHupxXC1o8o1XvpJ+QtmSHQLzfC4Pwzh7JdRBppgFQfMQ== X-Received: by 2002:a17:902:24d:b029:e3:cfa7:e308 with SMTP id 71-20020a170902024db02900e3cfa7e308mr13764417plc.82.1616151820840; Fri, 19 Mar 2021 04:03:40 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:03:40 -0700 (PDT) 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 v10 31/33] counter: Implement events_queue_size sysfs attribute Date: Fri, 19 Mar 2021 20:00:50 +0900 Message-Id: <052410b645d7c2ce47f78540cfa93ebad489c1df.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110342_834610_E356B0E1 X-CRM114-Status: GOOD ( 21.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 eb1505bfbd89..bf038eff4587 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 Fri Mar 19 11:00:51 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: 12150843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5D27C433DB for ; Fri, 19 Mar 2021 11:16:14 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2FD6764F6C for ; Fri, 19 Mar 2021 11:16:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FD6764F6C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=iThnHW5oh6kNWFOdjW4znrZysCuNpHzgEhw3sfEGqBw=; b=In3xNAdGtWnhdWCDmmQq29OG6 Zec5JEynF3lh1lJcPbQsY9cqQqufJWmqZEkd3YN/pOGDHIetVYW4UgtQPF7WOjzeCoTX8/tES6Vw5 62e+1WtZ2gioWQn6UDjExT1HvTexpOtMzloR2Z+wwZVjvmS0PekWyE2+z2PwRDxOkIggdkYaxrH8M 2Q2Zwxz/H7EF/4ZXzzcSZKV0teYZwVrfNvpBJ+FymtN5oDHh09ZC2fT7s8P/h1ciuhMcxs3u5ATmb tLNk2CrMQoHdyJryMB4cyPTF2L0lcNtpQE1MG3TX/b5ra8mu/N/S3zbYRXKDlmUJsVtI83pi87MLy rE6/eePjg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lND4y-007How-Vt; Fri, 19 Mar 2021 11:14:11 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCux-007EDK-3s for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:03:53 +0000 Received: by mail-pj1-x1029.google.com with SMTP id cl21-20020a17090af695b02900c61ac0f0e9so8303669pjb.1 for ; Fri, 19 Mar 2021 04:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bnr3nxKzCXX2teamhMKHsrHLZQg+RvaFqb+8NBtz+g0=; b=ONQ1EfmCsggbuatwu2Al09Qw7DWmqPTUz7i0LUvxTsFGIFMOJdbmi//5T8vxftN8Kk 8In2A/ACRd6XPfR5KtxECyKP83RrUcmyPq+vTvy+KTg5jH6o97dJIGbD/+sBrO1ee155 7tq+/kWGsn3nf9yode7H0HdmhdQofZ6x5+S11RiCMkQ7CtGEofijW2+VKBulZRts7SfA 0UZ8IGPTgLkemK5mmoymPvOPdEoWh1D9yinumlc+1kJH07CekzeyGq28bB64c4isa5IC DNKs7wvWYn2j7gnThtTqUNMwWaX0lMuMVJ9dkZnrvCY3O5ZlNx3VcqnvIaMM9+mc7JnC 6aSw== 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=Bnr3nxKzCXX2teamhMKHsrHLZQg+RvaFqb+8NBtz+g0=; b=DAGo1MZFDr4QoHdf/t84LCeDJFbtN6mILVOMFu0ndwE24J2ZvdvQ2QfoEYDMUogV2A zfbTf2RiQChecP19dlcbMRUlrrms7D620/uLAcruUuM+thFCuNvmH8zzrwymJbEAibX2 I9yqsW0qTupMmiTOaA6zU6zHS9x/uSm6P64PBSFuhlDzeMUqRfYQgywmK0qdCmZEa/fc BoBJPHMn4nQ3tB3tIzxlQQIQ4o1kzfgh22DDMOMh0wVA4pUm/A7N/mfyATlMZcyhXQ5t pD8oNkcaLt8o4qqB3QiB9jN8JV6hiDrC6ESW8Cxnoh3LpCiGHn8xXzS2zaEY8jtcMJkz o4LQ== X-Gm-Message-State: AOAM530+3OL9BdeRmPdwIpM1tNqFlidgKvVhTZJ5ErULFgeGZSWeY3Bp Kd0IIMuGsMc/aJMg6SUy1WQ= X-Google-Smtp-Source: ABdhPJyciwuVESkzQty0MYJJFuLzCsQIKej8/IdadGHDuZY3dD+ZvyUk7yb/PbMZ10THXAT/ceUUrA== X-Received: by 2002:a17:90b:1007:: with SMTP id gm7mr9266147pjb.17.1616151825686; Fri, 19 Mar 2021 04:03:45 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:03:45 -0700 (PDT) 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 v10 32/33] counter: 104-quad-8: Replace mutex with spinlock Date: Fri, 19 Mar 2021 20:00:51 +0900 Message-Id: <52016584522ed9b733cd52057f6974c274e34003.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110347_435703_8447B92E X-CRM114-Status: GOOD ( 18.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Acked-by: Syed Nayyar Waris --- 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 Fri Mar 19 11:00:52 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: 12150847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6313AC433DB for ; Fri, 19 Mar 2021 11:17:02 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EBBA864F53 for ; Fri, 19 Mar 2021 11:17:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBBA864F53 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SIhow+EpyA8Wl1OqsWO/jsw13kszw+2RyWtD6637KGQ=; b=V8bUq3qcJMACDa/ir+YAb/pYR Zw5cxiOdTVIHQRXBKuZoD3x5rBvaWyEL6nXUkCDzYSbsMEI3PlbUnbza6L/QSvvVhPg5J3Dac9hGx QvJP9klBz+NmsAtfHE3Q6z7ffOEoxWa6YYoLLJaPq3cxNK8dZTQjqizQnpzn+g00XuBFA/oxnif/l wugm/jwMimb1wphd6RO+TeGO+7L+9Stg9iV9UCjG4yfkUUotR38jnkJChBoVfPMwd/D9+xk/3pY/2 HZLqO5fFfES9/stIYW/PxllftgJhAfr+QhB9QCUpz2ykD1G6aANlnTWghNgbMMLBAwmRhl0s4UOK2 iL8vhQpMA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lND5e-007I3a-8A; Fri, 19 Mar 2021 11:14:50 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCv2-007EFQ-3l for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:03:58 +0000 Received: by mail-pj1-x102e.google.com with SMTP id lr1-20020a17090b4b81b02900ea0a3f38c1so8319638pjb.0 for ; Fri, 19 Mar 2021 04:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DFYjuegOGbgHgYqxs5GI1KnJ54NWCzese+od+Fnc8YA=; b=jp+ASD1Y8cbrAI9TdrsgIv89huqPP06f+wod69gyZkhRk7AicBVWQyjnZmOD74bqOg itDfDXiRgCl92Jnm5lNezcoFlExTbYL5SROhwlN1FY5apXu8rSSgblyyH8E9i9hiDFii MHFSWdDYHPJvrEmtIULdSBNALbHliqj2m4CaNxx3KFmPT6O7NQa68ACq1AoqrhJld2Pi gqDMiZg90h0RgkFuyLFHtxVmfLlgjM035QfNOb/zM147/M//UFOoS5P2bPy+Xno0zwIg ybexdTPo7B+/APiGnh5TC+5VFGicjholq/O1TdehE9euzZCuNnb7aRt9s5P6tH+h+xMD 9KmQ== 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=DFYjuegOGbgHgYqxs5GI1KnJ54NWCzese+od+Fnc8YA=; b=R/7l084gGHAeJ5vlReZ2tkXm25bbsj94WgAxDt8ZtkfxhgO0cSWpDQOWdEKNmpC7ay BHSZlXHQlir7uE11Lp42XNV+iMMESNN2vB9rrfjyORaa+nyUqKI+EKqyb0kVq4ddtPsl m6uj5S6DxMhEJG5lp73o+K6VSyw8xaGbDnj4C60AdA0WBm2CGdj5dd0pTLAWaBj5p/ew 3j1RLtSJQJNUTs91LJo71gNTBc/XqIgvpgDUpjO5IVQUM7YpdKTcJdXwmR1b337keQBS odWK0BdGjuDNvxjll/0TdP7Bye7xl5GQ/ap/NjRpijMWv2lh8KO2W2L5jQYgb8zYhEro d8Og== X-Gm-Message-State: AOAM530KaXuXJTkrooKiUhq10Tcu5ivoGVkXiY5FLGSyBoTNGiF98jtf M3OiyoyR5Mb2Vbq/AFsr2AE= X-Google-Smtp-Source: ABdhPJzlzkf76EUu1+dlV5gYt/3d6NqNxpwvsEkonssFkaTvEQAfnq7RJkbE7rnjbkKVaSe2ojmFDw== X-Received: by 2002:a17:90b:4b08:: with SMTP id lx8mr8970434pjb.135.1616151830554; Fri, 19 Mar 2021 04:03:50 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:03:50 -0700 (PDT) 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 v10 33/33] counter: 104-quad-8: Add IRQ support for the ACCES 104-QUAD-8 Date: Fri, 19 Mar 2021 20:00:52 +0900 Message-Id: <24f0eacf6d2e320c2ed1bc20e07a6e723da75737.1616150619.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110354_273103_652EECD6 X-CRM114-Status: GOOD ( 27.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Acked-by: Syed Nayyar Waris --- 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"