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.

Dependency Surface

Detected Declarations

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

Implementation Notes