spi: Change spi_xfer to work in units of bytes instead of bits.
Whenever spi_xfer is called and whenver it's implemented, the natural unit for the amount of data being transfered is bytes. The API expected things to be expressed in bits, however, which led to a lot of multiplying and dividing by eight, and checkes to make sure things were multiples of eight. All of that can now be removed. BUG=None TEST=Built and booted on link, falco, peach_pit and nyan and looked for SPI errors in the firmware log. Built for rambi. BRANCH=None Change-Id: I02365bdb6960a35def7be7a0cd1aa0a2cc09392f Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: https://chromium-review.googlesource.com/192049 Reviewed-by: Gabe Black <gabeblack@chromium.org> Tested-by: Gabe Black <gabeblack@chromium.org> Commit-Queue: Gabe Black <gabeblack@chromium.org> [km: cherry-pick from chromium] Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/6175 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
This commit is contained in:
committed by
Kyösti Mälkki
parent
1e187356e8
commit
93d9f92cfb
@@ -28,7 +28,7 @@ static void spi_flash_addr(u32 addr, u8 *cmd)
|
||||
|
||||
int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len)
|
||||
{
|
||||
int ret = spi_xfer(spi, &cmd, 8, response, len * 8);
|
||||
int ret = spi_xfer(spi, &cmd, sizeof(cmd), response, len);
|
||||
if (ret)
|
||||
printk(BIOS_WARNING, "SF: Failed to send command %02x: %d\n", cmd, ret);
|
||||
|
||||
@@ -38,7 +38,7 @@ int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len)
|
||||
int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd,
|
||||
size_t cmd_len, void *data, size_t data_len)
|
||||
{
|
||||
int ret = spi_xfer(spi, cmd, cmd_len * 8, data, data_len * 8);
|
||||
int ret = spi_xfer(spi, cmd, cmd_len, data, data_len);
|
||||
if (ret) {
|
||||
printk(BIOS_WARNING, "SF: Failed to send read command (%zu bytes): %d\n",
|
||||
data_len, ret);
|
||||
@@ -55,7 +55,7 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
|
||||
memcpy(buff, cmd, cmd_len);
|
||||
memcpy(buff + cmd_len, data, data_len);
|
||||
|
||||
ret = spi_xfer(spi, buff, (cmd_len + data_len) * 8, NULL, 0);
|
||||
ret = spi_xfer(spi, buff, cmd_len + data_len, NULL, 0);
|
||||
if (ret) {
|
||||
printk(BIOS_WARNING, "SF: Failed to send write command (%zu bytes): %d\n",
|
||||
data_len, ret);
|
||||
|
Reference in New Issue
Block a user