drivers/mtd/spi-nor/sst.c

Source file repositories/reference/linux-study-clean/drivers/mtd/spi-nor/sst.c

File Facts

System
Linux kernel
Corpus path
drivers/mtd/spi-nor/sst.c
Extension
.c
Size
6645 bytes
Lines
286
Domain
Driver Families
Bucket
drivers/mtd
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (needs_write_enable) {
			ret = spi_nor_write_enable(nor);
			if (ret)
				goto out;
		}
	}

	/* 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;

		actual += 1;

		ret = spi_nor_write_disable(nor);
	}
out:
	*retlen += actual;
	spi_nor_unlock_and_unprep(nor);
	return ret;
}

static int sst_nor_late_init(struct spi_nor *nor)
{
	if (nor->info->mfr_flags & SST_WRITE)
		nor->mtd._write = sst_nor_write;

	return 0;
}

static const struct spi_nor_fixups sst_nor_fixups = {
	.late_init = sst_nor_late_init,
};

const struct spi_nor_manufacturer spi_nor_sst = {
	.name = "sst",
	.parts = sst_nor_parts,
	.nparts = ARRAY_SIZE(sst_nor_parts),
	.fixups = &sst_nor_fixups,
};

Annotation

Implementation Notes