net/rfkill/core.c

Source file repositories/reference/linux-study-clean/net/rfkill/core.c

File Facts

System
Linux kernel
Corpus path
net/rfkill/core.c
Extension
.c
Size
33957 bytes
Lines
1474
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct file_operations rfkill_fops = {
	.owner		= THIS_MODULE,
	.open		= rfkill_fop_open,
	.read		= rfkill_fop_read,
	.write		= rfkill_fop_write,
	.poll		= rfkill_fop_poll,
	.release	= rfkill_fop_release,
	.unlocked_ioctl	= rfkill_fop_ioctl,
	.compat_ioctl	= compat_ptr_ioctl,
};

#define RFKILL_NAME "rfkill"

static struct miscdevice rfkill_miscdev = {
	.fops	= &rfkill_fops,
	.name	= RFKILL_NAME,
	.minor	= RFKILL_MINOR,
};

static int __init rfkill_init(void)
{
	int error;

	rfkill_update_global_state(RFKILL_TYPE_ALL, !rfkill_default_state);

	error = class_register(&rfkill_class);
	if (error)
		goto error_class;

	error = misc_register(&rfkill_miscdev);
	if (error)
		goto error_misc;

	error = rfkill_global_led_trigger_register();
	if (error)
		goto error_led_trigger;

#ifdef CONFIG_RFKILL_INPUT
	error = rfkill_handler_init();
	if (error)
		goto error_input;
#endif

	return 0;

#ifdef CONFIG_RFKILL_INPUT
error_input:
	rfkill_global_led_trigger_unregister();
#endif
error_led_trigger:
	misc_deregister(&rfkill_miscdev);
error_misc:
	class_unregister(&rfkill_class);
error_class:
	return error;
}
subsys_initcall(rfkill_init);

static void __exit rfkill_exit(void)
{
#ifdef CONFIG_RFKILL_INPUT
	rfkill_handler_exit();
#endif
	rfkill_global_led_trigger_unregister();
	misc_deregister(&rfkill_miscdev);
	class_unregister(&rfkill_class);
}
module_exit(rfkill_exit);

MODULE_ALIAS_MISCDEV(RFKILL_MINOR);
MODULE_ALIAS("devname:" RFKILL_NAME);

Annotation

Implementation Notes