drivers/scsi/megaraid/megaraid_mbox.c

Source file repositories/reference/linux-study-clean/drivers/scsi/megaraid/megaraid_mbox.c

File Facts

System
Linux kernel
Corpus path
drivers/scsi/megaraid/megaraid_mbox.c
Extension
.c
Size
99873 bytes
Lines
4070
Domain
Driver Families
Bucket
drivers/scsi
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.

Dependency Surface

Detected Declarations

Annotated Snippet

static struct pci_driver megaraid_pci_driver = {
	.name		= "megaraid",
	.id_table	= pci_id_table_g,
	.probe		= megaraid_probe_one,
	.remove		= megaraid_detach_one,
	.shutdown	= megaraid_mbox_shutdown,
};



// definitions for the device attributes for exporting logical drive number
// for a scsi address (Host, Channel, Id, Lun)

static DEVICE_ATTR_ADMIN_RO(megaraid_mbox_app_hndl);

// Host template initializer for megaraid mbox sysfs device attributes
static struct attribute *megaraid_shost_attrs[] = {
	&dev_attr_megaraid_mbox_app_hndl.attr,
	NULL,
};

ATTRIBUTE_GROUPS(megaraid_shost);

static DEVICE_ATTR_ADMIN_RO(megaraid_mbox_ld);

// Host template initializer for megaraid mbox sysfs device attributes
static struct attribute *megaraid_sdev_attrs[] = {
	&dev_attr_megaraid_mbox_ld.attr,
	NULL,
};

ATTRIBUTE_GROUPS(megaraid_sdev);

/*
 * Scsi host template for megaraid unified driver
 */
static const struct scsi_host_template megaraid_template_g = {
	.module				= THIS_MODULE,
	.name				= "LSI Logic MegaRAID driver",
	.proc_name			= "megaraid",
	.queuecommand			= megaraid_queue_command,
	.eh_abort_handler		= megaraid_abort_handler,
	.eh_host_reset_handler		= megaraid_reset_handler,
	.change_queue_depth		= scsi_change_queue_depth,
	.no_write_same			= 1,
	.sdev_groups			= megaraid_sdev_groups,
	.shost_groups			= megaraid_shost_groups,
};


/**
 * megaraid_init - module load hook
 *
 * We register ourselves as hotplug enabled module and let PCI subsystem
 * discover our adapters.
 */
static int __init
megaraid_init(void)
{
	int	rval;

	// Announce the driver version
	con_log(CL_ANN, (KERN_INFO "megaraid: %s %s\n", MEGARAID_VERSION,
		MEGARAID_EXT_VERSION));

	// check validity of module parameters
	if (megaraid_cmd_per_lun > MBOX_MAX_SCSI_CMDS) {

		con_log(CL_ANN, (KERN_WARNING
			"megaraid mailbox: max commands per lun reset to %d\n",
			MBOX_MAX_SCSI_CMDS));

		megaraid_cmd_per_lun = MBOX_MAX_SCSI_CMDS;
	}


	// register as a PCI hot-plug driver module
	rval = pci_register_driver(&megaraid_pci_driver);
	if (rval < 0) {
		con_log(CL_ANN, (KERN_WARNING
			"megaraid: could not register hotplug support.\n"));
	}

	return rval;
}


/**
 * megaraid_exit - driver unload entry point
 *

Annotation

Implementation Notes