drivers/ptp/ptp_ocp.c
Source file repositories/reference/linux-study-clean/drivers/ptp/ptp_ocp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ptp/ptp_ocp.c- Extension
.c- Size
- 125701 bytes
- Lines
- 5281
- Domain
- Driver Families
- Bucket
- drivers/ptp
- 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.
- 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/bits.hlinux/err.hlinux/kernel.hlinux/module.hlinux/debugfs.hlinux/init.hlinux/pci.hlinux/serial_8250.hlinux/clkdev.hlinux/clk-provider.hlinux/platform_device.hlinux/platform_data/i2c-xiic.hlinux/platform_data/i2c-ocores.hlinux/ptp_clock_kernel.hlinux/spi/spi.hlinux/spi/xilinx_spi.hlinux/spi/altera.hnet/devlink.hlinux/i2c.hlinux/mtd/mtd.hlinux/nvmem-consumer.hlinux/crc16.hlinux/dpll.h
Detected Declarations
struct ocp_regstruct ptp_ocp_servo_confstruct ptp_ocp_adva_infostruct tod_regstruct ts_regstruct pps_regstruct img_regstruct gpio_regstruct irig_master_regstruct irig_slave_regstruct dcf_master_regstruct dcf_slave_regstruct signal_regstruct frequency_regstruct board_config_regstruct ptp_ocp_flash_infostruct ptp_ocp_firmware_headerstruct ptp_ocp_i2c_infostruct ptp_ocp_ext_infostruct ptp_ocp_ext_srcstruct ptp_ocp_sma_connectorstruct ocp_attr_groupstruct ocp_selectorstruct ocp_sma_opstruct ptp_ocp_signalstruct ptp_ocp_serial_portstruct ptp_ocpstruct ocp_resourcestruct ptp_ocp_eeprom_mapstruct ocp_art_gpio_regstruct ptp_ocp_nvmem_match_infoenum ptp_ocp_sma_modefunction OCP_MEM_RESOURCEfunction OCP_MEM_RESOURCEfunction OCP_MEM_RESOURCEfunction OCP_MEM_RESOURCEfunction ptp_ocp_sma_initfunction ptp_ocp_sma_getfunction ptp_ocp_sma_set_inputsfunction ptp_ocp_sma_set_outputfunction ptp_ocp_select_name_from_valfunction ptp_ocp_select_val_from_namefunction ptp_ocp_select_table_showfunction __ptp_ocp_gettime_lockedfunction ptp_ocp_gettimexfunction __ptp_ocp_settime_lockedfunction ptp_ocp_settimefunction __ptp_ocp_adjtime_locked
Annotated Snippet
static struct pci_driver ptp_ocp_driver = {
.name = KBUILD_MODNAME,
.id_table = ptp_ocp_pcidev_id,
.probe = ptp_ocp_probe,
.remove = ptp_ocp_remove,
.shutdown = ptp_ocp_remove,
};
static int
ptp_ocp_i2c_notifier_call(struct notifier_block *nb,
unsigned long action, void *data)
{
struct device *dev, *child = data;
struct ptp_ocp *bp;
bool add;
switch (action) {
case BUS_NOTIFY_ADD_DEVICE:
case BUS_NOTIFY_DEL_DEVICE:
add = action == BUS_NOTIFY_ADD_DEVICE;
break;
default:
return 0;
}
if (!i2c_verify_adapter(child))
return 0;
dev = child;
while ((dev = dev->parent))
if (dev->driver && !strcmp(dev->driver->name, KBUILD_MODNAME))
goto found;
return 0;
found:
bp = dev_get_drvdata(dev);
if (add)
ptp_ocp_symlink(bp, child, "i2c");
else
sysfs_remove_link(&bp->dev.kobj, "i2c");
return 0;
}
static struct notifier_block ptp_ocp_i2c_notifier = {
.notifier_call = ptp_ocp_i2c_notifier_call,
};
static int __init
ptp_ocp_init(void)
{
const char *what;
int err;
ptp_ocp_debugfs_init();
what = "timecard class";
err = class_register(&timecard_class);
if (err)
goto out;
what = "i2c notifier";
err = bus_register_notifier(&i2c_bus_type, &ptp_ocp_i2c_notifier);
if (err)
goto out_notifier;
what = "ptp_ocp driver";
err = pci_register_driver(&ptp_ocp_driver);
if (err)
goto out_register;
return 0;
out_register:
bus_unregister_notifier(&i2c_bus_type, &ptp_ocp_i2c_notifier);
out_notifier:
class_unregister(&timecard_class);
out:
ptp_ocp_debugfs_fini();
pr_err(KBUILD_MODNAME ": failed to register %s: %d\n", what, err);
return err;
}
static void __exit
ptp_ocp_fini(void)
{
bus_unregister_notifier(&i2c_bus_type, &ptp_ocp_i2c_notifier);
pci_unregister_driver(&ptp_ocp_driver);
class_unregister(&timecard_class);
ptp_ocp_debugfs_fini();
Annotation
- Immediate include surface: `linux/bits.h`, `linux/err.h`, `linux/kernel.h`, `linux/module.h`, `linux/debugfs.h`, `linux/init.h`, `linux/pci.h`, `linux/serial_8250.h`.
- Detected declarations: `struct ocp_reg`, `struct ptp_ocp_servo_conf`, `struct ptp_ocp_adva_info`, `struct tod_reg`, `struct ts_reg`, `struct pps_reg`, `struct img_reg`, `struct gpio_reg`, `struct irig_master_reg`, `struct irig_slave_reg`.
- Atlas domain: Driver Families / drivers/ptp.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.