Furquan Shaikh (furquan@google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17682
-gerrit
commit 27d44e5ba5618970acd83dd9f65871c59036a1f6 Author: Furquan Shaikh furquan@chromium.org Date: Wed Nov 30 04:34:22 2016 -0800
spi: Fix parameter types for spi functions
1. Use size_t instead of unsigned int for bytes_out and bytes_in. 2. Use const attribute for spi_slave structure passed into xfer, claim bus and release bus functions.
BUG=chrome-os-partner:59832 BRANCH=None TEST=Compiles successfully
Change-Id: Ie70b3520b51c42d750f907892545510c6058f85a Signed-off-by: Furquan Shaikh furquan@chromium.org --- src/drivers/spi/spi_flash.c | 4 ++-- src/drivers/spi/tpm/tpm.c | 10 +++++----- src/include/spi-generic.h | 13 ++++++------- src/soc/broadcom/cygnus/spi.c | 8 ++++---- src/soc/imgtec/pistachio/spi.c | 22 +++++++++++----------- src/soc/intel/apollolake/spi.c | 8 ++++---- src/soc/intel/baytrail/spi.c | 8 ++++---- src/soc/intel/braswell/spi.c | 8 ++++---- src/soc/intel/broadwell/spi.c | 8 ++++---- src/soc/intel/fsp_baytrail/spi.c | 8 ++++---- src/soc/intel/fsp_broadwell_de/spi.c | 8 ++++---- src/soc/intel/skylake/flash_controller.c | 8 ++++---- src/soc/marvell/armada38x/spi.c | 14 +++++++------- src/soc/marvell/bg4cd/spi.c | 8 ++++---- src/soc/mediatek/mt8173/spi.c | 16 ++++++++-------- src/soc/nvidia/tegra124/spi.c | 10 +++++----- src/soc/nvidia/tegra210/spi.c | 14 +++++++------- src/soc/qualcomm/ipq40xx/include/soc/spi.h | 2 +- src/soc/qualcomm/ipq40xx/spi.c | 10 +++++----- src/soc/qualcomm/ipq806x/include/soc/spi.h | 2 +- src/soc/qualcomm/ipq806x/spi.c | 8 ++++---- src/soc/rockchip/common/spi.c | 30 +++++++++++++++--------------- src/soc/samsung/exynos5420/spi.c | 20 ++++++++++---------- src/southbridge/amd/agesa/hudson/spi.c | 10 +++++----- src/southbridge/amd/cimx/sb800/spi.c | 10 +++++----- src/southbridge/amd/sb700/spi.c | 10 +++++----- src/southbridge/amd/sb700/spi.h | 4 ++-- src/southbridge/intel/common/spi.c | 8 ++++---- src/southbridge/intel/fsp_rangeley/spi.c | 8 ++++---- 29 files changed, 148 insertions(+), 149 deletions(-)
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index b2fdab9..b6d535a 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -48,8 +48,8 @@ static void spi_flash_addr(u32 addr, u8 *cmd) * FIXME: This really should be abstracted better, but that will * require overhauling the entire SPI infrastructure. */ -static int do_spi_flash_cmd(struct spi_slave *spi, const void *dout, - unsigned int bytes_out, void *din, unsigned int bytes_in) +static int do_spi_flash_cmd(const struct spi_slave *spi, const void *dout, + size_t bytes_out, void *din, size_t bytes_in) { int ret = 1;
diff --git a/src/drivers/spi/tpm/tpm.c b/src/drivers/spi/tpm/tpm.c index 9651ea8..d364cb9 100644 --- a/src/drivers/spi/tpm/tpm.c +++ b/src/drivers/spi/tpm/tpm.c @@ -37,11 +37,11 @@ /* SPI Interface descriptor used by the driver. */ struct tpm_spi_if { struct spi_slave *slave; - int (*cs_assert)(struct spi_slave *slave); - void (*cs_deassert)(struct spi_slave *slave); - int (*xfer)(struct spi_slave *slave, const void *dout, - unsigned bytesout, void *din, - unsigned bytesin); + int (*cs_assert)(const struct spi_slave *slave); + void (*cs_deassert)(const struct spi_slave *slave); + int (*xfer)(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, + size_t bytesin); };
/* Use the common SPI driver wrapper as the interface callbacks. */ diff --git a/src/include/spi-generic.h b/src/include/spi-generic.h index 347ec3c..7c53611 100644 --- a/src/include/spi-generic.h +++ b/src/include/spi-generic.h @@ -17,6 +17,7 @@ #define _SPI_GENERIC_H_
#include <stdint.h> +#include <stddef.h>
/* Controller-specific definitions: */
@@ -67,7 +68,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs); * Returns: 0 if the bus was claimed successfully, or a negative value * if it wasn't. */ -int spi_claim_bus(struct spi_slave *slave); +int spi_claim_bus(const struct spi_slave *slave);
/*----------------------------------------------------------------------- * Release the SPI bus @@ -78,7 +79,7 @@ int spi_claim_bus(struct spi_slave *slave); * * slave: The SPI slave */ -void spi_release_bus(struct spi_slave *slave); +void spi_release_bus(const struct spi_slave *slave);
/*----------------------------------------------------------------------- * SPI transfer @@ -92,10 +93,8 @@ void spi_release_bus(struct spi_slave *slave); * * Returns: 0 on success, not 0 on failure */ -int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytesout, - void *din, unsigned int bytesin); - - +int spi_xfer(const struct spi_slave *slave, const void *dout, size_t bytesout, + void *din, size_t bytesin);
unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len);
@@ -108,7 +107,7 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len); * * TODO: This function probably shouldn't be inlined. */ -static inline int spi_w8r8(struct spi_slave *slave, unsigned char byte) +static inline int spi_w8r8(const struct spi_slave *slave, unsigned char byte) { unsigned char dout[2]; unsigned char din[2]; diff --git a/src/soc/broadcom/cygnus/spi.c b/src/soc/broadcom/cygnus/spi.c index d7c0a8d..13b6976 100644 --- a/src/soc/broadcom/cygnus/spi.c +++ b/src/soc/broadcom/cygnus/spi.c @@ -156,7 +156,7 @@ static int mspi_enable(struct qspi_priv *priv) return 0; }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { struct qspi_priv *priv = to_qspi_slave(slave);
@@ -175,7 +175,7 @@ int spi_claim_bus(struct spi_slave *slave) return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { struct qspi_priv *priv = to_qspi_slave(slave);
@@ -189,8 +189,8 @@ void spi_release_bus(struct spi_slave *slave) #define RXRAM_8B(p, i) (REG_RD((p)->reg + MSPI_RXRAM_REG + \ ((((i) << 1) + 1) << 2)) & 0xff)
-int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytesout, - void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, size_t bytesout, + void *din, size_t bytesin) { struct qspi_priv *priv = to_qspi_slave(slave); const u8 *tx = (const u8 *)dout; diff --git a/src/soc/imgtec/pistachio/spi.c b/src/soc/imgtec/pistachio/spi.c index 2b4b01c..307aec9 100644 --- a/src/soc/imgtec/pistachio/spi.c +++ b/src/soc/imgtec/pistachio/spi.c @@ -60,7 +60,7 @@ static int wait_status(u32 reg, u32 shift) }
/* Transmitter function. Fills TX FIFO with data before enabling SPIM */ -static int transmitdata(struct spi_slave *slave, u8 *buffer, u32 size) +static int transmitdata(const struct spi_slave *slave, u8 *buffer, u32 size) { u32 blocksize, base, write_data; int ret; @@ -97,7 +97,7 @@ static int transmitdata(struct spi_slave *slave, u8 *buffer, u32 size) }
/* Receiver function */ -static int receivedata(struct spi_slave *slave, u8 *buffer, u32 size) +static int receivedata(const struct spi_slave *slave, u8 *buffer, u32 size) { u32 read_data, base; int ret; @@ -141,7 +141,7 @@ static int receivedata(struct spi_slave *slave, u8 *buffer, u32 size) }
/* Sets port parameters in port state register. */ -static void setparams(struct spi_slave *slave, u32 port, +static void setparams(const struct spi_slave *slave, u32 port, struct spim_device_parameters *params) { u32 spim_parameters, port_state, base; @@ -247,7 +247,7 @@ static u32 control_reg_setup(struct spim_buffer *first, }
/* Checks the given buffer information */ -static int check_buffers(struct spi_slave *slave, struct spim_buffer *first, +static int check_buffers(const struct spi_slave *slave, struct spim_buffer *first, struct spim_buffer *second){
if (!(container_of(slave, struct img_spi_slave, slave)->initialised)) @@ -325,7 +325,7 @@ static int check_device_params(struct spim_device_parameters *pdev_param) }
/* Function that carries out read/write operations */ -static int spim_io(struct spi_slave *slave, struct spim_buffer *first, +static int spim_io(const struct spi_slave *slave, struct spim_buffer *first, struct spim_buffer *second) { u32 reg, base; @@ -459,7 +459,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs) }
/* Claim the bus and prepare it for communication */ -int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { int ret; struct img_spi_slave *img_slave; @@ -490,7 +490,7 @@ int spi_claim_bus(struct spi_slave *slave) }
/* Release the SPI bus */ -void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { struct img_spi_slave *img_slave;
@@ -508,8 +508,8 @@ void spi_release_bus(struct spi_slave *slave) }
/* SPI transfer */ -static int do_spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +static int do_spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { struct spim_buffer buff_0; struct spim_buffer buff_1; @@ -532,8 +532,8 @@ static int do_spi_xfer(struct spi_slave *slave, const void *dout, return spim_io(slave, &buff_0, (dout && din) ? &buff_1 : NULL); }
-int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytesout, - void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, size_t bytesout, + void *din, size_t bytesin) { unsigned int in_sz, out_sz; int ret; diff --git a/src/soc/intel/apollolake/spi.c b/src/soc/intel/apollolake/spi.c index eab3a12..6e873f4 100644 --- a/src/soc/intel/apollolake/spi.c +++ b/src/soc/intel/apollolake/spi.c @@ -184,8 +184,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return MIN(buf_len, SPIBAR_FDATA_FIFO_SIZE); }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { printk(BIOS_DEBUG, "NOT IMPLEMENTED: %s() !!!\n", __func__); return E_NOT_IMPLEMENTED; @@ -215,13 +215,13 @@ void spi_init(void) pci_write_config32(ctx->pci_dev, SPIBAR_BIOS_CONTROL, bios_ctl); }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { /* There's nothing we need to to here. */ return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { /* No magic needed here. */ } diff --git a/src/soc/intel/baytrail/spi.c b/src/soc/intel/baytrail/spi.c index 1f2b285..13f8806 100644 --- a/src/soc/intel/baytrail/spi.c +++ b/src/soc/intel/baytrail/spi.c @@ -317,13 +317,13 @@ static void spi_init_cb(void *unused)
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ } @@ -489,8 +489,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return min(cntlr.databytes, buf_len); }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { uint16_t control; int16_t opcode_index; diff --git a/src/soc/intel/braswell/spi.c b/src/soc/intel/braswell/spi.c index 01f2150..34e031b 100644 --- a/src/soc/intel/braswell/spi.c +++ b/src/soc/intel/braswell/spi.c @@ -296,13 +296,13 @@ static void spi_init_cb(void *unused)
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ } @@ -470,8 +470,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return min(cntlr.databytes, buf_len); }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { uint16_t control; int16_t opcode_index; diff --git a/src/soc/intel/broadwell/spi.c b/src/soc/intel/broadwell/spi.c index c7ac09c..6aa7dd3 100644 --- a/src/soc/intel/broadwell/spi.c +++ b/src/soc/intel/broadwell/spi.c @@ -313,13 +313,13 @@ static void spi_init_cb(void *unused)
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ } @@ -485,8 +485,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return min(cntlr.databytes, buf_len); }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { uint16_t control; int16_t opcode_index; diff --git a/src/soc/intel/fsp_baytrail/spi.c b/src/soc/intel/fsp_baytrail/spi.c index 1ab73f3..232366c 100644 --- a/src/soc/intel/fsp_baytrail/spi.c +++ b/src/soc/intel/fsp_baytrail/spi.c @@ -297,13 +297,13 @@ void spi_init(void) cntlr.preop = &ich9_spi->preop; }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ } @@ -469,8 +469,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return min(cntlr.databytes, buf_len); }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { uint16_t control; int16_t opcode_index; diff --git a/src/soc/intel/fsp_broadwell_de/spi.c b/src/soc/intel/fsp_broadwell_de/spi.c index 116001f..c38fbce 100644 --- a/src/soc/intel/fsp_broadwell_de/spi.c +++ b/src/soc/intel/fsp_broadwell_de/spi.c @@ -312,13 +312,13 @@ void spi_init(void) pci_write_config_byte(dev, 0xdc, bios_cntl | 0x1); }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ } @@ -484,8 +484,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return min(cntlr.databytes, buf_len); }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { uint16_t control; int16_t opcode_index; diff --git a/src/soc/intel/skylake/flash_controller.c b/src/soc/intel/skylake/flash_controller.c index cc6c20a..8aee796 100644 --- a/src/soc/intel/skylake/flash_controller.c +++ b/src/soc/intel/skylake/flash_controller.c @@ -151,8 +151,8 @@ static size_t spi_get_flash_size(pch_spi_regs *spi_bar) return size; }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { /* TODO: Define xfer for hardware sequencing. */ return -1; @@ -170,13 +170,13 @@ void spi_init(void) pci_write_config_byte(dev, SPIBAR_BIOS_CNTL, bios_cntl); }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { /* Handled by PCH automatically. */ return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { /* Handled by PCH automatically. */ } diff --git a/src/soc/marvell/armada38x/spi.c b/src/soc/marvell/armada38x/spi.c index 6a0e062..af0a279 100644 --- a/src/soc/marvell/armada38x/spi.c +++ b/src/soc/marvell/armada38x/spi.c @@ -409,8 +409,8 @@ int mv_spi_8bit_data_tx_rx(unsigned char spi_id, return MV_OK; }
-static int mrvl_spi_xfer(struct spi_slave *slave, - unsigned int bitlen, +static int mrvl_spi_xfer(const struct spi_slave *slave, + size_t bitlen, const void *dout, void *din) { @@ -454,14 +454,14 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs) return slave; }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { mv_spi_cs_set(slave->bus, slave->cs); mv_spi_cs_assert(slave->bus); return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { mv_spi_cs_deassert(slave->bus); } @@ -471,11 +471,11 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return buf_len; }
-int spi_xfer(struct spi_slave *slave, +int spi_xfer(const struct spi_slave *slave, const void *dout, - unsigned out_bytes, + size_t out_bytes, void *din, - unsigned in_bytes) + size_t in_bytes) { int ret = -1;
diff --git a/src/soc/marvell/bg4cd/spi.c b/src/soc/marvell/bg4cd/spi.c index 53f46c7..9a999b0 100644 --- a/src/soc/marvell/bg4cd/spi.c +++ b/src/soc/marvell/bg4cd/spi.c @@ -20,17 +20,17 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs) return NULL; }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned out_bytes, void *din, unsigned in_bytes) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t out_bytes, void *din, size_t in_bytes) { return 0; } diff --git a/src/soc/mediatek/mt8173/spi.c b/src/soc/mediatek/mt8173/spi.c index 9d56b63..f60de6c 100644 --- a/src/soc/mediatek/mt8173/spi.c +++ b/src/soc/mediatek/mt8173/spi.c @@ -55,7 +55,7 @@ static struct mtk_spi_bus spi_bus[1] = { } };
-static inline struct mtk_spi_bus *to_mtk_spi(struct spi_slave *slave) +static inline struct mtk_spi_bus *to_mtk_spi(const struct spi_slave *slave) { return container_of(slave, struct mtk_spi_bus, slave); } @@ -182,7 +182,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs) }; }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { struct mtk_spi_bus *mtk_slave = to_mtk_spi(slave); struct mtk_spi_regs *regs = mtk_slave->regs; @@ -193,8 +193,8 @@ int spi_claim_bus(struct spi_slave *slave) return 0; }
-static int mtk_spi_fifo_transfer(struct spi_slave *slave, void *in, - const void *out, u32 size) +static int mtk_spi_fifo_transfer(const struct spi_slave *slave, void *in, + const void *out, size_t size) { struct mtk_spi_bus *mtk_slave = to_mtk_spi(slave); struct mtk_spi_regs *regs = mtk_slave->regs; @@ -269,10 +269,10 @@ error: return -1; }
-int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytes_out, - void *din, unsigned int bytes_in) +int spi_xfer(const struct spi_slave *slave, const void *dout, size_t bytes_out, + void *din, size_t bytes_in) { - uint32_t min_size = 0; + size_t min_size = 0; int ret;
while (bytes_out || bytes_in) { @@ -301,7 +301,7 @@ int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytes_out, return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { struct mtk_spi_bus *mtk_slave = to_mtk_spi(slave); struct mtk_spi_regs *regs = mtk_slave->regs; diff --git a/src/soc/nvidia/tegra124/spi.c b/src/soc/nvidia/tegra124/spi.c index d5be4a6..2ad4aa1 100644 --- a/src/soc/nvidia/tegra124/spi.c +++ b/src/soc/nvidia/tegra124/spi.c @@ -209,7 +209,7 @@ static unsigned int tegra_spi_speed(unsigned int bus) return 50000000; }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { struct tegra_spi_regs *regs = to_tegra_spi(slave->bus)->regs; u32 val; @@ -232,7 +232,7 @@ int spi_claim_bus(struct spi_slave *slave) return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { struct tegra_spi_regs *regs = to_tegra_spi(slave->bus)->regs; u32 val; @@ -719,13 +719,13 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return buf_len; }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int out_bytes, void *din, unsigned int in_bytes) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t out_bytes, void *din, size_t in_bytes) { struct tegra_spi_channel *spi = to_tegra_spi(slave->bus); u8 *out_buf = (u8 *)dout; u8 *in_buf = (u8 *)din; - unsigned int todo; + size_t todo; int ret = 0;
/* tegra bus numbers start at 1 */ diff --git a/src/soc/nvidia/tegra210/spi.c b/src/soc/nvidia/tegra210/spi.c index b01289c..7efefc4 100644 --- a/src/soc/nvidia/tegra210/spi.c +++ b/src/soc/nvidia/tegra210/spi.c @@ -208,7 +208,7 @@ static struct tegra_spi_channel * const to_tegra_spi(int bus) { return &tegra_spi_channels[bus - 1]; }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { struct tegra_spi_regs *regs = to_tegra_spi(slave->bus)->regs; u32 val; @@ -231,7 +231,7 @@ int spi_claim_bus(struct spi_slave *slave) return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { struct tegra_spi_regs *regs = to_tegra_spi(slave->bus)->regs; u32 val; @@ -755,13 +755,13 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return buf_len; }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int out_bytes, void *din, unsigned int in_bytes) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t out_bytes, void *din, size_t in_bytes) { struct tegra_spi_channel *spi = to_tegra_spi(slave->bus); u8 *out_buf = (u8 *)dout; u8 *in_buf = (u8 *)din; - unsigned int todo; + size_t todo; int ret = 0;
/* tegra bus numbers start at 1 */ @@ -827,8 +827,8 @@ int spi_xfer(struct spi_slave *slave, const void *dout,
if (ret < 0) { printk(BIOS_ERR, "%s: Error detected\n", __func__); - printk(BIOS_ERR, "Transaction size: %u, bytes remaining: " - "%u out / %u in\n", todo, out_bytes, in_bytes); + printk(BIOS_ERR, "Transaction size: %zu, bytes remaining: " + "%zu out / %zu in\n", todo, out_bytes, in_bytes); clear_fifo_status(spi); } return ret; diff --git a/src/soc/qualcomm/ipq40xx/include/soc/spi.h b/src/soc/qualcomm/ipq40xx/include/soc/spi.h index 1fd6a57..8ef1fbf 100644 --- a/src/soc/qualcomm/ipq40xx/include/soc/spi.h +++ b/src/soc/qualcomm/ipq40xx/include/soc/spi.h @@ -186,7 +186,7 @@ struct ipq_spi_slave { int allocated; };
-static inline struct ipq_spi_slave *to_ipq_spi(struct spi_slave *slave) +static inline struct ipq_spi_slave *to_ipq_spi(const struct spi_slave *slave) { return container_of(slave, struct ipq_spi_slave, slave); } diff --git a/src/soc/qualcomm/ipq40xx/spi.c b/src/soc/qualcomm/ipq40xx/spi.c index dcd00c0..871f24b 100644 --- a/src/soc/qualcomm/ipq40xx/spi.c +++ b/src/soc/qualcomm/ipq40xx/spi.c @@ -320,7 +320,7 @@ static int spi_hw_init(struct ipq_spi_slave *ds) return SUCCESS; }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { struct ipq_spi_slave *ds = to_ipq_spi(slave); unsigned int ret; @@ -332,7 +332,7 @@ int spi_claim_bus(struct spi_slave *slave) return SUCCESS; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { struct ipq_spi_slave *ds = to_ipq_spi(slave);
@@ -341,7 +341,7 @@ void spi_release_bus(struct spi_slave *slave) ds->initialized = 0; }
-static void write_force_cs(struct spi_slave *slave, int assert) +static void write_force_cs(const struct spi_slave *slave, int assert) { struct ipq_spi_slave *ds = to_ipq_spi(slave);
@@ -633,8 +633,8 @@ static int blsp_spi_write(struct ipq_spi_slave *ds, u8 *cmd_buffer, * This function is invoked with either tx_buf or rx_buf. * Calling this function with both null does a chip select change. */ -int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned out_bytes, void *din, unsigned in_bytes) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t out_bytes, void *din, size_t in_bytes) { struct ipq_spi_slave *ds = to_ipq_spi(slave); u8 *txp = (u8 *)dout; diff --git a/src/soc/qualcomm/ipq806x/include/soc/spi.h b/src/soc/qualcomm/ipq806x/include/soc/spi.h index 4f6f055..5dedcda 100644 --- a/src/soc/qualcomm/ipq806x/include/soc/spi.h +++ b/src/soc/qualcomm/ipq806x/include/soc/spi.h @@ -271,7 +271,7 @@ struct ipq_spi_slave { int allocated; };
-static inline struct ipq_spi_slave *to_ipq_spi(struct spi_slave *slave) +static inline struct ipq_spi_slave *to_ipq_spi(const struct spi_slave *slave) { return container_of(slave, struct ipq_spi_slave, slave); } diff --git a/src/soc/qualcomm/ipq806x/spi.c b/src/soc/qualcomm/ipq806x/spi.c index 71a8c29..d1af720 100644 --- a/src/soc/qualcomm/ipq806x/spi.c +++ b/src/soc/qualcomm/ipq806x/spi.c @@ -618,7 +618,7 @@ static int spi_hw_init(struct ipq_spi_slave *ds) return SUCCESS; }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { struct ipq_spi_slave *ds = to_ipq_spi(slave); unsigned int ret; @@ -641,7 +641,7 @@ int spi_claim_bus(struct spi_slave *slave) return SUCCESS; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { struct ipq_spi_slave *ds = to_ipq_spi(slave);
@@ -711,8 +711,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return min(MAX_PACKET_COUNT, buf_len); }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned out_bytes, void *din, unsigned in_bytes) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t out_bytes, void *din, size_t in_bytes) { int ret; struct ipq_spi_slave *ds = to_ipq_spi(slave); diff --git a/src/soc/rockchip/common/spi.c b/src/soc/rockchip/common/spi.c index 3666de3..8f45679 100644 --- a/src/soc/rockchip/common/spi.c +++ b/src/soc/rockchip/common/spi.c @@ -68,7 +68,7 @@ static struct rockchip_spi_slave rockchip_spi_slaves[] = { #endif };
-static struct rockchip_spi_slave *to_rockchip_spi(struct spi_slave *slave) +static struct rockchip_spi_slave *to_rockchip_spi(const struct spi_slave *slave) { return container_of(slave, struct rockchip_spi_slave, slave); } @@ -79,13 +79,13 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs) return &(rockchip_spi_slaves[bus].slave); }
-static void spi_cs_activate(struct spi_slave *slave) +static void spi_cs_activate(const struct spi_slave *slave) { struct rockchip_spi *regs = to_rockchip_spi(slave)->regs; setbits_le32(®s->ser, 1); }
-static void spi_cs_deactivate(struct spi_slave *slave) +static void spi_cs_deactivate(const struct spi_slave *slave) { struct rockchip_spi *regs = to_rockchip_spi(slave)->regs; clrbits_le32(®s->ser, 1); @@ -157,13 +157,13 @@ void rockchip_spi_set_sample_delay(unsigned int bus, unsigned int delay_ns) rsd << SPI_RXDSD_OFFSET); }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { spi_cs_activate(slave); return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { spi_cs_deactivate(slave); } @@ -203,11 +203,11 @@ static void set_transfer_mode(struct rockchip_spi *regs,
/* returns 0 to indicate success, <0 otherwise */ static int do_xfer(struct rockchip_spi *regs, bool use_16bit, const void *dout, - unsigned int *bytes_out, void *din, unsigned int *bytes_in) + size_t *bytes_out, void *din, size_t *bytes_in) { uint8_t *in_buf = din; uint8_t *out_buf = (uint8_t *)dout; - unsigned int min_xfer; + size_t min_xfer;
if (*bytes_out == 0) min_xfer = *bytes_in; @@ -268,8 +268,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return min(65535, buf_len); }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytes_out, void *din, unsigned int bytes_in) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytes_out, void *din, size_t bytes_in) { struct rockchip_spi *regs = to_rockchip_spi(slave)->regs; int ret = 0; @@ -283,10 +283,10 @@ int spi_xfer(struct spi_slave *slave, const void *dout, * seems to work fine. */ while (bytes_out || bytes_in) { - unsigned int in_now = MIN(bytes_in, 0xfffe); - unsigned int out_now = MIN(bytes_out, 0xfffe); - unsigned int in_rem, out_rem; - unsigned int mask; + size_t in_now = MIN(bytes_in, 0xfffe); + size_t out_now = MIN(bytes_out, 0xfffe); + size_t in_rem, out_rem; + size_t mask; bool use_16bit;
rockchip_spi_enable_chip(regs, 0); @@ -324,13 +324,13 @@ int spi_xfer(struct spi_slave *slave, const void *dout, break;
if (bytes_out) { - unsigned int sent = out_now - out_rem; + size_t sent = out_now - out_rem; bytes_out -= sent; dout += sent; }
if (bytes_in) { - unsigned int received = in_now - in_rem; + size_t received = in_now - in_rem; bytes_in -= received; din += received; } diff --git a/src/soc/samsung/exynos5420/spi.c b/src/soc/samsung/exynos5420/spi.c index fd31a2f..c2faeb5 100644 --- a/src/soc/samsung/exynos5420/spi.c +++ b/src/soc/samsung/exynos5420/spi.c @@ -58,7 +58,7 @@ static struct exynos_spi_slave exynos_spi_slaves[3] = { }, };
-static inline struct exynos_spi_slave *to_exynos_spi(struct spi_slave *slave) +static inline struct exynos_spi_slave *to_exynos_spi(const struct spi_slave *slave) { return container_of(slave, struct exynos_spi_slave, slave); } @@ -128,7 +128,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs) return &eslave->slave; }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { struct exynos_spi *regs = to_exynos_spi(slave)->regs; // TODO(hungte) Add some delay if too many transactions happen at once. @@ -137,19 +137,19 @@ int spi_claim_bus(struct spi_slave *slave) }
static void spi_transfer(struct exynos_spi *regs, void *in, const void *out, - u32 size) + size_t size) { u8 *inb = in; const u8 *outb = out;
- int width = (size % 4) ? 1 : 4; + size_t width = (size % 4) ? 1 : 4;
while (size) { - int packets = size / width; + size_t packets = size / width; // The packet count field is 16 bits wide. packets = MIN(packets, (1 << 16) - 1);
- int out_bytes, in_bytes; + size_t out_bytes, in_bytes; out_bytes = in_bytes = packets * width;
spi_sw_reset(regs, width == 4); @@ -188,13 +188,13 @@ static void spi_transfer(struct exynos_spi *regs, void *in, const void *out, } }
-int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytes_out, - void *din, unsigned int bytes_in) +int spi_xfer(const struct spi_slave *slave, const void *dout, size_t bytes_out, + void *din, size_t bytes_in) { struct exynos_spi *regs = to_exynos_spi(slave)->regs;
if (bytes_out && bytes_in) { - u32 min_size = MIN(bytes_out, bytes_in); + size_t min_size = MIN(bytes_out, bytes_in);
spi_transfer(regs, din, dout, min_size);
@@ -213,7 +213,7 @@ int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytes_out, return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { struct exynos_spi *regs = to_exynos_spi(slave)->regs; setbits_le32(®s->cs_reg, SPI_SLAVE_SIG_INACT); diff --git a/src/southbridge/amd/agesa/hudson/spi.c b/src/southbridge/amd/agesa/hudson/spi.c index f1a82e9..7bb0e3f 100644 --- a/src/southbridge/amd/agesa/hudson/spi.c +++ b/src/southbridge/amd/agesa/hudson/spi.c @@ -90,13 +90,13 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return min(AMD_SB_SPI_TX_LEN - cmd_len, buf_len); }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { /* First byte is cmd which can not being sent through FIFO. */ u8 cmd = *(u8 *)dout++; u8 readoffby1; - u8 count; + size_t count;
bytesout--;
@@ -147,13 +147,13 @@ int spi_xfer(struct spi_slave *slave, const void *dout, return 0; }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { /* Nothing is required. */ return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { /* Nothing is required. */ } diff --git a/src/southbridge/amd/cimx/sb800/spi.c b/src/southbridge/amd/cimx/sb800/spi.c index 726d8e0..2522c2e 100644 --- a/src/southbridge/amd/cimx/sb800/spi.c +++ b/src/southbridge/amd/cimx/sb800/spi.c @@ -59,14 +59,14 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return min(AMD_SB_SPI_TX_LEN - cmd_len, buf_len); }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { /* First byte is cmd which can not being sent through FIFO. */ u8 cmd = *(u8 *)dout++; u8 readoffby1; u8 readwrite; - u8 count; + size_t count;
bytesout--;
@@ -138,13 +138,13 @@ static void ImcWakeup(void) WaitForEcLDN9MailboxCmdAck(); }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { /* Nothing is required. */ return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { /* Nothing is required. */ return; diff --git a/src/southbridge/amd/sb700/spi.c b/src/southbridge/amd/sb700/spi.c index fa316f1..2b1ae2d 100644 --- a/src/southbridge/amd/sb700/spi.c +++ b/src/southbridge/amd/sb700/spi.c @@ -65,13 +65,13 @@ static void execute_command(void) (read8((void *)(spibar+3)) & 0x80)); }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { /* Handled internally by the SB700 */ return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { /* Handled internally by the SB700 */ } @@ -89,14 +89,14 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs) return slave; }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { /* First byte is cmd which cannot be sent through the FIFO. */ u8 cmd = *(u8 *)dout++; u8 readoffby1; u8 readwrite; - u8 count; + size_t count;
uint32_t spibar = get_spi_bar();
diff --git a/src/southbridge/amd/sb700/spi.h b/src/southbridge/amd/sb700/spi.h index ed5b858..605f3ee 100644 --- a/src/southbridge/amd/sb700/spi.h +++ b/src/southbridge/amd/sb700/spi.h @@ -13,5 +13,5 @@ * GNU General Public License for more details. */
-int spi_claim_bus(struct spi_slave *slave); -void spi_release_bus(struct spi_slave *slave); +int spi_claim_bus(const struct spi_slave *slave); +void spi_release_bus(const struct spi_slave *slave); diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c index 36102c2..2d36d38 100644 --- a/src/southbridge/intel/common/spi.c +++ b/src/southbridge/intel/common/spi.c @@ -357,13 +357,13 @@ static void spi_init_cb(void *unused)
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ } @@ -536,8 +536,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return min(cntlr.databytes, buf_len); }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { uint16_t control; int16_t opcode_index; diff --git a/src/southbridge/intel/fsp_rangeley/spi.c b/src/southbridge/intel/fsp_rangeley/spi.c index 8b0c3c1..8a0fac2 100644 --- a/src/southbridge/intel/fsp_rangeley/spi.c +++ b/src/southbridge/intel/fsp_rangeley/spi.c @@ -429,13 +429,13 @@ void spi_init(void) } }
-int spi_claim_bus(struct spi_slave *slave) +int spi_claim_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ return 0; }
-void spi_release_bus(struct spi_slave *slave) +void spi_release_bus(const struct spi_slave *slave) { /* Handled by ICH automatically. */ } @@ -601,8 +601,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len) return min(cntlr.databytes, buf_len); }
-int spi_xfer(struct spi_slave *slave, const void *dout, - unsigned int bytesout, void *din, unsigned int bytesin) +int spi_xfer(const struct spi_slave *slave, const void *dout, + size_t bytesout, void *din, size_t bytesin) { uint16_t control; int16_t opcode_index;