drivers/ata/pata_parport/pata_parport.c
Source file repositories/reference/linux-study-clean/drivers/ata/pata_parport/pata_parport.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ata/pata_parport/pata_parport.c- Extension
.c- Size
- 20990 bytes
- Lines
- 829
- Domain
- Driver Families
- Bucket
- drivers/ata
- 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/module.hlinux/parport.hpata_parport.h
Detected Declarations
struct pi_device_matchfunction claimedfunction pi_disconnectfunction pata_parport_dev_selectfunction pata_parport_set_devctlfunction pata_parport_devchkfunction pata_parport_wait_after_resetfunction pata_parport_bus_softresetfunction pata_parport_softresetfunction pata_parport_check_statusfunction pata_parport_check_altstatusfunction pata_parport_tf_loadfunction pata_parport_tf_readfunction pata_parport_exec_commandfunction pata_parport_data_xferfunction pata_parport_drain_fifofunction pi_releasefunction default_test_protofunction pi_test_protofunction pi_probe_modefunction pi_probe_unitfunction pata_parport_dev_releasefunction pi_find_devfunction pata_parport_register_driverfunction pata_parport_unregister_driverfunction new_device_storefunction idr_for_each_entryfunction pi_remove_onefunction delete_device_storefunction pata_parport_attachfunction pi_remove_portfunction pata_parport_detachfunction pata_parport_initfunction pata_parport_exitmodule init pata_parport_initexport pata_parport_register_driverexport pata_parport_unregister_driver
Annotated Snippet
static const struct bus_type pata_parport_bus_type = {
.name = DRV_NAME,
};
static struct device *pata_parport_bus;
static const struct scsi_host_template pata_parport_sht = {
PATA_PARPORT_SHT("pata_parport")
};
struct pi_device_match {
struct parport *parport;
struct pi_protocol *proto;
};
static int pi_find_dev(struct device *dev, void *data)
{
struct pi_adapter *pi = container_of(dev, struct pi_adapter, dev);
struct pi_device_match *match = data;
return pi->pardev->port == match->parport && pi->proto == match->proto;
}
static struct pi_adapter *pi_init_one(struct parport *parport,
struct pi_protocol *pr, int mode, int unit, int delay)
{
struct pardev_cb par_cb = { };
const struct ata_port_info *ppi[] = { &pata_parport_port_info };
struct ata_host *host;
struct pi_adapter *pi;
struct pi_device_match match = { .parport = parport, .proto = pr };
int id;
/*
* Abort if there's a device already registered on the same parport
* using the same protocol.
*/
if (bus_for_each_dev(&pata_parport_bus_type, NULL, &match, pi_find_dev))
return NULL;
id = ida_alloc(&pata_parport_bus_dev_ids, GFP_KERNEL);
if (id < 0)
return NULL;
pi = kzalloc_obj(struct pi_adapter);
if (!pi) {
ida_free(&pata_parport_bus_dev_ids, id);
return NULL;
}
/* set up pi->dev before pi_probe_unit() so it can use dev_printk() */
pi->dev.parent = pata_parport_bus;
pi->dev.bus = &pata_parport_bus_type;
pi->dev.driver = &pr->driver;
pi->dev.release = pata_parport_dev_release;
pi->dev.id = id;
dev_set_name(&pi->dev, "pata_parport.%u", pi->dev.id);
if (device_register(&pi->dev)) {
put_device(&pi->dev);
/* pata_parport_dev_release will do ida_free(dev->id) and kfree(pi) */
return NULL;
}
pi->proto = pr;
if (!try_module_get(pi->proto->owner))
goto out_unreg_dev;
if (pi->proto->init_proto && pi->proto->init_proto(pi) < 0)
goto out_module_put;
pi->delay = (delay == -1) ? pi->proto->default_delay : delay;
pi->mode = mode;
pi->port = parport->base;
par_cb.private = pi;
pi->pardev = parport_register_dev_model(parport, DRV_NAME, &par_cb, id);
if (!pi->pardev)
goto out_module_put;
if (!pi_probe_unit(pi, unit)) {
dev_info(&pi->dev, "Adapter not found\n");
goto out_unreg_parport;
}
pi->proto->log_adapter(pi);
host = ata_host_alloc_pinfo(&pi->pardev->dev, ppi, 1);
if (!host)
goto out_unreg_parport;
dev_set_drvdata(&pi->dev, host);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/parport.h`, `pata_parport.h`.
- Detected declarations: `struct pi_device_match`, `function claimed`, `function pi_disconnect`, `function pata_parport_dev_select`, `function pata_parport_set_devctl`, `function pata_parport_devchk`, `function pata_parport_wait_after_reset`, `function pata_parport_bus_softreset`, `function pata_parport_softreset`, `function pata_parport_check_status`.
- Atlas domain: Driver Families / drivers/ata.
- 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.