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)  *  HP Compaq TC1100 Tablet WMI Extras Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (C) 2007 Carlos Corbacho <carlos@strangeworlds.co.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  Copyright (C) 2004 Jamey Hicks <jamey.hicks@hp.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define GUID "C364AC71-36DB-495A-8494-B439D472A505"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define TC1100_INSTANCE_WIRELESS		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define TC1100_INSTANCE_JOGDIAL		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) MODULE_AUTHOR("Jamey Hicks, Carlos Corbacho");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) MODULE_DESCRIPTION("HP Compaq TC1100 Tablet WMI Extras");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) MODULE_ALIAS("wmi:C364AC71-36DB-495A-8494-B439D472A505");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static struct platform_device *tc1100_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) struct tc1100_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	u32 wireless;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	u32 jogdial;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) static struct tc1100_data suspend_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) /* --------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 				Device Management
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)    -------------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) static int get_state(u32 *out, u8 instance)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	u32 tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	struct acpi_buffer result = { ACPI_ALLOCATE_BUFFER, NULL };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	union acpi_object *obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	if (!out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	if (instance > 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	status = wmi_query_block(GUID, instance, &result);
^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 -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	obj = (union acpi_object *) result.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	if (obj && obj->type == ACPI_TYPE_INTEGER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		tmp = obj->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		tmp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	if (result.length > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		kfree(result.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	switch (instance) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	case TC1100_INSTANCE_WIRELESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		*out = (tmp == 3) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	case TC1100_INSTANCE_JOGDIAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		*out = (tmp == 1) ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		return -ENODEV;
^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) static int set_state(u32 *in, u8 instance)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	u32 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	struct acpi_buffer input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (!in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	if (instance > 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	switch (instance) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	case TC1100_INSTANCE_WIRELESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		value = (*in) ? 1 : 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	case TC1100_INSTANCE_JOGDIAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		value = (*in) ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	input.length = sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	input.pointer = &value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	status = wmi_set_block(GUID, instance, &input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /* --------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 				FS Interface (/sys)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)    -------------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  * Read/ write bool sysfs macro
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define show_set_bool(value, instance) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static ssize_t \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) show_bool_##value(struct device *dev, struct device_attribute *attr, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	char *buf) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	u32 result; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	acpi_status status = get_state(&result, instance); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	if (ACPI_SUCCESS(status)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		return sprintf(buf, "%d\n", result); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	return sprintf(buf, "Read error\n"); \
^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) static ssize_t \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) set_bool_##value(struct device *dev, struct device_attribute *attr, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	const char *buf, size_t count) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	u32 tmp = simple_strtoul(buf, NULL, 10); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	acpi_status status = set_state(&tmp, instance); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		if (ACPI_FAILURE(status)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			return -EINVAL; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	return count; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) static DEVICE_ATTR(value, S_IRUGO | S_IWUSR, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	show_bool_##value, set_bool_##value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) show_set_bool(wireless, TC1100_INSTANCE_WIRELESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) show_set_bool(jogdial, TC1100_INSTANCE_JOGDIAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static struct attribute *tc1100_attributes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	&dev_attr_wireless.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	&dev_attr_jogdial.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) static struct attribute_group tc1100_attribute_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	.attrs	= tc1100_attributes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /* --------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 				Driver Model
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)    -------------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static int __init tc1100_probe(struct platform_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	return sysfs_create_group(&device->dev.kobj, &tc1100_attribute_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static int tc1100_remove(struct platform_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	sysfs_remove_group(&device->dev.kobj, &tc1100_attribute_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static int tc1100_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	ret = get_state(&suspend_data.wireless, TC1100_INSTANCE_WIRELESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	ret = get_state(&suspend_data.jogdial, TC1100_INSTANCE_JOGDIAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) static int tc1100_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	ret = set_state(&suspend_data.wireless, TC1100_INSTANCE_WIRELESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	ret = set_state(&suspend_data.jogdial, TC1100_INSTANCE_JOGDIAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static const struct dev_pm_ops tc1100_pm_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	.suspend	= tc1100_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	.resume		= tc1100_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	.freeze		= tc1100_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	.restore	= tc1100_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static struct platform_driver tc1100_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		.name = "tc1100-wmi",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		.pm = &tc1100_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	.remove = tc1100_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) static int __init tc1100_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	if (!wmi_has_guid(GUID))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	tc1100_device = platform_device_alloc("tc1100-wmi", -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	if (!tc1100_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	error = platform_device_add(tc1100_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		goto err_device_put;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	error = platform_driver_probe(&tc1100_driver, tc1100_probe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		goto err_device_del;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	pr_info("HP Compaq TC1100 Tablet WMI Extras loaded\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)  err_device_del:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	platform_device_del(tc1100_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)  err_device_put:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	platform_device_put(tc1100_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) static void __exit tc1100_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	platform_device_unregister(tc1100_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	platform_driver_unregister(&tc1100_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) module_init(tc1100_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) module_exit(tc1100_exit);