mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-17 07:54:54 +08:00
spi: axi-spi-engine: small cleanups
Merge series from David Lechner <dlechner@baylibre.com>: This series contains a few small cleanups to the axi-spi-engine driver, mostly suggested from previous reviews.
This commit is contained in:
commit
0f1a277b3d
@ -12,6 +12,7 @@
|
||||
#include <linux/io.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/overflow.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/spi/spi.h>
|
||||
|
||||
@ -75,15 +76,13 @@
|
||||
|
||||
struct spi_engine_program {
|
||||
unsigned int length;
|
||||
uint16_t instructions[];
|
||||
uint16_t instructions[] __counted_by(length);
|
||||
};
|
||||
|
||||
/**
|
||||
* struct spi_engine_message_state - SPI engine per-message state
|
||||
*/
|
||||
struct spi_engine_message_state {
|
||||
/** @p: Instructions for executing this message. */
|
||||
struct spi_engine_program *p;
|
||||
/** @cmd_length: Number of elements in cmd_buf array. */
|
||||
unsigned cmd_length;
|
||||
/** @cmd_buf: Array of commands not yet written to CMD FIFO. */
|
||||
@ -117,9 +116,10 @@ struct spi_engine {
|
||||
static void spi_engine_program_add_cmd(struct spi_engine_program *p,
|
||||
bool dry, uint16_t cmd)
|
||||
{
|
||||
if (!dry)
|
||||
p->instructions[p->length] = cmd;
|
||||
p->length++;
|
||||
|
||||
if (!dry)
|
||||
p->instructions[p->length - 1] = cmd;
|
||||
}
|
||||
|
||||
static unsigned int spi_engine_get_config(struct spi_device *spi)
|
||||
@ -503,15 +503,13 @@ static irqreturn_t spi_engine_irq(int irq, void *devid)
|
||||
static int spi_engine_optimize_message(struct spi_message *msg)
|
||||
{
|
||||
struct spi_engine_program p_dry, *p;
|
||||
size_t size;
|
||||
|
||||
spi_engine_precompile_message(msg);
|
||||
|
||||
p_dry.length = 0;
|
||||
spi_engine_compile_message(msg, true, &p_dry);
|
||||
|
||||
size = sizeof(*p->instructions) * (p_dry.length + 1);
|
||||
p = kzalloc(sizeof(*p) + size, GFP_KERNEL);
|
||||
p = kzalloc(struct_size(p, instructions, p_dry.length + 1), GFP_KERNEL);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -543,7 +541,6 @@ static int spi_engine_transfer_one_message(struct spi_controller *host,
|
||||
|
||||
/* reinitialize message state for this transfer */
|
||||
memset(st, 0, sizeof(*st));
|
||||
st->p = p;
|
||||
st->cmd_buf = p->instructions;
|
||||
st->cmd_length = p->length;
|
||||
msg->state = st;
|
||||
|
Loading…
Reference in New Issue
Block a user