Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)     Dell Airplane Mode Switch driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)     Copyright (C) 2014-2015  Pali Rohár <pali@kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/rfkill.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "dell-rbtn.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) enum rbtn_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	RBTN_UNKNOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	RBTN_TOGGLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	RBTN_SLIDER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) struct rbtn_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	enum rbtn_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	struct rfkill *rfkill;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	bool suspended;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * acpi functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static enum rbtn_type rbtn_check(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	unsigned long long output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	status = acpi_evaluate_integer(device->handle, "CRBT", NULL, &output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		return RBTN_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	switch (output) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		return RBTN_TOGGLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	case 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		return RBTN_SLIDER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		return RBTN_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) static int rbtn_get(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	unsigned long long output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	status = acpi_evaluate_integer(device->handle, "GRBT", NULL, &output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	return !output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) static int rbtn_acquire(struct acpi_device *device, bool enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct acpi_object_list input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	union acpi_object param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	param.type = ACPI_TYPE_INTEGER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	param.integer.value = enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	input.count = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	input.pointer = &param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	status = acpi_evaluate_object(device->handle, "ARBT", &input, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  * rfkill device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) static void rbtn_rfkill_query(struct rfkill *rfkill, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	struct acpi_device *device = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	int state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	state = rbtn_get(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	if (state < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	rfkill_set_states(rfkill, state, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static int rbtn_rfkill_set_block(void *data, bool blocked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	/* NOTE: setting soft rfkill state is not supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static const struct rfkill_ops rbtn_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	.query = rbtn_rfkill_query,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	.set_block = rbtn_rfkill_set_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static int rbtn_rfkill_init(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	struct rbtn_data *rbtn_data = device->driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (rbtn_data->rfkill)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	 * NOTE: rbtn controls all radio devices, not only WLAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	 *       but rfkill interface does not support "ANY" type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	 *       so "WLAN" type is used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	rbtn_data->rfkill = rfkill_alloc("dell-rbtn", &device->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 					 RFKILL_TYPE_WLAN, &rbtn_ops, device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	if (!rbtn_data->rfkill)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	ret = rfkill_register(rbtn_data->rfkill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		rfkill_destroy(rbtn_data->rfkill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		rbtn_data->rfkill = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static void rbtn_rfkill_exit(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	struct rbtn_data *rbtn_data = device->driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	if (!rbtn_data->rfkill)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	rfkill_unregister(rbtn_data->rfkill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	rfkill_destroy(rbtn_data->rfkill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	rbtn_data->rfkill = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static void rbtn_rfkill_event(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	struct rbtn_data *rbtn_data = device->driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	if (rbtn_data->rfkill)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		rbtn_rfkill_query(rbtn_data->rfkill, device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * input device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static int rbtn_input_init(struct rbtn_data *rbtn_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	rbtn_data->input_dev = input_allocate_device();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	if (!rbtn_data->input_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	rbtn_data->input_dev->name = "DELL Wireless hotkeys";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	rbtn_data->input_dev->phys = "dellabce/input0";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	rbtn_data->input_dev->id.bustype = BUS_HOST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	rbtn_data->input_dev->evbit[0] = BIT(EV_KEY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	set_bit(KEY_RFKILL, rbtn_data->input_dev->keybit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	ret = input_register_device(rbtn_data->input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		input_free_device(rbtn_data->input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		rbtn_data->input_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) static void rbtn_input_exit(struct rbtn_data *rbtn_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	input_unregister_device(rbtn_data->input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	rbtn_data->input_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) static void rbtn_input_event(struct rbtn_data *rbtn_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	input_report_key(rbtn_data->input_dev, KEY_RFKILL, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	input_sync(rbtn_data->input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	input_report_key(rbtn_data->input_dev, KEY_RFKILL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	input_sync(rbtn_data->input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)  * acpi driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) static int rbtn_add(struct acpi_device *device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static int rbtn_remove(struct acpi_device *device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static void rbtn_notify(struct acpi_device *device, u32 event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) static const struct acpi_device_id rbtn_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	{ "DELRBTN", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	{ "DELLABCE", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	 * This driver can also handle the "DELLABC6" device that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	 * appears on the XPS 13 9350, but that device is disabled by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	 * the DSDT unless booted with acpi_osi="!Windows 2012"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	 * acpi_osi="!Windows 2013".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	 * According to Mario at Dell:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	 *  DELLABC6 is a custom interface that was created solely to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	 *  have airplane mode support for Windows 7.  For Windows 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	 *  the proper interface is to use that which is handled by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	 *  intel-hid. A OEM airplane mode driver is not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	 *  Since the kernel doesn't identify as Windows 7 it would be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	 *  incorrect to do attempt to use that interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	 * Even if we override _OSI and bind to DELLABC6, we end up with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	 * inconsistent behavior in which userspace can get out of sync
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	 * with the rfkill state as it conflicts with events from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	 * intel-hid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	 * The upshot is that it is better to just ignore DELLABC6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	 * devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	{ "", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) #ifdef CONFIG_PM_SLEEP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static void ACPI_SYSTEM_XFACE rbtn_clear_suspended_flag(void *context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	struct rbtn_data *rbtn_data = context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	rbtn_data->suspended = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) static int rbtn_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	struct acpi_device *device = to_acpi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	struct rbtn_data *rbtn_data = acpi_driver_data(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	rbtn_data->suspended = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) static int rbtn_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	struct acpi_device *device = to_acpi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	struct rbtn_data *rbtn_data = acpi_driver_data(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	 * Upon resume, some BIOSes send an ACPI notification thet triggers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	 * an unwanted input event. In order to ignore it, we use a flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	 * that we set at suspend and clear once we have received the extra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	 * ACPI notification. Since ACPI notifications are delivered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	 * asynchronously to drivers, we clear the flag from the workqueue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	 * used to deliver the notifications. This should be enough
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	 * to have the flag cleared only after we received the extra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	 * notification, if any.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	status = acpi_os_execute(OSL_NOTIFY_HANDLER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 			 rbtn_clear_suspended_flag, rbtn_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		rbtn_clear_suspended_flag(rbtn_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) static SIMPLE_DEV_PM_OPS(rbtn_pm_ops, rbtn_suspend, rbtn_resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) static struct acpi_driver rbtn_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	.name = "dell-rbtn",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	.ids = rbtn_ids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	.drv.pm = &rbtn_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	.ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		.add = rbtn_add,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		.remove = rbtn_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		.notify = rbtn_notify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)  * notifier export functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) static bool auto_remove_rfkill = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) static ATOMIC_NOTIFIER_HEAD(rbtn_chain_head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) static int rbtn_inc_count(struct device *dev, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	struct acpi_device *device = to_acpi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	struct rbtn_data *rbtn_data = device->driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	int *count = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	if (rbtn_data->type == RBTN_SLIDER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		(*count)++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) static int rbtn_switch_dev(struct device *dev, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	struct acpi_device *device = to_acpi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	struct rbtn_data *rbtn_data = device->driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	bool enable = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	if (rbtn_data->type != RBTN_SLIDER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	if (enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		rbtn_rfkill_init(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		rbtn_rfkill_exit(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) int dell_rbtn_notifier_register(struct notifier_block *nb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	bool first;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	ret = driver_for_each_device(&rbtn_driver.drv, NULL, &count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 				     rbtn_inc_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	if (ret || count == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	first = !rbtn_chain_head.head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	ret = atomic_notifier_chain_register(&rbtn_chain_head, nb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	if (auto_remove_rfkill && first)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		ret = driver_for_each_device(&rbtn_driver.drv, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 					     (void *)false, rbtn_switch_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) EXPORT_SYMBOL_GPL(dell_rbtn_notifier_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) int dell_rbtn_notifier_unregister(struct notifier_block *nb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	ret = atomic_notifier_chain_unregister(&rbtn_chain_head, nb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	if (auto_remove_rfkill && !rbtn_chain_head.head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		ret = driver_for_each_device(&rbtn_driver.drv, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 					     (void *)true, rbtn_switch_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) EXPORT_SYMBOL_GPL(dell_rbtn_notifier_unregister);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)  * acpi driver functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) static int rbtn_add(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	struct rbtn_data *rbtn_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	enum rbtn_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	type = rbtn_check(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	if (type == RBTN_UNKNOWN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		dev_info(&device->dev, "Unknown device type\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	ret = rbtn_acquire(device, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		dev_err(&device->dev, "Cannot enable device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	rbtn_data = devm_kzalloc(&device->dev, sizeof(*rbtn_data), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	if (!rbtn_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	rbtn_data->type = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	device->driver_data = rbtn_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	switch (rbtn_data->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	case RBTN_TOGGLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		ret = rbtn_input_init(rbtn_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	case RBTN_SLIDER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		if (auto_remove_rfkill && rbtn_chain_head.head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 			ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			ret = rbtn_rfkill_init(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) static int rbtn_remove(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	struct rbtn_data *rbtn_data = device->driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	switch (rbtn_data->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	case RBTN_TOGGLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 		rbtn_input_exit(rbtn_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	case RBTN_SLIDER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		rbtn_rfkill_exit(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	rbtn_acquire(device, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	device->driver_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) static void rbtn_notify(struct acpi_device *device, u32 event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	struct rbtn_data *rbtn_data = device->driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	 * Some BIOSes send a notification at resume.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	 * Ignore it to prevent unwanted input events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	if (rbtn_data->suspended) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		dev_dbg(&device->dev, "ACPI notification ignored\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	if (event != 0x80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 		dev_info(&device->dev, "Received unknown event (0x%x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 			 event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	switch (rbtn_data->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	case RBTN_TOGGLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 		rbtn_input_event(rbtn_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	case RBTN_SLIDER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 		rbtn_rfkill_event(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 		atomic_notifier_call_chain(&rbtn_chain_head, event, device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)  * module functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) module_acpi_driver(rbtn_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) module_param(auto_remove_rfkill, bool, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) MODULE_PARM_DESC(auto_remove_rfkill, "Automatically remove rfkill devices when "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 				     "other modules start receiving events "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 				     "from this module and re-add them when "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 				     "the last module stops receiving events "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 				     "(default true)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) MODULE_DEVICE_TABLE(acpi, rbtn_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) MODULE_DESCRIPTION("Dell Airplane Mode Switch driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) MODULE_AUTHOR("Pali Rohár <pali@kernel.org>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) MODULE_LICENSE("GPL");