drivers/i2c/busses/i2c-ismt.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-ismt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-ismt.c- Extension
.c- Size
- 28561 bytes
- Lines
- 995
- Domain
- Driver Families
- Bucket
- drivers/i2c
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/module.hlinux/pci.hlinux/kernel.hlinux/stddef.hlinux/completion.hlinux/dma-mapping.hlinux/i2c.hlinux/acpi.hlinux/interrupt.hlinux/io-64-nonatomic-lo-hi.h
Detected Declarations
struct ismt_descstruct ismt_privfunction __ismt_desc_dumpfunction ismt_desc_dumpfunction ismt_gen_reg_dumpfunction ismt_mstr_reg_dumpfunction ismt_submit_descfunction ismt_process_descfunction ismt_kill_transactionfunction ismt_accessfunction ismt_funcfunction ismt_handle_isrfunction ismt_do_interruptfunction ismt_do_msi_interruptfunction ismt_hw_initfunction ismt_dev_initfunction ismt_int_initfunction ismt_probefunction ismt_remove
Annotated Snippet
static struct pci_driver ismt_driver;
/**
* ismt_probe() - probe for iSMT devices
* @pdev: PCI-Express device
* @id: PCI-Express device ID
*/
static int
ismt_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
int err;
struct ismt_priv *priv;
unsigned long start, len;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
pci_set_drvdata(pdev, priv);
i2c_set_adapdata(&priv->adapter, priv);
priv->adapter.owner = THIS_MODULE;
priv->adapter.class = I2C_CLASS_HWMON;
priv->adapter.algo = &smbus_algorithm;
priv->adapter.dev.parent = &pdev->dev;
ACPI_COMPANION_SET(&priv->adapter.dev, ACPI_COMPANION(&pdev->dev));
priv->adapter.retries = ISMT_MAX_RETRIES;
priv->pci_dev = pdev;
err = pcim_enable_device(pdev);
if (err) {
dev_err(&pdev->dev, "Failed to enable SMBus PCI device (%d)\n",
err);
return err;
}
/* enable bus mastering */
pci_set_master(pdev);
/* Determine the address of the SMBus area */
start = pci_resource_start(pdev, SMBBAR);
len = pci_resource_len(pdev, SMBBAR);
if (!start || !len) {
dev_err(&pdev->dev,
"SMBus base address uninitialized, upgrade BIOS\n");
return -ENODEV;
}
snprintf(priv->adapter.name, sizeof(priv->adapter.name),
"SMBus iSMT adapter at %lx", start);
dev_dbg(&priv->pci_dev->dev, " start=0x%lX\n", start);
dev_dbg(&priv->pci_dev->dev, " len=0x%lX\n", len);
err = acpi_check_resource_conflict(&pdev->resource[SMBBAR]);
if (err) {
dev_err(&pdev->dev, "ACPI resource conflict!\n");
return err;
}
err = pcim_request_region(pdev, SMBBAR, ismt_driver.name);
if (err) {
dev_err(&pdev->dev,
"Failed to request SMBus region 0x%lx-0x%lx\n",
start, start + len);
return err;
}
priv->smba = pcim_iomap(pdev, SMBBAR, len);
if (!priv->smba) {
dev_err(&pdev->dev, "Unable to ioremap SMBus BAR\n");
return -ENODEV;
}
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (err) {
dev_err(&pdev->dev, "dma_set_mask fail\n");
return -ENODEV;
}
err = ismt_dev_init(priv);
if (err)
return err;
ismt_hw_init(priv);
err = ismt_int_init(priv);
if (err)
return err;
Annotation
- Immediate include surface: `linux/module.h`, `linux/pci.h`, `linux/kernel.h`, `linux/stddef.h`, `linux/completion.h`, `linux/dma-mapping.h`, `linux/i2c.h`, `linux/acpi.h`.
- Detected declarations: `struct ismt_desc`, `struct ismt_priv`, `function __ismt_desc_dump`, `function ismt_desc_dump`, `function ismt_gen_reg_dump`, `function ismt_mstr_reg_dump`, `function ismt_submit_desc`, `function ismt_process_desc`, `function ismt_kill_transaction`, `function ismt_access`.
- Atlas domain: Driver Families / drivers/i2c.
- Implementation status: pattern implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.