drivers/hid/intel-ish-hid/ishtp/bus.c

Source file repositories/reference/linux-study-clean/drivers/hid/intel-ish-hid/ishtp/bus.c

File Facts

System
Linux kernel
Corpus path
drivers/hid/intel-ish-hid/ishtp/bus.c
Extension
.c
Size
24775 bytes
Lines
958
Domain
Driver Families
Bucket
drivers/hid
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

static int ishtp_cl_bus_match(struct device *dev, const struct device_driver *drv)
{
	struct ishtp_cl_device *device = to_ishtp_cl_device(dev);
	struct ishtp_cl_driver *driver = to_ishtp_cl_driver(drv);
	struct ishtp_fw_client *client = device->fw_client;
	const struct ishtp_device_id *id;

	if (client) {
		for (id = driver->id; !guid_is_null(&id->guid); id++) {
			if (guid_equal(&id->guid, &client->props.protocol_name))
				return 1;
		}
	}

	return 0;
}

/**
 * ishtp_cl_device_remove() - Bus remove() callback
 * @dev: the device structure
 *
 * This is a bus remove callback and calls the drive remove function.
 * Since the ISH driver model supports only built in, this is
 * primarily can be called during pci driver init failure.
 *
 * Return: Return value from driver remove() call.
 */
static void ishtp_cl_device_remove(struct device *dev)
{
	struct ishtp_cl_device *device = to_ishtp_cl_device(dev);
	struct ishtp_cl_driver *driver = to_ishtp_cl_driver(dev->driver);

	if (device->event_cb) {
		device->event_cb = NULL;
		cancel_work_sync(&device->event_work);
	}

	if (driver->remove)
		driver->remove(device);
}

/**
 * ishtp_cl_device_suspend() - Bus suspend callback
 * @dev:	device
 *
 * Called during device suspend process.
 *
 * Return: Return value from driver suspend() call.
 */
static int ishtp_cl_device_suspend(struct device *dev)
{
	struct ishtp_cl_device *device = to_ishtp_cl_device(dev);
	struct ishtp_cl_driver *driver;
	int ret = 0;

	if (!device)
		return 0;

	driver = to_ishtp_cl_driver(dev->driver);
	if (driver && driver->driver.pm) {
		if (driver->driver.pm->suspend)
			ret = driver->driver.pm->suspend(dev);
	}

	return ret;
}

/**
 * ishtp_cl_device_resume() - Bus resume callback
 * @dev:	device
 *
 * Called during device resume process.
 *
 * Return: Return value from driver resume() call.
 */
static int ishtp_cl_device_resume(struct device *dev)
{
	struct ishtp_cl_device *device = to_ishtp_cl_device(dev);
	struct ishtp_cl_driver *driver;
	int ret = 0;

	if (!device)
		return 0;

	driver = to_ishtp_cl_driver(dev->driver);
	if (driver && driver->driver.pm) {
		if (driver->driver.pm->resume)
			ret = driver->driver.pm->resume(dev);
	}

Annotation

Implementation Notes