drivers/acpi/dock.c

Source file repositories/reference/linux-study-clean/drivers/acpi/dock.c

File Facts

System
Linux kernel
Corpus path
drivers/acpi/dock.c
Extension
.c
Size
16559 bytes
Lines
635
Domain
Driver Families
Bucket
drivers/acpi
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

struct dock_station {
	acpi_handle handle;
	unsigned long last_dock_time;
	u32 flags;
	struct list_head dependent_devices;

	struct list_head sibling;
	struct platform_device *dock_device;
};
static LIST_HEAD(dock_stations);
static int dock_station_count;

struct dock_dependent_device {
	struct list_head list;
	struct acpi_device *adev;
};

#define DOCK_DOCKING	0x00000001
#define DOCK_UNDOCKING  0x00000002
#define DOCK_IS_DOCK	0x00000010
#define DOCK_IS_ATA	0x00000020
#define DOCK_IS_BAT	0x00000040
#define DOCK_EVENT	3
#define UNDOCK_EVENT	2

enum dock_callback_type {
	DOCK_CALL_HANDLER,
	DOCK_CALL_FIXUP,
	DOCK_CALL_UEVENT,
};

/*****************************************************************************
 *                         Dock Dependent device functions                   *
 *****************************************************************************/
/**
 * add_dock_dependent_device - associate a device with the dock station
 * @ds: Dock station.
 * @adev: Dependent ACPI device object.
 *
 * Add the dependent device to the dock's dependent device list.
 */
static int add_dock_dependent_device(struct dock_station *ds,
				     struct acpi_device *adev)
{
	struct dock_dependent_device *dd;

	dd = kzalloc_obj(*dd);
	if (!dd)
		return -ENOMEM;

	dd->adev = adev;
	INIT_LIST_HEAD(&dd->list);
	list_add_tail(&dd->list, &ds->dependent_devices);

	return 0;
}

static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event,
			       enum dock_callback_type cb_type)
{
	struct acpi_device *adev = dd->adev;
	acpi_hp_fixup fixup = NULL;
	acpi_hp_uevent uevent = NULL;
	acpi_hp_notify notify = NULL;

	acpi_lock_hp_context();

	if (adev->hp) {
		if (cb_type == DOCK_CALL_FIXUP)
			fixup = adev->hp->fixup;
		else if (cb_type == DOCK_CALL_UEVENT)
			uevent = adev->hp->uevent;
		else
			notify = adev->hp->notify;
	}

	acpi_unlock_hp_context();

	if (fixup)
		fixup(adev);
	else if (uevent)
		uevent(adev, event);
	else if (notify)
		notify(adev, event);
}

static struct dock_station *find_dock_station(acpi_handle handle)
{
	struct dock_station *ds;

Annotation

Implementation Notes