Add uniwill interface str id and read for tuxedo_io

This commit is contained in:
Christoffer Sandberg 2021-09-18 00:30:00 +02:00
parent ea720826e8
commit d2ff4e4b83
5 changed files with 30 additions and 28 deletions

View file

@ -252,28 +252,6 @@ u32 uw_ec_write_addr(u8 addr_low, u8 addr_high, u8 data_low, u8 data_high, union
}
EXPORT_SYMBOL(uw_ec_write_addr);
static u32 uniwill_identify(void)
{
int status;
// Look for for GUIDs used on uniwill devices
status =
wmi_has_guid(UNIWILL_WMI_EVENT_GUID_0) &&
wmi_has_guid(UNIWILL_WMI_EVENT_GUID_1) &&
wmi_has_guid(UNIWILL_WMI_EVENT_GUID_2) &&
wmi_has_guid(UNIWILL_WMI_MGMT_GUID_BA) &&
wmi_has_guid(UNIWILL_WMI_MGMT_GUID_BB) &&
wmi_has_guid(UNIWILL_WMI_MGMT_GUID_BC);
if (!status)
{
pr_debug("probe: At least one Uniwill GUID missing\n");
return -ENODEV;
}
return 0;
}
static void uniwill_init(void)
{
/* u32 i;

View file

@ -51,6 +51,11 @@ static u32 clevo_identify(void)
return clevo_get_active_interface_id(NULL) == 0 ? 1 : 0;
}
static u32 uniwill_identify(void)
{
return uniwill_get_active_interface_id(NULL) == 0 ? 1 : 0;
}
/*static int fop_open(struct inode *inode, struct file *file)
{
return 0;
@ -205,6 +210,8 @@ static long uniwill_ioctl_interface(struct file *file, unsigned int cmd, unsigne
u32 copy_result;
u32 argument;
u8 byte_data;
const char str_no_if[] = "";
char *str_uniwill_if;
union uw_ec_read_return reg_read_return;
union uw_ec_write_return reg_write_return;
@ -218,6 +225,13 @@ static long uniwill_ioctl_interface(struct file *file, unsigned int cmd, unsigne
#endif
switch (cmd) {
case R_UW_HW_IF_STR:
if (uniwill_get_active_interface_id(&str_uniwill_if) == 0) {
copy_result = copy_to_user((char *) arg, str_uniwill_if, strlen(str_uniwill_if) + 1);
} else {
copy_result = copy_to_user((char *) arg, str_no_if, strlen(str_no_if) + 1);
}
break;
case R_UW_FANSPEED:
uniwill_read_ec_ram(0x1804, &byte_data);
result = byte_data;
@ -363,11 +377,7 @@ static int __init tuxedo_io_init(void)
// Hardware identification
id_check_clevo = clevo_identify();
id_check_uniwill = uniwill_identify() == 0 ? 1 : 0;
if (id_check_uniwill == 1) {
uniwill_init();
}
id_check_uniwill = uniwill_identify();
#ifdef DEBUG
if (id_check_clevo == 0 && id_check_uniwill == 0) {

View file

@ -71,6 +71,7 @@
*/
// Read
#define R_UW_HW_IF_STR _IOR(MAGIC_READ_UW, 0x00, char*)
#define R_UW_FANSPEED _IOR(MAGIC_READ_UW, 0x10, int32_t*)
#define R_UW_FANSPEED2 _IOR(MAGIC_READ_UW, 0x11, int32_t*)
#define R_UW_FAN_TEMP _IOR(MAGIC_READ_UW, 0x12, int32_t*)

View file

@ -50,5 +50,6 @@ u32 uniwill_add_interface(struct uniwill_interface_t *new_interface);
u32 uniwill_remove_interface(struct uniwill_interface_t *interface);
uniwill_read_ec_ram_t uniwill_read_ec_ram;
uniwill_write_ec_ram_t uniwill_write_ec_ram;
u32 uniwill_get_active_interface_id(char **id_str);
#endif

View file

@ -90,7 +90,7 @@ static struct key_entry uniwill_wmi_keymap[] = {
static struct uniwill_interfaces_t {
struct uniwill_interface_t *wmi;
} uniwill_interfaces;
} uniwill_interfaces = { .wmi = NULL };
uniwill_event_callb_t uniwill_event_callb;
@ -168,6 +168,18 @@ u32 uniwill_remove_interface(struct uniwill_interface_t *interface)
}
EXPORT_SYMBOL(uniwill_remove_interface);
u32 uniwill_get_active_interface_id(char **id_str)
{
if (IS_ERR_OR_NULL(uniwill_interfaces.wmi))
return -ENODEV;
if (!IS_ERR_OR_NULL(id_str))
*id_str = uniwill_interfaces.wmi->string_id;
return 0;
}
EXPORT_SYMBOL(uniwill_get_active_interface_id);
static void key_event_work(struct work_struct *work)
{
sparse_keymap_report_known_event(