drivers/misc/ibmasm/ibmasmfs.c

Source file repositories/reference/linux-study-clean/drivers/misc/ibmasm/ibmasmfs.c

File Facts

System
Linux kernel
Corpus path
drivers/misc/ibmasm/ibmasmfs.c
Extension
.c
Size
14339 bytes
Lines
605
Domain
Driver Families
Bucket
drivers/misc
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

const struct file_operations *fops,
			void *data,
			int mode)
{
	struct dentry *dentry;
	struct inode *inode;

	dentry = d_alloc_name(parent, name);
	if (!dentry)
		return -ENOMEM;

	inode = ibmasmfs_make_inode(parent->d_sb, S_IFREG | mode);
	if (!inode) {
		dput(dentry);
		return -ENOMEM;
	}

	inode->i_fop = fops;
	inode->i_private = data;

	d_make_persistent(dentry, inode);
	dput(dentry);
	return 0;
}

static struct dentry *ibmasmfs_create_dir(struct dentry *parent,
				const char *name)
{
	struct dentry *dentry;
	struct inode *inode;

	dentry = d_alloc_name(parent, name);
	if (!dentry)
		return NULL;

	inode = ibmasmfs_make_inode(parent->d_sb, S_IFDIR | 0500);
	if (!inode) {
		dput(dentry);
		return NULL;
	}

	inode->i_op = &simple_dir_inode_operations;
	inode->i_fop = &simple_dir_operations;

	d_make_persistent(dentry, inode);
	dput(dentry);
	return dentry; // borrowed
}

int ibmasmfs_register(void)
{
	return register_filesystem(&ibmasmfs_type);
}

void ibmasmfs_unregister(void)
{
	unregister_filesystem(&ibmasmfs_type);
}

void ibmasmfs_add_sp(struct service_processor *sp)
{
	list_add(&sp->node, &service_processors);
}

/* struct to save state between command file operations */
struct ibmasmfs_command_data {
	struct service_processor	*sp;
	struct command			*command;
};

/* struct to save state between event file operations */
struct ibmasmfs_event_data {
	struct service_processor	*sp;
	struct event_reader		reader;
	int				active;
};

/* struct to save state between reverse heartbeat file operations */
struct ibmasmfs_heartbeat_data {
	struct service_processor	*sp;
	struct reverse_heartbeat	heartbeat;
	int				active;
};

static int command_file_open(struct inode *inode, struct file *file)
{
	struct ibmasmfs_command_data *command_data;

	if (!inode->i_private)
		return -ENODEV;

Annotation

Implementation Notes