drivers/scsi/mpt3sas/mpt3sas_ctl.c

Source file repositories/reference/linux-study-clean/drivers/scsi/mpt3sas/mpt3sas_ctl.c

File Facts

System
Linux kernel
Corpus path
drivers/scsi/mpt3sas/mpt3sas_ctl.c
Extension
.c
Size
127810 bytes
Lines
4519
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 const struct file_operations ctl_fops = {
	.owner = THIS_MODULE,
	.unlocked_ioctl = _ctl_ioctl,
	.poll = _ctl_poll,
	.fasync = _ctl_fasync,
#ifdef CONFIG_COMPAT
	.compat_ioctl = _ctl_ioctl_compat,
#endif
};

/* file operations table for mpt2ctl device */
static const struct file_operations ctl_gen2_fops = {
	.owner = THIS_MODULE,
	.unlocked_ioctl = _ctl_mpt2_ioctl,
	.poll = _ctl_poll,
	.fasync = _ctl_fasync,
#ifdef CONFIG_COMPAT
	.compat_ioctl = _ctl_mpt2_ioctl_compat,
#endif
};

static struct miscdevice ctl_dev = {
	.minor  = MPT3SAS_MINOR,
	.name   = MPT3SAS_DEV_NAME,
	.fops   = &ctl_fops,
};

static struct miscdevice gen2_ctl_dev = {
	.minor  = MPT2SAS_MINOR,
	.name   = MPT2SAS_DEV_NAME,
	.fops   = &ctl_gen2_fops,
};

/**
 * mpt3sas_ctl_init - main entry point for ctl.
 * @hbas_to_enumerate: ?
 */
void
mpt3sas_ctl_init(ushort hbas_to_enumerate)
{
	async_queue = NULL;

	/* Don't register mpt3ctl ioctl device if
	 * hbas_to_enumarate is one.
	 */
	if (hbas_to_enumerate != 1)
		if (misc_register(&ctl_dev) < 0)
			pr_err("%s can't register misc device [minor=%d]\n",
			    MPT3SAS_DRIVER_NAME, MPT3SAS_MINOR);

	/* Don't register mpt3ctl ioctl device if
	 * hbas_to_enumarate is two.
	 */
	if (hbas_to_enumerate != 2)
		if (misc_register(&gen2_ctl_dev) < 0)
			pr_err("%s can't register misc device [minor=%d]\n",
			    MPT2SAS_DRIVER_NAME, MPT2SAS_MINOR);

	init_waitqueue_head(&ctl_poll_wait);
}

/**
 * mpt3sas_ctl_release - release dma for ctl
 * @ioc: per adapter object
 */
void
mpt3sas_ctl_release(struct MPT3SAS_ADAPTER *ioc)
{
	int i;

	/* free memory associated to diag buffers */
	for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) {
		if (!ioc->diag_buffer[i])
			continue;
		dma_free_coherent(&ioc->pdev->dev,
				  ioc->diag_buffer_sz[i],
				  ioc->diag_buffer[i],
				  ioc->diag_buffer_dma[i]);
		ioc->diag_buffer[i] = NULL;
		ioc->diag_buffer_status[i] = 0;
	}

	kfree(ioc->event_log);
}

/**
 * mpt3sas_ctl_exit - exit point for ctl
 * @hbas_to_enumerate: ?
 */
void

Annotation

Implementation Notes