static int greybus_remove()

in core.c [225:266]


static int greybus_remove(struct device *dev)
{
	struct greybus_driver *driver = to_greybus_driver(dev->driver);
	struct gb_bundle *bundle = to_gb_bundle(dev);
	struct gb_connection *connection;
	int retval;

	retval = pm_runtime_get_sync(dev);
	if (retval < 0)
		dev_err(dev, "failed to resume bundle: %d\n", retval);

	/*
	 * Disable (non-offloaded) connections early in case the interface is
	 * already gone to avoid unceccessary operation timeouts during
	 * driver disconnect. Otherwise, only disable incoming requests.
	 */
	list_for_each_entry(connection, &bundle->connections, bundle_links) {
		if (gb_connection_is_offloaded(connection))
			continue;

		if (bundle->intf->disconnected)
			gb_connection_disable_forced(connection);
		else
			gb_connection_disable_rx(connection);
	}

	driver->disconnect(bundle);

	/* Catch buggy drivers that fail to destroy their connections. */
	WARN_ON(!list_empty(&bundle->connections));

	if (!bundle->intf->disconnected)
		gb_control_bundle_deactivate(bundle->intf->control, bundle->id);

	pm_runtime_put_noidle(dev);
	pm_runtime_disable(dev);
	pm_runtime_set_suspended(dev);
	pm_runtime_dont_use_autosuspend(dev);
	pm_runtime_put_noidle(dev);

	return 0;
}