diff options
author | Mario Six | 2018-01-15 11:08:35 +0100 |
---|---|---|
committer | Jagan Teki | 2018-01-24 12:04:07 +0530 |
commit | 547bcc3d18ddcc107b8aa7ca393830590c27978f (patch) | |
tree | 29f4441013ce209db23b38cea001a36d86d268cc /drivers/spi | |
parent | 13129064161c1e90cb6f9e53c9501dc98a1f3c2e (diff) |
spi: Fix style violation and improve code
This patch fixes a printf specifier style violation, reduces the scope
of a variable, and turns a void pointer that is used with pointer
arithmetic into a u8 pointer.
Signed-off-by: Mario Six <mario.six@gdsys.cc>
Reviewed-by: Jagan Teki <jagan@openedev.com>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 7d81fbd7f8f..dea8dcda5b0 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -12,7 +12,7 @@ int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen) { if (wordlen == 0 || wordlen > 32) { - printf("spi: invalid wordlen %d\n", wordlen); + printf("spi: invalid wordlen %u\n", wordlen); return -1; } @@ -24,11 +24,12 @@ int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen) void *spi_do_alloc_slave(int offset, int size, unsigned int bus, unsigned int cs) { - struct spi_slave *slave; - void *ptr; + u8 *ptr; ptr = malloc(size); if (ptr) { + struct spi_slave *slave; + memset(ptr, '\0', size); slave = (struct spi_slave *)(ptr + offset); slave->bus = bus; |