lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240624204424.6a91a5e4@jic23-huawei>
Date: Mon, 24 Jun 2024 20:44:24 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: David Lechner <dlechner@...libre.com>
Cc: Mark Brown <broonie@...nel.org>, Michael Hennerich
 <michael.hennerich@...log.com>, Nuno Sá <nuno.sa@...log.com>,
 Marcelo Schmitt <marcelo.schmitt@...log.com>, Jonathan Corbet
 <corbet@....net>, linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-spi@...r.kernel.org, linux-iio@...r.kernel.org
Subject: Re: [PATCH 2/3] spi: add devm_spi_optimize_message() helper

On Fri, 21 Jun 2024 15:51:31 -0500
David Lechner <dlechner@...libre.com> wrote:

> This adds a new helper function devm_spi_optimize_message() that
> automatically registers spi_unoptimize_message() to be called
> when the device is removed.
> 
> Signed-off-by: David Lechner <dlechner@...libre.com>
The new function can be called from modules and doesn't have an
EXPORT_SYMBOL_GPL()

I failed to spot this but a build test immediately noticed!

Jonathan

> ---
>  Documentation/driver-api/driver-model/devres.rst |  1 +
>  drivers/spi/spi.c                                | 27 ++++++++++++++++++++++++
>  include/linux/spi/spi.h                          |  2 ++
>  3 files changed, 30 insertions(+)
> 
> diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst
> index a1c17bcae68d..ac9ee7441887 100644
> --- a/Documentation/driver-api/driver-model/devres.rst
> +++ b/Documentation/driver-api/driver-model/devres.rst
> @@ -464,6 +464,7 @@ SLAVE DMA ENGINE
>  SPI
>    devm_spi_alloc_master()
>    devm_spi_alloc_slave()
> +  devm_spi_optimize_message()
>    devm_spi_register_controller()
>    devm_spi_register_host()
>    devm_spi_register_target()
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 54cbe652a4df..3f953504244b 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -4358,6 +4358,33 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
>  	return ctlr->transfer(spi, message);
>  }
>  
> +static void devm_spi_unoptimize_message(void *msg)
> +{
> +	spi_unoptimize_message(msg);
> +}
> +
> +/**
> + * devm_spi_optimize_message - managed version of spi_optimize_message()
> + * @dev: the device that manages @msg (usually @spi->dev)
> + * @spi: the device that will be used for the message
> + * @msg: the message to optimize
> + * Return: zero on success, else a negative error code
> + *
> + * spi_unoptimize_message() will automatically be called when the device is
> + * removed.
> + */
> +int devm_spi_optimize_message(struct device *dev, struct spi_device *spi,
> +			      struct spi_message *msg)
> +{
> +	int ret;
> +
> +	ret = spi_optimize_message(spi, msg);
> +	if (ret)
> +		return ret;
> +
> +	return devm_add_action_or_reset(dev, devm_spi_unoptimize_message, msg);
> +}
Missing an export.

> +
>  /**
>   * spi_async - asynchronous SPI transfer
>   * @spi: device with which data will be exchanged
> diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
> index 85785bcd20c1..a9388714e7e7 100644
> --- a/include/linux/spi/spi.h
> +++ b/include/linux/spi/spi.h
> @@ -1272,6 +1272,8 @@ static inline void spi_message_free(struct spi_message *m)
>  
>  extern int spi_optimize_message(struct spi_device *spi, struct spi_message *msg);
>  extern void spi_unoptimize_message(struct spi_message *msg);
> +extern int devm_spi_optimize_message(struct device *dev, struct spi_device *spi,
> +				     struct spi_message *msg);
>  
>  extern int spi_setup(struct spi_device *spi);
>  extern int spi_async(struct spi_device *spi, struct spi_message *message);
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ