Skip to content

Commit 9908c44

Browse files
Revert "[nrf temphack] drivers: flash: Add one byte write access to QSPI NOR"
This reverts commit 6b2b6ee. Signed-off-by: Martí Bolívar <[email protected]>
1 parent 4ee2f8f commit 9908c44

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

drivers/flash/nrf_qspi_nor.c

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -541,36 +541,16 @@ static int qspi_nor_read(struct device *dev, off_t addr, void *dest,
541541
static int qspi_nor_write(struct device *dev, off_t addr, const void *src,
542542
size_t size)
543543
{
544-
u8_t __aligned(4) buf[4];
545-
546-
const void *sptr = src;
547-
size_t dlen = size;
548-
549-
if (!src || (size == 0)) {
544+
if (!src) {
550545
return -EINVAL;
551546
}
552547

553-
/* address must be 4-byte aligned */
554-
if ((addr % 4U) != 0) {
548+
/* write size must be non-zero multiple of 4 bytes */
549+
if (((size % 4U) != 0) || (size == 0)) {
555550
return -EINVAL;
556551
}
557-
558-
/* Since the QSPI driver requires data to be at least 4 bytes we need
559-
* to use a 4 byte buffer for writes smaller than 4 bytes.
560-
*/
561-
if (size < 4U) {
562-
src = buf;
563-
size = sizeof(buf);
564-
/* read out the whole word so that unchanged data can be
565-
* written back
566-
*/
567-
nrfx_err_t res = nrfx_qspi_read(buf, size, addr);
568-
569-
if (res != 0) {
570-
return qspi_get_zephyr_ret_code(res);
571-
}
572-
memcpy(buf, sptr, dlen);
573-
} else if ((size % 4U) != 0) {
552+
/* address must be 4-byte aligned */
553+
if ((addr % 4U) != 0) {
574554
return -EINVAL;
575555
}
576556

0 commit comments

Comments
 (0)