spi: add devm_spi_optimize_message() helper
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@baylibre.com> Link: https://patch.msgid.link/20240621-devm_spi_optimize_message-v1-2-3f9dcba6e95e@baylibre.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
9b894d65e9
commit
d4a0055fdc
@ -464,6 +464,7 @@ SLAVE DMA ENGINE
|
|||||||
SPI
|
SPI
|
||||||
devm_spi_alloc_master()
|
devm_spi_alloc_master()
|
||||||
devm_spi_alloc_slave()
|
devm_spi_alloc_slave()
|
||||||
|
devm_spi_optimize_message()
|
||||||
devm_spi_register_controller()
|
devm_spi_register_controller()
|
||||||
devm_spi_register_host()
|
devm_spi_register_host()
|
||||||
devm_spi_register_target()
|
devm_spi_register_target()
|
||||||
|
@ -4378,6 +4378,33 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
|
|||||||
return ctlr->transfer(spi, 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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spi_async - asynchronous SPI transfer
|
* spi_async - asynchronous SPI transfer
|
||||||
* @spi: device with which data will be exchanged
|
* @spi: device with which data will be exchanged
|
||||||
|
@ -1268,6 +1268,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 int spi_optimize_message(struct spi_device *spi, struct spi_message *msg);
|
||||||
extern void spi_unoptimize_message(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_setup(struct spi_device *spi);
|
||||||
extern int spi_async(struct spi_device *spi, struct spi_message *message);
|
extern int spi_async(struct spi_device *spi, struct spi_message *message);
|
||||||
|
Loading…
Reference in New Issue
Block a user