aboutsummaryrefslogtreecommitdiff
path: root/src/soc/rockchip
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2016-11-30 04:34:22 -0800
committerFurquan Shaikh <furquan@google.com>2016-12-05 03:24:38 +0100
commit0dba0254ea31eca41fdef88783f1dd192ac6fa56 (patch)
tree3c43a2ca9ff4706beb0c0df82cfd96aca75a3927 /src/soc/rockchip
parent52896c6c33250036928406d9dc38aa2ce1906b05 (diff)
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> Reviewed-on: https://review.coreboot.org/17682 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/soc/rockchip')
-rw-r--r--src/soc/rockchip/common/spi.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/soc/rockchip/common/spi.c b/src/soc/rockchip/common/spi.c
index 3666de39d1..8f45679dfc 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(&regs->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(&regs->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;
}