[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <85184d56-b0c5-449a-9b69-cd141b186d6f@baylibre.com>
Date: Fri, 25 Oct 2024 11:28:49 -0500
From: David Lechner <dlechner@...libre.com>
To: Nuno Sá <noname.nuno@...il.com>,
Mark Brown <broonie@...nel.org>, Jonathan Cameron <jic23@...nel.org>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Nuno Sá
<nuno.sa@...log.com>, Uwe Kleine-König <ukleinek@...nel.org>
Cc: Michael Hennerich <Michael.Hennerich@...log.com>,
Lars-Peter Clausen <lars@...afoo.de>, David Jander <david@...tonic.nl>,
Martin Sperl <kernel@...tin.sperl.org>, linux-spi@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-iio@...r.kernel.org, linux-pwm@...r.kernel.org
Subject: Re: [PATCH RFC v4 06/15] spi: offload-trigger: add PWM trigger driver
On 10/25/24 7:07 AM, Nuno Sá wrote:
> Hi David,
>
> Looks mostly good... Just one minor comments from me.
>
> On Wed, 2024-10-23 at 15:59 -0500, David Lechner wrote:
>> Add a new driver for a generic PWM trigger for SPI offloads.
>>
>> Signed-off-by: David Lechner <dlechner@...libre.com>
>> ---
>>
...
>> +static bool spi_offload_trigger_pwm_match(void *priv,
>> + enum spi_offload_trigger_type type,
>> + u64 *args, u32 nargs)
>> +{
>> + if (nargs)
>> + return false;
>> +
>> + return type == SPI_OFFLOAD_TRIGGER_PERIODIC;
>
> Hmm will we ever be in a place where a trigger provide might have multiple types? If
> so, then I'm mostly fine with this match() callback. But we could still avoid it if
> we use a bitmask for trigger types and having any trigger provider to give the
> supported types. Then the core could pretty much do the match between the requested
> trigger type and what the provider supports.
We will still need some callback though to handle drivers that use
phandle args.
>
>> +}
>> +
>> +static int spi_offload_trigger_pwm_validate(void *priv,
>> + struct spi_offload_trigger_config
>> *config)
>> +{
>> + struct spi_offload_trigger_pwm_state *st = priv;
>> + struct spi_offload_trigger_periodic *periodic = &config->periodic;
>> + struct pwm_waveform wf = { };
>> + int ret;
>> +
>> + if (config->type != SPI_OFFLOAD_TRIGGER_PERIODIC)
>> + return -EINVAL;
>
> Checking the above every time seems redundant to me. We should match it once during
> the trigger request and then just use that trigger type. Otherwise I'm not seeing the
> point of the match() callback.
>
Here it is validating struct spi_offload_trigger_config has the right
type, which is needed before we can safely trust that the correct
union member was used in that struct. So it has a different purpose from
the match check.
Powered by blists - more mailing lists