drivers/misc/eeprom/idt_89hpesx.c
Source file repositories/reference/linux-study-clean/drivers/misc/eeprom/idt_89hpesx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/eeprom/idt_89hpesx.c- Extension
.c- Size
- 42048 bytes
- Lines
- 1517
- Domain
- Driver Families
- Bucket
- drivers/misc
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/kernel.hlinux/init.hlinux/module.hlinux/types.hlinux/sizes.hlinux/slab.hlinux/mutex.hlinux/sysfs.hlinux/debugfs.hlinux/mod_devicetable.hlinux/property.hlinux/i2c.hlinux/pci_ids.hlinux/delay.h
Detected Declarations
struct idt_smb_seqstruct idt_89hpesx_devstruct idt_smb_seqstruct idt_eeprom_seqstruct idt_csr_seqfunction idt_smb_write_bytefunction idt_smb_read_bytefunction idt_smb_write_wordfunction idt_smb_read_wordfunction idt_smb_write_blockfunction idt_smb_read_blockfunction idt_smb_write_i2c_blockfunction idt_smb_read_i2c_blockfunction idt_eeprom_read_bytefunction idt_eeprom_writefunction idt_eeprom_readfunction idt_csr_writefunction idt_csr_readfunction eeprom_writefunction eeprom_readfunction idt_dbgfs_csr_writefunction idt_dbgfs_csr_readfunction idt_set_defvalfunction idt_ee_match_idfunction idt_get_fw_datafunction device_for_each_child_nodefunction idt_create_pdevfunction idt_free_pdevfunction idt_set_smbus_opsfunction i2c_check_functionalityfunction i2c_check_functionalityfunction idt_check_devfunction idt_create_sysfs_filesfunction idt_remove_sysfs_filesfunction idt_probefunction idt_remove
Annotated Snippet
static const struct file_operations csr_dbgfs_ops = {
.owner = THIS_MODULE,
.open = simple_open,
.write = idt_dbgfs_csr_write,
.read = idt_dbgfs_csr_read
};
/*===========================================================================
* Driver init/deinit methods
*===========================================================================
*/
/*
* idt_set_defval() - disable EEPROM access by default
* @pdev: Pointer to the driver data
*/
static void idt_set_defval(struct idt_89hpesx_dev *pdev)
{
/* If OF info is missing then use next values */
pdev->eesize = 0;
pdev->eero = true;
pdev->inieecmd = 0;
pdev->eeaddr = 0;
}
static const struct i2c_device_id ee_ids[];
/*
* idt_ee_match_id() - check whether the node belongs to compatible EEPROMs
*/
static const struct i2c_device_id *idt_ee_match_id(struct fwnode_handle *fwnode)
{
const struct i2c_device_id *id = ee_ids;
const char *compatible, *p;
char devname[I2C_NAME_SIZE];
int ret;
ret = fwnode_property_read_string(fwnode, "compatible", &compatible);
if (ret)
return NULL;
p = strchr(compatible, ',');
strscpy(devname, p ? p + 1 : compatible, sizeof(devname));
/* Search through the device name */
while (id->name[0]) {
if (strcmp(devname, id->name) == 0)
return id;
id++;
}
return NULL;
}
/*
* idt_get_fw_data() - get IDT i2c-device parameters from device tree
* @pdev: Pointer to the driver data
*/
static void idt_get_fw_data(struct idt_89hpesx_dev *pdev)
{
struct device *dev = &pdev->client->dev;
struct fwnode_handle *fwnode;
const struct i2c_device_id *ee_id = NULL;
u32 eeprom_addr;
int ret;
device_for_each_child_node(dev, fwnode) {
ee_id = idt_ee_match_id(fwnode);
if (ee_id)
break;
dev_warn(dev, "Skip unsupported EEPROM device %pfw\n", fwnode);
}
/* If there is no fwnode EEPROM device, then set zero size */
if (!ee_id) {
dev_warn(dev, "No fwnode, EEPROM access disabled");
idt_set_defval(pdev);
return;
}
/* Retrieve EEPROM size */
pdev->eesize = (u32)ee_id->driver_data;
/* Get custom EEPROM address from 'reg' attribute */
ret = fwnode_property_read_u32(fwnode, "reg", &eeprom_addr);
if (ret || (eeprom_addr == 0)) {
dev_warn(dev, "No EEPROM reg found, use default address 0x%x",
EEPROM_DEF_ADDR);
pdev->inieecmd = 0;
pdev->eeaddr = EEPROM_DEF_ADDR << 1;
} else {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/module.h`, `linux/types.h`, `linux/sizes.h`, `linux/slab.h`, `linux/mutex.h`, `linux/sysfs.h`.
- Detected declarations: `struct idt_smb_seq`, `struct idt_89hpesx_dev`, `struct idt_smb_seq`, `struct idt_eeprom_seq`, `struct idt_csr_seq`, `function idt_smb_write_byte`, `function idt_smb_read_byte`, `function idt_smb_write_word`, `function idt_smb_read_word`, `function idt_smb_write_block`.
- Atlas domain: Driver Families / drivers/misc.
- Implementation status: pattern 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.