[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241125212955.6d5748b5@jic23-huawei>
Date: Mon, 25 Nov 2024 21:29:55 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: David Lechner <dlechner@...libre.com>
Cc: Mark Brown <broonie@...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>, 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 v5 01/16] spi: add basic support for SPI offloading
On Sun, 24 Nov 2024 12:01:23 -0600
David Lechner <dlechner@...libre.com> wrote:
> On 11/24/24 10:32 AM, Jonathan Cameron wrote:
> > On Fri, 15 Nov 2024 14:18:40 -0600
> > David Lechner <dlechner@...libre.com> wrote:
> >
> >> Add the basic infrastructure to support SPI offload providers and
> >> consumers.
> >>
>
> ...
>
> >> + resource = kzalloc(sizeof(*resource), GFP_KERNEL);
> >> + if (!resource)
> >> + return ERR_PTR(-ENOMEM);
> >> +
> >> + resource->controller = spi->controller;
> >> + resource->offload = spi->controller->get_offload(spi, config);
> >> + ret = PTR_ERR_OR_ZERO(resource->offload);
> >> + if (ret) {
> > Why not simply
> > if (IS_ERR(resource->offload) {
> > kfree(resource);
> > return resource->offload;
> > }
> >> + kfree(resource);
> >> + return ERR_PTR(ret);
> >> + }
>
> Hmm... maybe somewhere along the way ret was being checked again
> after this, but doesn't to be the case anymore.
>
> >> +
> >> + ret = devm_add_action_or_reset(dev, spi_offload_put, resource);
> >> + if (ret)
> >> + return ERR_PTR(ret);
> >> +
> >> + return resource->offload;
> >> +}
> >> +EXPORT_SYMBOL_GPL(devm_spi_offload_get);
> >
> >> diff --git a/include/linux/spi/spi-offload.h b/include/linux/spi/spi-offload.h
> >> new file mode 100644
> >> index 000000000000..81b115fc89bf
> >> --- /dev/null
> >> +++ b/include/linux/spi/spi-offload.h
> >
> >> +
> >> +MODULE_IMPORT_NS(SPI_OFFLOAD);
> >
> > This is rarely done in headers. (only pwm.h does it I think)
> > I'd push it down into code that uses this.
>
> Yes, it was Uwe that suggested that I put it in the header. :-)
>
> Are there any unwanted side effects of having it in the header?
Reviewer surprise?
:)
Up to Mark as he gets to enjoy this code for ever.
>
> >
> > It might be worth splitting the header into a spi-offload-provider.h
> > and spi-offload-consumer.h with a common spi-offload-types.h included
> > by both.
> >
Powered by blists - more mailing lists