drivers/net/wan/framer/framer-core.c

Source file repositories/reference/linux-study-clean/drivers/net/wan/framer/framer-core.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wan/framer/framer-core.c
Extension
.c
Size
23089 bytes
Lines
874
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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

ret = device_add(&framer->dev);
	if (ret)
		goto put_dev;

	if (pm_runtime_enabled(dev)) {
		pm_runtime_enable(&framer->dev);
		pm_runtime_no_callbacks(&framer->dev);
	}

	return framer;

put_dev:
	put_device(&framer->dev);  /* calls framer_release() which frees resources */
	return ERR_PTR(ret);

free_framer:
	kfree(framer);
	return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(framer_create);

/**
 * framer_destroy() - destroy the framer
 * @framer: the framer to be destroyed
 *
 * Called to destroy the framer.
 */
void framer_destroy(struct framer *framer)
{
	/* polling_work should already be stopped but if framer_exit() was not
	 * called (bug), here it's the last time to do that ...
	 */
	cancel_delayed_work_sync(&framer->polling_work);
	cancel_work_sync(&framer->notify_status_work);
	pm_runtime_disable(&framer->dev);
	device_unregister(&framer->dev); /* calls framer_release() which frees resources */
}
EXPORT_SYMBOL_GPL(framer_destroy);

static void devm_framer_destroy(struct device *dev, void *res)
{
	struct framer *framer = *(struct framer **)res;

	framer_destroy(framer);
}

/**
 * devm_framer_create() - create a new framer
 * @dev: device that is creating the new framer
 * @node: device node of the framer
 * @ops: function pointers for performing framer operations
 *
 * Creates a new framer device adding it to the framer class.
 * While at that, it also associates the device with the framer using devres.
 * On driver detach, release function is invoked on the devres data,
 * then, devres data is freed.
 */
struct framer *devm_framer_create(struct device *dev, struct device_node *node,
				  const struct framer_ops *ops)
{
	struct framer **ptr, *framer;

	ptr = devres_alloc(devm_framer_destroy, sizeof(*ptr), GFP_KERNEL);
	if (!ptr)
		return ERR_PTR(-ENOMEM);

	framer = framer_create(dev, node, ops);
	if (!IS_ERR(framer)) {
		*ptr = framer;
		devres_add(dev, ptr);
	} else {
		devres_free(ptr);
	}

	return framer;
}
EXPORT_SYMBOL_GPL(devm_framer_create);

/**
 * framer_provider_simple_of_xlate() - returns the framer instance from framer provider
 * @dev: the framer provider device (not used here)
 * @args: of_phandle_args
 *
 * Intended to be used by framer provider for the common case where #framer-cells is
 * 0. For other cases where #framer-cells is greater than '0', the framer provider
 * should provide a custom of_xlate function that reads the *args* and returns
 * the appropriate framer.
 */
struct framer *framer_provider_simple_of_xlate(struct device *dev,
					       const struct of_phandle_args *args)

Annotation

Implementation Notes