drivers/platform/x86/lenovo/wmi-gamezone.c

Source file repositories/reference/linux-study-clean/drivers/platform/x86/lenovo/wmi-gamezone.c

File Facts

System
Linux kernel
Corpus path
drivers/platform/x86/lenovo/wmi-gamezone.c
Extension
.c
Size
10734 bytes
Lines
410
Domain
Driver Families
Bucket
drivers/platform
Inferred role
Driver Families: implementation source
Status
source 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 lwmi_gz_priv {
	enum thermal_mode current_mode;
	struct notifier_block event_nb;
	struct notifier_block mode_nb;
	spinlock_t gz_mode_lock; /* current_mode lock */
	struct wmi_device *wdev;
	int extreme_supported;
	struct device *ppdev;
};

struct quirk_entry {
	bool extreme_supported;
};

static struct quirk_entry quirk_no_extreme_bug = {
	.extreme_supported = false,
};

/**
 * lwmi_gz_mode_call() - Call method for lenovo-wmi-other driver notifier.
 *
 * @nb: The notifier_block registered to lenovo-wmi-other driver.
 * @cmd: The event type.
 * @data: Thermal mode enum pointer pointer for returning the thermal mode.
 *
 * For LWMI_GZ_GET_THERMAL_MODE, retrieve the current thermal mode.
 *
 * Return: Notifier_block status.
 */
static int lwmi_gz_mode_call(struct notifier_block *nb, unsigned long cmd,
			     void *data)
{
	enum thermal_mode **mode = data;
	struct lwmi_gz_priv *priv;

	priv = container_of(nb, struct lwmi_gz_priv, mode_nb);

	switch (cmd) {
	case LWMI_GZ_GET_THERMAL_MODE:
		scoped_guard(spinlock, &priv->gz_mode_lock) {
			**mode = priv->current_mode;
		}
		return NOTIFY_OK;
	default:
		return NOTIFY_DONE;
	}
}

/**
 * lwmi_gz_event_call() - Call method for lenovo-wmi-events driver notifier.
 * block call chain.
 * @nb: The notifier_block registered to lenovo-wmi-events driver.
 * @cmd: The event type.
 * @data: The data to be updated by the event.
 *
 * For LWMI_EVENT_THERMAL_MODE, set current_mode and notify platform_profile
 * of a change.
 *
 * Return: notifier_block status.
 */
static int lwmi_gz_event_call(struct notifier_block *nb, unsigned long cmd,
			      void *data)
{
	enum thermal_mode *mode = data;
	struct lwmi_gz_priv *priv;

	priv = container_of(nb, struct lwmi_gz_priv, event_nb);

	switch (cmd) {
	case LWMI_EVENT_THERMAL_MODE:
		scoped_guard(spinlock, &priv->gz_mode_lock) {
			priv->current_mode = *mode;
		}
		platform_profile_notify(priv->ppdev);
		return NOTIFY_STOP;
	default:
		return NOTIFY_DONE;
	}
}

/**
 * lwmi_gz_thermal_mode_supported() - Get the version of the WMI
 * interface to determine the support level.
 * @wdev: The Gamezone WMI device.
 * @supported: Pointer to return the support level with.
 *
 * Return: 0 on success, or an error code.
 */
static int lwmi_gz_thermal_mode_supported(struct wmi_device *wdev,
					  int *supported)

Annotation

Implementation Notes