drivers/ata/libata-transport.c
Source file repositories/reference/linux-study-clean/drivers/ata/libata-transport.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ata/libata-transport.c- Extension
.c- Size
- 20623 bytes
- Lines
- 804
- Domain
- Driver Families
- Bucket
- drivers/ata
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/blkdev.hlinux/spinlock.hlinux/slab.hscsi/scsi_transport.hlinux/libata.hlinux/hdreg.hlinux/uaccess.hlinux/pm_runtime.hlibata.hlibata-transport.h
Detected Declarations
struct ata_show_ering_argfunction ata_tport_releasefunction ata_is_portfunction ata_tport_matchfunction ata_tport_deletefunction ata_tport_addfunction ata_dev_classifyfunction ata_show_eringfunction show_ata_dev_eringfunction show_ata_dev_idfunction show_ata_dev_gscrfunction show_ata_dev_trimfunction ata_tdev_releasefunction ata_tdev_addfunction ata_tdev_deletefunction ata_tdev_addfunction noopfunction ata_tlink_releasefunction devicefunction ata_for_each_devfunction ata_tlink_addfunction ata_for_each_devfunction ata_tlink_matchfunction ata_tdev_matchfunction libata_transport_initfunction libata_transport_exitexport ata_tport_deleteexport ata_tport_addexport ata_port_classify
Annotated Snippet
error = device_add(dev);
if (error) {
goto tport_err;
}
device_enable_async_suspend(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
pm_runtime_forbid(dev);
error = transport_add_device(dev);
if (error)
goto tport_transport_add_err;
transport_configure_device(dev);
error = ata_tlink_add(&ap->link);
if (error) {
goto tport_link_err;
}
return 0;
tport_link_err:
transport_remove_device(dev);
tport_transport_add_err:
device_del(dev);
tport_err:
transport_destroy_device(dev);
put_device(dev);
return error;
}
EXPORT_SYMBOL_GPL(ata_tport_add);
/**
* ata_port_classify - determine device type based on ATA-spec signature
* @ap: ATA port device on which the classification should be run
* @tf: ATA taskfile register set for device to be identified
*
* A wrapper around ata_dev_classify() to provide additional logging
*
* RETURNS:
* Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP,
* %ATA_DEV_ZAC, or %ATA_DEV_UNKNOWN the event of failure.
*/
unsigned int ata_port_classify(struct ata_port *ap,
const struct ata_taskfile *tf)
{
int i;
unsigned int class = ata_dev_classify(tf);
/* Start with index '1' to skip the 'unknown' entry */
for (i = 1; i < ARRAY_SIZE(ata_class_names); i++) {
if (ata_class_names[i].value == class) {
ata_port_dbg(ap, "found %s device by sig\n",
ata_class_names[i].name);
return class;
}
}
ata_port_info(ap, "found unknown device (class %u)\n", class);
return class;
}
EXPORT_SYMBOL_GPL(ata_port_classify);
/*
* ATA device attributes
*/
#define ata_dev_show_class(title, field) \
static ssize_t \
show_ata_dev_##field(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
struct ata_device *ata_dev = transport_class_to_dev(dev); \
\
return get_ata_##title##_names(ata_dev->field, buf); \
}
#define ata_dev_attr(title, field) \
ata_dev_show_class(title, field) \
static DEVICE_ATTR(field, S_IRUGO, show_ata_dev_##field, NULL)
ata_dev_attr(class, class);
ata_dev_attr(xfer, pio_mode);
ata_dev_attr(xfer, dma_mode);
ata_dev_attr(xfer, xfer_mode);
#define ata_dev_show_simple(field, format_string, cast) \
static ssize_t \
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/blkdev.h`, `linux/spinlock.h`, `linux/slab.h`, `scsi/scsi_transport.h`, `linux/libata.h`, `linux/hdreg.h`, `linux/uaccess.h`.
- Detected declarations: `struct ata_show_ering_arg`, `function ata_tport_release`, `function ata_is_port`, `function ata_tport_match`, `function ata_tport_delete`, `function ata_tport_add`, `function ata_dev_classify`, `function ata_show_ering`, `function show_ata_dev_ering`, `function show_ata_dev_id`.
- Atlas domain: Driver Families / drivers/ata.
- Implementation status: integration implementation candidate.
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.