]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/spi/fsl_espi.c
upgrade to upstream version 2013.07
[karo-tx-uboot.git] / drivers / spi / fsl_espi.c
index f872cd84f6e7e17e6655f00eedbdcd3b795c8943..fc0a58be2998381198e4b9411a42a20d9cda6f44 100644 (file)
@@ -4,20 +4,7 @@
  * Copyright 2010-2011 Freescale Semiconductor, Inc.
  * Author: Mingkai Hu (Mingkai.hu@freescale.com)
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -79,12 +66,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
        if (!spi_cs_is_valid(bus, cs))
                return NULL;
 
-       fsl = malloc(sizeof(struct fsl_spi_slave));
+       fsl = spi_alloc_slave(struct fsl_spi_slave, bus, cs);
        if (!fsl)
                return NULL;
 
-       fsl->slave.bus = bus;
-       fsl->slave.cs = cs;
        fsl->mode = mode;
        fsl->max_transfer_length = ESPI_MAX_DATA_TRANSFER_LEN;
 
@@ -97,8 +82,8 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
                pm = spibrg / (max_hz * 16 * 2);
                if (pm > 16) {
                        pm = 16;
-                       debug("Requested speed is too low: %d Hz, "
-                               "%d Hz is used.\n", max_hz, spibrg / (32 * 16));
+                       debug("Requested speed is too low: %d Hz, %ld Hz "
+                               "is used.\n", max_hz, spibrg / (32 * 16));
                }
        } else
                pm = spibrg / (max_hz * 2);
@@ -216,10 +201,8 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out,
                        return 1;
                }
                memcpy(buffer, cmd_buf, cmd_len);
-               if (cmd_len != 1) {
-                       if (data_in == NULL)
-                               memcpy(buffer + cmd_len, data_out, data_len);
-               }
+               if (data_in == NULL)
+                       memcpy(buffer + cmd_len, data_out, data_len);
                break;
        case SPI_XFER_BEGIN | SPI_XFER_END:
                len = data_len;
@@ -234,7 +217,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out,
                break;
        }
 
-       debug("spi_xfer: slave %u:%u dout %08X(%08x) din %08X(%08x) len %u\n",
+       debug("spi_xfer: slave %u:%u dout %08X(%p) din %08X(%p) len %u\n",
              slave->bus, slave->cs, *(uint *) dout,
              dout, *(uint *) din, din, len);