提交 49ddedf3 编写于 作者: M Martin Sperl 提交者: Mark Brown

spi: add spi_message_init_no_memset to avoid zeroing the spi_message

In the spi_loopback_test driver there is the need to initialize
a spi_message that is filled with values from a static structure.

Applying spi_message_init to such a prefilled structure results in
all the settings getting reset to zero, which is not what we want.
Copying each field of spi_message separately instead always includes
the risk that some new fields have not been implemented in the copying
code.

So here we introduce a version of spi_message_init called
spi_message_init_no_memset that does not fill the structure
with zero first, but only initializes the relevant list_heads.
Signed-off-by: NMartin Sperl <kernel@martin.sperl.org>
Signed-off-by: NMark Brown <broonie@kernel.org>
上级 8005c49d
...@@ -762,10 +762,15 @@ struct spi_message { ...@@ -762,10 +762,15 @@ struct spi_message {
void *state; void *state;
}; };
static inline void spi_message_init_no_memset(struct spi_message *m)
{
INIT_LIST_HEAD(&m->transfers);
}
static inline void spi_message_init(struct spi_message *m) static inline void spi_message_init(struct spi_message *m)
{ {
memset(m, 0, sizeof *m); memset(m, 0, sizeof *m);
INIT_LIST_HEAD(&m->transfers); spi_message_init_no_memset(m);
} }
static inline void static inline void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册