mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-02 17:41:08 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
53 lines
1.3 KiB
C
53 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* SPI flash interface
|
|
*
|
|
* Copyright (C) 2008 Atmel Corporation
|
|
* Copyright (C) 2010 Reinhard Meyer, EMK Elektronik
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <spi.h>
|
|
|
|
static int spi_flash_read_write(struct spi_slave *spi,
|
|
const u8 *cmd, size_t cmd_len,
|
|
const u8 *data_out, u8 *data_in,
|
|
size_t data_len)
|
|
{
|
|
unsigned long flags = SPI_XFER_BEGIN;
|
|
int ret;
|
|
|
|
if (data_len == 0)
|
|
flags |= SPI_XFER_END;
|
|
|
|
ret = spi_xfer(spi, cmd_len * 8, cmd, NULL, flags);
|
|
if (ret) {
|
|
debug("SF: Failed to send command (%zu bytes): %d\n",
|
|
cmd_len, ret);
|
|
} else if (data_len != 0) {
|
|
ret = spi_xfer(spi, data_len * 8, data_out, data_in,
|
|
SPI_XFER_END);
|
|
if (ret)
|
|
debug("SF: Failed to transfer %zu bytes of data: %d\n",
|
|
data_len, ret);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd,
|
|
size_t cmd_len, void *data, size_t data_len)
|
|
{
|
|
return spi_flash_read_write(spi, cmd, cmd_len, NULL, data, data_len);
|
|
}
|
|
|
|
int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len)
|
|
{
|
|
return spi_flash_cmd_read(spi, &cmd, 1, response, len);
|
|
}
|
|
|
|
int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
|
|
const void *data, size_t data_len)
|
|
{
|
|
return spi_flash_read_write(spi, cmd, cmd_len, data, NULL, data_len);
|
|
}
|