Linux SPI subsystem development
 help / color / mirror / Atom feed
* [PATCH] spi: offload: check for match callback when a trigger is being registered
@ 2025-04-18 17:55 Andres Urian Florez
  2025-04-18 19:49 ` David Lechner
  0 siblings, 1 reply; 5+ messages in thread
From: Andres Urian Florez @ 2025-04-18 17:55 UTC (permalink / raw)
  To: dlechner, broonie; +Cc: Andres Urian Florez, skhan, linux-spi

Make match a required callback when a new trigger is being registered,
this allows that other functions like spi_offload_trigger_get() could
safelly invoke the callback when it is required

Signed-off-by: Andres Urian Florez <andres.emb.sys@gmail.com>
---
 drivers/spi/spi-offload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-offload.c b/drivers/spi/spi-offload.c
index 6bad042fe437..6f4c5188e6ad 100644
--- a/drivers/spi/spi-offload.c
+++ b/drivers/spi/spi-offload.c
@@ -434,7 +434,7 @@ int devm_spi_offload_trigger_register(struct device *dev,
 {
 	struct spi_offload_trigger *trigger;
 
-	if (!info->fwnode || !info->ops)
+	if (!info->fwnode || !(info->ops && info->ops->match))
 		return -EINVAL;
 
 	trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] spi: offload: check for match callback when a trigger is being registered
  2025-04-18 17:55 Andres Urian Florez
@ 2025-04-18 19:49 ` David Lechner
  2025-04-18 21:52   ` Andres Urian
  0 siblings, 1 reply; 5+ messages in thread
From: David Lechner @ 2025-04-18 19:49 UTC (permalink / raw)
  To: Andres Urian Florez, broonie; +Cc: skhan, linux-spi

On 4/18/25 12:55 PM, Andres Urian Florez wrote:
> Make match a required callback when a new trigger is being registered,
> this allows that other functions like spi_offload_trigger_get() could
> safelly invoke the callback when it is required

s/safelly/safely/

> 
> Signed-off-by: Andres Urian Florez <andres.emb.sys@gmail.com>
> ---
>  drivers/spi/spi-offload.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-offload.c b/drivers/spi/spi-offload.c
> index 6bad042fe437..6f4c5188e6ad 100644
> --- a/drivers/spi/spi-offload.c
> +++ b/drivers/spi/spi-offload.c
> @@ -434,7 +434,7 @@ int devm_spi_offload_trigger_register(struct device *dev,
>  {
>  	struct spi_offload_trigger *trigger;
>  
> -	if (!info->fwnode || !info->ops)
> +	if (!info->fwnode || !(info->ops && info->ops->match))

IMHO, this would be easier to read and understand as:

	if (!info->fwnode || !info->ops || !info->ops->match)

>  		return -EINVAL;
>  
>  	trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] spi: offload: check for match callback when a trigger is being registered
  2025-04-18 19:49 ` David Lechner
@ 2025-04-18 21:52   ` Andres Urian
  0 siblings, 0 replies; 5+ messages in thread
From: Andres Urian @ 2025-04-18 21:52 UTC (permalink / raw)
  To: David Lechner; +Cc: broonie, skhan, linux-spi

On Fri, Apr 18, 2025 at 2:49 PM David Lechner <dlechner@baylibre.com> wrote:
>
> On 4/18/25 12:55 PM, Andres Urian Florez wrote:
> > Make match a required callback when a new trigger is being registered,
> > this allows that other functions like spi_offload_trigger_get() could
> > safelly invoke the callback when it is required
>
> s/safelly/safely/
>
> >
> > Signed-off-by: Andres Urian Florez <andres.emb.sys@gmail.com>
> > ---
> >  drivers/spi/spi-offload.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/spi/spi-offload.c b/drivers/spi/spi-offload.c
> > index 6bad042fe437..6f4c5188e6ad 100644
> > --- a/drivers/spi/spi-offload.c
> > +++ b/drivers/spi/spi-offload.c
> > @@ -434,7 +434,7 @@ int devm_spi_offload_trigger_register(struct device *dev,
> >  {
> >       struct spi_offload_trigger *trigger;
> >
> > -     if (!info->fwnode || !info->ops)
> > +     if (!info->fwnode || !(info->ops && info->ops->match))
>
> IMHO, this would be easier to read and understand as:
>
>         if (!info->fwnode || !info->ops || !info->ops->match)
>
> >               return -EINVAL;
> >

> >       trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
>

Right, I will apply your recommendation.
Thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] spi: offload: check for match callback when a trigger is being registered
@ 2025-04-18 22:39 Andres Urian Florez
  2025-04-18 22:42 ` Andres Urian
  0 siblings, 1 reply; 5+ messages in thread
From: Andres Urian Florez @ 2025-04-18 22:39 UTC (permalink / raw)
  To: dlechner, broonie; +Cc: Andres Urian Florez, skhan, linux-spi

Make match a required callback when a new trigger is being registered,
this allows that other functions like spi_offload_trigger_get() could
safely invoke the callback when it is required

In v2:
- improve readability of the condition

Signed-off-by: Andres Urian Florez <andres.emb.sys@gmail.com>
---
 drivers/spi/spi-offload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-offload.c b/drivers/spi/spi-offload.c
index 6bad042fe437..21a0f3a3a176 100644
--- a/drivers/spi/spi-offload.c
+++ b/drivers/spi/spi-offload.c
@@ -434,7 +434,7 @@ int devm_spi_offload_trigger_register(struct device *dev,
 {
 	struct spi_offload_trigger *trigger;
 
-	if (!info->fwnode || !info->ops)
+	if (!info->fwnode || !info->ops || !info->ops->match)
 		return -EINVAL;
 
 	trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] spi: offload: check for match callback when a trigger is being registered
  2025-04-18 22:39 [PATCH] spi: offload: check for match callback when a trigger is being registered Andres Urian Florez
@ 2025-04-18 22:42 ` Andres Urian
  0 siblings, 0 replies; 5+ messages in thread
From: Andres Urian @ 2025-04-18 22:42 UTC (permalink / raw)
  To: dlechner, broonie; +Cc: skhan, linux-spi

On Fri, Apr 18, 2025 at 5:39 PM Andres Urian Florez
<andres.emb.sys@gmail.com> wrote:
>
> Make match a required callback when a new trigger is being registered,
> this allows that other functions like spi_offload_trigger_get() could
> safely invoke the callback when it is required
>
> In v2:
> - improve readability of the condition
>
> Signed-off-by: Andres Urian Florez <andres.emb.sys@gmail.com>
> ---
>  drivers/spi/spi-offload.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-offload.c b/drivers/spi/spi-offload.c
> index 6bad042fe437..21a0f3a3a176 100644
> --- a/drivers/spi/spi-offload.c
> +++ b/drivers/spi/spi-offload.c
> @@ -434,7 +434,7 @@ int devm_spi_offload_trigger_register(struct device *dev,
>  {
>         struct spi_offload_trigger *trigger;
>
> -       if (!info->fwnode || !info->ops)
> +       if (!info->fwnode || !info->ops || !info->ops->match)
>                 return -EINVAL;
>
>         trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
> --
> 2.43.0
>

Sorry, I sent the patch incorrectly

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-18 22:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-18 22:39 [PATCH] spi: offload: check for match callback when a trigger is being registered Andres Urian Florez
2025-04-18 22:42 ` Andres Urian
  -- strict thread matches above, loose matches on Subject: below --
2025-04-18 17:55 Andres Urian Florez
2025-04-18 19:49 ` David Lechner
2025-04-18 21:52   ` Andres Urian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox