drivers/misc/eeprom/eeprom_93xx46.c
Source file repositories/reference/linux-study-clean/drivers/misc/eeprom/eeprom_93xx46.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/eeprom/eeprom_93xx46.c- Extension
.c- Size
- 13558 bytes
- Lines
- 562
- Domain
- Driver Families
- Bucket
- drivers/misc
- 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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/array_size.hlinux/bits.hlinux/delay.hlinux/device.hlinux/gpio/consumer.hlinux/kstrtox.hlinux/log2.hlinux/mod_devicetable.hlinux/module.hlinux/mutex.hlinux/property.hlinux/slab.hlinux/spi/spi.hlinux/string_choices.hlinux/nvmem-provider.h
Detected Declarations
struct eeprom_93xx46_platform_datastruct eeprom_93xx46_devtype_datastruct eeprom_93xx46_devfunction has_quirk_single_word_readfunction has_quirk_instruction_lengthfunction has_quirk_extra_read_cyclefunction eeprom_93xx46_readfunction eeprom_93xx46_ewfunction eeprom_93xx46_write_wordfunction eeprom_93xx46_writefunction eeprom_93xx46_eralfunction erase_storefunction eeprom_93xx46_probe_fwfunction eeprom_93xx46_probefunction eeprom_93xx46_remove
Annotated Snippet
struct eeprom_93xx46_platform_data {
unsigned char flags;
#define EE_ADDR8 0x01 /* 8 bit addr. cfg */
#define EE_ADDR16 0x02 /* 16 bit addr. cfg */
#define EE_READONLY 0x08 /* forbid writing */
#define EE_SIZE1K 0x10 /* 1 kb of data, that is a 93xx46 */
#define EE_SIZE2K 0x20 /* 2 kb of data, that is a 93xx56 */
#define EE_SIZE4K 0x40 /* 4 kb of data, that is a 93xx66 */
unsigned int quirks;
/* Single word read transfers only; no sequential read. */
#define EEPROM_93XX46_QUIRK_SINGLE_WORD_READ (1 << 0)
/* Instructions such as EWEN are (addrlen + 2) in length. */
#define EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH (1 << 1)
/* Add extra cycle after address during a read */
#define EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE BIT(2)
struct gpio_desc *select;
};
#define OP_START 0x4
#define OP_WRITE (OP_START | 0x1)
#define OP_READ (OP_START | 0x2)
/* The following addresses are offset for the 1K EEPROM variant in 16-bit mode */
#define ADDR_EWDS 0x00
#define ADDR_ERAL 0x20
#define ADDR_EWEN 0x30
struct eeprom_93xx46_devtype_data {
unsigned int quirks;
unsigned char flags;
};
static const struct eeprom_93xx46_devtype_data at93c46_data = {
.flags = EE_SIZE1K,
};
static const struct eeprom_93xx46_devtype_data at93c56_data = {
.flags = EE_SIZE2K,
};
static const struct eeprom_93xx46_devtype_data at93c66_data = {
.flags = EE_SIZE4K,
};
static const struct eeprom_93xx46_devtype_data atmel_at93c46d_data = {
.flags = EE_SIZE1K,
.quirks = EEPROM_93XX46_QUIRK_SINGLE_WORD_READ |
EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH,
};
static const struct eeprom_93xx46_devtype_data microchip_93lc46b_data = {
.flags = EE_SIZE1K,
.quirks = EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE,
};
struct eeprom_93xx46_dev {
struct spi_device *spi;
struct eeprom_93xx46_platform_data *pdata;
struct mutex lock;
struct nvmem_config nvmem_config;
struct nvmem_device *nvmem;
int addrlen;
int size;
};
static inline bool has_quirk_single_word_read(struct eeprom_93xx46_dev *edev)
{
return edev->pdata->quirks & EEPROM_93XX46_QUIRK_SINGLE_WORD_READ;
}
static inline bool has_quirk_instruction_length(struct eeprom_93xx46_dev *edev)
{
return edev->pdata->quirks & EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH;
}
static inline bool has_quirk_extra_read_cycle(struct eeprom_93xx46_dev *edev)
{
return edev->pdata->quirks & EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE;
}
static int eeprom_93xx46_read(void *priv, unsigned int off,
void *val, size_t count)
{
struct eeprom_93xx46_dev *edev = priv;
char *buf = val;
int err = 0;
int bits;
if (unlikely(off >= edev->size))
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bits.h`, `linux/delay.h`, `linux/device.h`, `linux/gpio/consumer.h`, `linux/kstrtox.h`, `linux/log2.h`, `linux/mod_devicetable.h`.
- Detected declarations: `struct eeprom_93xx46_platform_data`, `struct eeprom_93xx46_devtype_data`, `struct eeprom_93xx46_dev`, `function has_quirk_single_word_read`, `function has_quirk_instruction_length`, `function has_quirk_extra_read_cycle`, `function eeprom_93xx46_read`, `function eeprom_93xx46_ew`, `function eeprom_93xx46_write_word`, `function eeprom_93xx46_write`.
- Atlas domain: Driver Families / drivers/misc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.