net/nfc/core.c

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

File Facts

System
Linux kernel
Corpus path
net/nfc/core.c
Extension
.c
Size
25561 bytes
Lines
1274
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: exported/initcall integration point
Status
integration 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

rc = device_add(&dev->dev);
	mutex_unlock(&nfc_devlist_mutex);

	if (rc < 0)
		return rc;

	rc = nfc_llcp_register_device(dev);
	if (rc)
		pr_err("Could not register llcp device\n");

	device_lock(&dev->dev);
	dev->rfkill = rfkill_alloc(dev_name(&dev->dev), &dev->dev,
				   RFKILL_TYPE_NFC, &nfc_rfkill_ops, dev);
	if (dev->rfkill) {
		if (rfkill_register(dev->rfkill) < 0) {
			rfkill_destroy(dev->rfkill);
			dev->rfkill = NULL;
		}
	}
	dev->shutting_down = false;
	device_unlock(&dev->dev);

	rc = nfc_genl_device_added(dev);
	if (rc)
		pr_debug("The userspace won't be notified that the device %s was added\n",
			 dev_name(&dev->dev));

	return 0;
}
EXPORT_SYMBOL(nfc_register_device);

/**
 * nfc_unregister_rfkill - unregister a nfc device in the rfkill subsystem
 *
 * @dev: The nfc device to unregister
 */
void nfc_unregister_rfkill(struct nfc_dev *dev)
{
	struct rfkill *rfk = NULL;
	int rc;

	pr_debug("dev_name=%s\n", dev_name(&dev->dev));

	rc = nfc_genl_device_removed(dev);
	if (rc)
		pr_debug("The userspace won't be notified that the device %s "
			 "was removed\n", dev_name(&dev->dev));

	device_lock(&dev->dev);
	if (dev->rfkill) {
		rfk = dev->rfkill;
		dev->rfkill = NULL;
	}
	dev->shutting_down = true;
	device_unlock(&dev->dev);

	if (rfk) {
		rfkill_unregister(rfk);
		rfkill_destroy(rfk);
	}
}
EXPORT_SYMBOL(nfc_unregister_rfkill);

/**
 * nfc_remove_device - remove a nfc device in the nfc subsystem
 *
 * @dev: The nfc device to remove
 */
void nfc_remove_device(struct nfc_dev *dev)
{
	if (dev->ops->check_presence) {
		timer_delete_sync(&dev->check_pres_timer);
		cancel_work_sync(&dev->check_pres_work);
	}

	nfc_llcp_unregister_device(dev);

	mutex_lock(&nfc_devlist_mutex);
	nfc_devlist_generation++;
	device_del(&dev->dev);
	mutex_unlock(&nfc_devlist_mutex);
}
EXPORT_SYMBOL(nfc_remove_device);

/**
 * nfc_unregister_device - unregister a nfc device in the nfc subsystem
 *
 * @dev: The nfc device to unregister
 */
void nfc_unregister_device(struct nfc_dev *dev)

Annotation

Implementation Notes