staticint sst_nor_write_data(struct spi_nor *nor, loff_t to, size_t len, const u_char *buf)
{
u8 op = (len == 1) ? SPINOR_OP_BP : SPINOR_OP_AAI_WP; int ret;
nor->program_opcode = op;
ret = spi_nor_write_data(nor, to, len, buf); if (ret < 0) return ret;
WARN(ret != len, "While writing %zu byte written %i bytes\n", len, ret);
return spi_nor_wait_till_ready(nor);
}
staticint sst_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf)
{ struct spi_nor *nor = mtd_to_spi_nor(mtd);
size_t actual = 0; int ret;
dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len);
ret = spi_nor_prep_and_lock(nor); if (ret) return ret;
ret = spi_nor_write_enable(nor); if (ret) goto out;
nor->sst_write_second = false;
/* Start write from odd address. */ if (to % 2) { /* write one byte. */
ret = sst_nor_write_data(nor, to, 1, buf); if (ret < 0) goto out;
to++;
actual++;
}
/* Write out most of the data here. */ for (; actual < len - 1; actual += 2) { /* write two bytes. */
ret = sst_nor_write_data(nor, to, 2, buf + actual); if (ret < 0) goto out;
to += 2;
nor->sst_write_second = true;
}
nor->sst_write_second = false;
ret = spi_nor_write_disable(nor); if (ret) goto out;
ret = spi_nor_wait_till_ready(nor); if (ret) goto out;
/* Write out trailing byte if it exists. */ if (actual != len) {
ret = spi_nor_write_enable(nor); if (ret) goto out;
ret = sst_nor_write_data(nor, to, 1, buf + actual); if (ret < 0) goto out;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.