Commit 91fe2045 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'platform-drivers-x86-v6.3-3' of...

Merge tag 'platform-drivers-x86-v6.3-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86

Pull x86 platform driver fixes from Hans de Goede:

 -  Intel tpmi/vsec fixes

 -  think-lmi fixes

 -  two other small fixes / hw-id additions

* tag 'platform-drivers-x86-v6.3-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
  platform/surface: aggregator: Add missing fwnode_handle_put()
  platform/x86: think-lmi: Add possible_values for ThinkStation
  platform/x86: think-lmi: only display possible_values if available
  platform/x86: think-lmi: use correct possible_values delimiters
  platform/x86: think-lmi: add missing type attribute
  platform/x86 (gigabyte-wmi): Add support for A320M-S2H V2
  platform/x86/intel: tpmi: Revise the comment of intel_vsec_add_aux
  platform/x86/intel: tpmi: Fix double free in tpmi_create_device()
  platform/x86/intel: vsec: Fix a memory leak in intel_vsec_add_aux
parents fc5d1a92 acd0acb8
......@@ -485,8 +485,10 @@ int __ssam_register_clients(struct device *parent, struct ssam_controller *ctrl,
* device, so ignore it and continue with the next one.
*/
status = ssam_add_client_device(parent, ctrl, child);
if (status && status != -ENODEV)
if (status && status != -ENODEV) {
fwnode_handle_put(child);
goto err;
}
}
return 0;
......
......@@ -140,6 +140,7 @@ static u8 gigabyte_wmi_detect_sensor_usability(struct wmi_device *wdev)
}}
static const struct dmi_system_id gigabyte_wmi_known_working_platforms[] = {
DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("A320M-S2H V2-CF"),
DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B450M DS3H-CF"),
DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B450M DS3H WIFI-CF"),
DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B450M S2H V2"),
......
......@@ -203,7 +203,7 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
struct intel_vsec_device *feature_vsec_dev;
struct resource *res, *tmp;
const char *name;
int ret, i;
int i;
name = intel_tpmi_name(pfs->pfs_header.tpmi_id);
if (!name)
......@@ -215,8 +215,8 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
feature_vsec_dev = kzalloc(sizeof(*feature_vsec_dev), GFP_KERNEL);
if (!feature_vsec_dev) {
ret = -ENOMEM;
goto free_res;
kfree(res);
return -ENOMEM;
}
snprintf(feature_id_name, sizeof(feature_id_name), "tpmi-%s", name);
......@@ -239,20 +239,11 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
/*
* intel_vsec_add_aux() is resource managed, no explicit
* delete is required on error or on module unload.
* feature_vsec_dev memory is also freed as part of device
* delete.
* feature_vsec_dev and res memory are also freed as part of
* device deletion.
*/
ret = intel_vsec_add_aux(vsec_dev->pcidev, &vsec_dev->auxdev.dev,
feature_vsec_dev, feature_id_name);
if (ret)
goto free_res;
return 0;
free_res:
kfree(res);
return ret;
return intel_vsec_add_aux(vsec_dev->pcidev, &vsec_dev->auxdev.dev,
feature_vsec_dev, feature_id_name);
}
static int tpmi_create_devices(struct intel_tpmi_info *tpmi_info)
......
......@@ -154,6 +154,7 @@ int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
ret = ida_alloc(intel_vsec_dev->ida, GFP_KERNEL);
mutex_unlock(&vsec_ida_lock);
if (ret < 0) {
kfree(intel_vsec_dev->resource);
kfree(intel_vsec_dev);
return ret;
}
......
......@@ -941,12 +941,23 @@ static ssize_t possible_values_show(struct kobject *kobj, struct kobj_attribute
{
struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj);
if (!tlmi_priv.can_get_bios_selections)
return -EOPNOTSUPP;
return sysfs_emit(buf, "%s\n", setting->possible_values);
}
static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj);
if (setting->possible_values) {
/* Figure out what setting type is as BIOS does not return this */
if (strchr(setting->possible_values, ';'))
return sysfs_emit(buf, "enumeration\n");
}
/* Anything else is going to be a string */
return sysfs_emit(buf, "string\n");
}
static ssize_t current_value_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t count)
......@@ -1036,14 +1047,30 @@ static struct kobj_attribute attr_possible_values = __ATTR_RO(possible_values);
static struct kobj_attribute attr_current_val = __ATTR_RW_MODE(current_value, 0600);
static struct kobj_attribute attr_type = __ATTR_RO(type);
static umode_t attr_is_visible(struct kobject *kobj,
struct attribute *attr, int n)
{
struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj);
/* We don't want to display possible_values attributes if not available */
if ((attr == &attr_possible_values.attr) && (!setting->possible_values))
return 0;
return attr->mode;
}
static struct attribute *tlmi_attrs[] = {
&attr_displ_name.attr,
&attr_current_val.attr,
&attr_possible_values.attr,
&attr_type.attr,
NULL
};
static const struct attribute_group tlmi_attr_group = {
.is_visible = attr_is_visible,
.attrs = tlmi_attrs,
};
......@@ -1423,7 +1450,34 @@ static int tlmi_analyze(void)
if (ret || !setting->possible_values)
pr_info("Error retrieving possible values for %d : %s\n",
i, setting->display_name);
} else {
/*
* Older Thinkstations don't support the bios_selections API.
* Instead they store this as a [Optional:Option1,Option2] section of the
* name string.
* Try and pull that out if it's available.
*/
char *item, *optstart, *optend;
if (!tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID)) {
optstart = strstr(item, "[Optional:");
if (optstart) {
optstart += strlen("[Optional:");
optend = strstr(optstart, "]");
if (optend)
setting->possible_values =
kstrndup(optstart, optend - optstart,
GFP_KERNEL);
}
}
}
/*
* firmware-attributes requires that possible_values are separated by ';' but
* Lenovo FW uses ','. Replace appropriately.
*/
if (setting->possible_values)
strreplace(setting->possible_values, ',', ';');
kobject_init(&setting->kobj, &tlmi_attr_setting_ktype);
tlmi_priv.setting[i] = setting;
kfree(item);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment