From: William Breathitt Gray <wbg@kernel.org>
To: "Bence Csókás" <csokas.bence@prolan.hu>
Cc: linux-arm-kernel@lists.infradead.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org,
Kamel Bouhara <kamel.bouhara@bootlin.com>
Subject: Re: [PATCH v6 2/3] counter: microchip-tcb-capture: Add IRQ handling
Date: Tue, 4 Mar 2025 16:02:00 +0900 [thread overview]
Message-ID: <Z8alaOTjZeRuXnUI@ishi> (raw)
In-Reply-To: <20250227144023.64530-3-csokas.bence@prolan.hu>
[-- Attachment #1: Type: text/plain, Size: 2549 bytes --]
On Thu, Feb 27, 2025 at 03:40:19PM +0100, Bence Csókás wrote:
> Add interrupt servicing to allow userspace to wait for the following events:
Hi Bence,
This is a nitpick but keep the commit description with a maximum of 75
characters per line so we don't have formatting issues with how they
wrap.
> @@ -378,6 +444,15 @@ static int mchp_tc_probe(struct platform_device *pdev)
> counter->num_signals = ARRAY_SIZE(mchp_tc_count_signals);
> counter->signals = mchp_tc_count_signals;
>
> + priv->irq = of_irq_get(np->parent, 0);
> + if (priv->irq == -EPROBE_DEFER)
> + return -EPROBE_DEFER;
In theory, the error code could be something else if of_irq_get() failed
for any other reason. Handle all those error cases at once by checking
IS_ERR(priv->irq) rather than just -EPROBE_DEFER. Then you can just
return dev_err_probe() with priv->irq for the error code.
> diff --git a/include/uapi/linux/counter/microchip-tcb-capture.h b/include/uapi/linux/counter/microchip-tcb-capture.h
> index 7bda5fdef19b..ee72f1463594 100644
> --- a/include/uapi/linux/counter/microchip-tcb-capture.h
> +++ b/include/uapi/linux/counter/microchip-tcb-capture.h
> @@ -12,6 +12,17 @@
> * Count 0
> * \__ Synapse 0 -- Signal 0 (Channel A, i.e. TIOA)
> * \__ Synapse 1 -- Signal 1 (Channel B, i.e. TIOB)
> + *
> + * It also supports the following events:
> + *
> + * Channel 0:
> + * - CV register changed
> + * - CV overflowed
> + * - RA captured
> + * Channel 1:
> + * - RB captured
> + * Channel 2:
> + * - RC compare triggered
> */
>
> enum counter_mchp_signals {
> @@ -19,4 +30,11 @@ enum counter_mchp_signals {
> COUNTER_MCHP_SIG_TIOB,
> };
>
> +enum counter_mchp_event_channels {
> + COUNTER_MCHP_EVCHN_CV = 0,
> + COUNTER_MCHP_EVCHN_RA = 0,
> + COUNTER_MCHP_EVCHN_RB,
> + COUNTER_MCHP_EVCHN_RC,
> +};
These would be better as preprocessor defines in case we need to
introduce new events to channel 1 or 2 in the future. That would allow
us to insert new events easily to existing channels without having to
worry about its actual position in an enum list.
One additional benefit is if we do end up introducing more Counts for
the module. In that situation we would have multiple CV and RA/RB/RC per
Counter device, but we can easily define a preprocessor macro to
calculate the channel offset given the Count index. However, with enum
structure we would have to manually add and maintain redundant defines
for each Count, which is far less ideal.
William Breathitt Gray
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2025-03-04 7:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-27 14:40 [PATCH v6 0/3] microchip-tcb-capture: Add Capture, Compare, Overflow etc. events Bence Csókás
2025-02-27 14:40 ` [PATCH v6 1/3] include: uapi: counter: Add microchip-tcb-capture.h Bence Csókás
2025-03-04 9:51 ` William Breathitt Gray
2025-03-04 11:14 ` Csókás Bence
2025-03-04 11:54 ` William Breathitt Gray
2025-02-27 14:40 ` [PATCH v6 2/3] counter: microchip-tcb-capture: Add IRQ handling Bence Csókás
2025-03-04 7:02 ` William Breathitt Gray [this message]
2025-03-04 9:57 ` Csókás Bence
2025-03-04 10:18 ` William Breathitt Gray
2025-02-27 14:40 ` [PATCH v6 3/3] counter: microchip-tcb-capture: Add capture extensions for registers RA/RB Bence Csókás
2025-03-04 7:47 ` William Breathitt Gray
2025-03-04 10:03 ` Csókás Bence
2025-03-04 10:21 ` William Breathitt Gray
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z8alaOTjZeRuXnUI@ishi \
--to=wbg@kernel.org \
--cc=csokas.bence@prolan.hu \
--cc=kamel.bouhara@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).