drivers/s390/block/dasd_proc.c

Source file repositories/reference/linux-study-clean/drivers/s390/block/dasd_proc.c

File Facts

System
Linux kernel
Corpus path
drivers/s390/block/dasd_proc.c
Extension
.c
Size
9717 bytes
Lines
369
Domain
Driver Families
Bucket
drivers/s390
Inferred role
Driver Families: implementation source
Status
source 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

if (strcmp(str, "on") == 0) {
			/* switch on statistics profiling */
			rc = dasd_stats_all_block_on();
			if (rc) {
				dasd_stats_all_block_off();
				goto out_error;
			}
			rc = dasd_profile_on(&dasd_global_profile);
			if (rc) {
				dasd_stats_all_block_off();
				goto out_error;
			}
			dasd_profile_reset(&dasd_global_profile);
			dasd_global_profile_level = DASD_PROFILE_ON;
			pr_info("The statistics feature has been switched "
				"on\n");
		} else if (strcmp(str, "off") == 0) {
			/* switch off statistics profiling */
			dasd_global_profile_level = DASD_PROFILE_OFF;
			dasd_profile_off(&dasd_global_profile);
			dasd_stats_all_block_off();
			pr_info("The statistics feature has been switched "
				"off\n");
		} else
			goto out_parse_error;
	} else if (strncmp(str, "reset", 5) == 0) {
		/* reset the statistics */
		dasd_profile_reset(&dasd_global_profile);
		dasd_stats_all_block_reset();
		pr_info("The statistics have been reset\n");
	} else
		goto out_parse_error;
	vfree(buffer);
	return user_len;
out_parse_error:
	rc = -EINVAL;
	pr_warn("%s is not a supported value for /proc/dasd/statistics\n", str);
out_error:
	vfree(buffer);
	return rc;
#else
	pr_warn("/proc/dasd/statistics: is not activated in this kernel\n");
	return user_len;
#endif				/* CONFIG_DASD_PROFILE */
}

static const struct proc_ops dasd_stats_proc_ops = {
	.proc_open	= dasd_stats_proc_open,
	.proc_read	= seq_read,
	.proc_lseek	= seq_lseek,
	.proc_release	= single_release,
	.proc_write	= dasd_stats_proc_write,
};

/*
 * Create dasd proc-fs entries.
 * In case creation failed, cleanup and return -ENOENT.
 */
int
dasd_proc_init(void)
{
	dasd_proc_root_entry = proc_mkdir("dasd", NULL);
	if (!dasd_proc_root_entry)
		goto out_nodasd;
	dasd_devices_entry = proc_create_seq("devices", 0444,
					 dasd_proc_root_entry,
					 &dasd_devices_seq_ops);
	if (!dasd_devices_entry)
		goto out_nodevices;
	dasd_statistics_entry = proc_create("statistics",
					    S_IFREG | S_IRUGO | S_IWUSR,
					    dasd_proc_root_entry,
					    &dasd_stats_proc_ops);
	if (!dasd_statistics_entry)
		goto out_nostatistics;
	return 0;

 out_nostatistics:
	remove_proc_entry("devices", dasd_proc_root_entry);
 out_nodevices:
	remove_proc_entry("dasd", NULL);
	dasd_proc_root_entry = NULL;
 out_nodasd:
	return -ENOENT;
}

void
dasd_proc_exit(void)
{
	if (!dasd_proc_root_entry)

Annotation

Implementation Notes