]> git.sur5r.net Git - u-boot/commitdiff
spi: Fix style violation and improve code
authorMario Six <mario.six@gdsys.cc>
Mon, 15 Jan 2018 10:08:35 +0000 (11:08 +0100)
committerJagan Teki <jagan@amarulasolutions.com>
Wed, 24 Jan 2018 06:34:07 +0000 (12:04 +0530)
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>
drivers/spi/spi.c

index 7d81fbd7f8f52c31dd9503241e721c9ec8ce6bd8..dea8dcda5b08bd0875aa98551376184f08fc2735 100644 (file)
@@ -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;