[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8dc22c7a-f1d2-483e-8b69-cb5dc494feae@baylibre.com>
Date: Tue, 17 Dec 2024 09:35:59 -0600
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>
Cc: Uwe Kleine-König <ukleinek@...nel.org>,
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,
Jonathan Cameron <Jonathan.Cameron@...wei.com>
Subject: Re: [PATCH v6 02/17] spi: offload: add support for hardware triggers
On 12/17/24 5:30 AM, Nuno Sá wrote:
> On Wed, 2024-12-11 at 14:54 -0600, David Lechner wrote:
>> Extend SPI offloading to support hardware triggers.
>>
...
>> +static struct spi_offload_trigger
>> +*spi_offload_trigger_get(enum spi_offload_trigger_type type,
>> + struct fwnode_reference_args *args)
>> +{
>> + struct spi_offload_trigger *trigger;
>> + bool match = false;
>> + int ret;
>> +
>> + guard(mutex)(&spi_offload_triggers_lock);
>> +
>> + list_for_each_entry(trigger, &spi_offload_triggers, list) {
>> + if (trigger->fwnode != args->fwnode)
>> + continue;
>> +
>> + match = trigger->ops->match(trigger, type, args->args, args-
>>> nargs);
>> + if (match)
>> + break;
>> + }
>> +
>> + if (!match)
>> + return ERR_PTR(-EPROBE_DEFER);
>> +
>> + guard(mutex)(&trigger->lock);
>> +
>> + if (!trigger->ops)
>> + return ERR_PTR(-ENODEV);
>> +
>> + if (trigger->ops->request) {
>> + ret = trigger->ops->request(trigger, type, args->args, args-
>>> nargs);
>> + if (ret)
>> + return ERR_PTR(ret);
>> + }
>> +
>> + kref_get(&trigger->ref);
>
> maybe try_module_get() would also make sense...
Even if a module had more than one trigger? Or do you mean
in addition to the kref_get()?
>
>> +
>> + return trigger;
>> +}
>> +
>> +/**
>> + * devm_spi_offload_trigger_get() - Get an offload trigger instance
>> + * @dev: Device for devm purposes.
>> + * @offload: Offload instance connected to a trigger.
>> + * @type: Trigger type to get.
>> + *
>> + * Return: Offload trigger instance or error on failure.
>> + */
>> +struct spi_offload_trigger
>> +*devm_spi_offload_trigger_get(struct device *dev,
>> + struct spi_offload *offload,
>> + enum spi_offload_trigger_type type)
>> +{
>> + struct spi_offload_trigger *trigger;
>> + struct fwnode_reference_args args;
>> + int ret;
>> +
>> + ret = fwnode_property_get_reference_args(dev_fwnode(offload-
>>> provider_dev),
>> + "trigger-sources",
>> + "#trigger-source-cells", 0,
>> 0,
>> + &args);
>
> I guess at some point we can add these to fwlinks?
>
Yes. Although we'll need to investigate how it would affect
leds since they use the same binding. So perhaps we can save
that for later since the rest of this series seems ready now.
Powered by blists - more mailing lists