Skip to content

Commit

Permalink
Merge tag 'platform-drivers-x86-v6.3-3' of git://git.kernel.org/pub/s…
Browse files Browse the repository at this point in the history
…cm/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
  • Loading branch information
Linus Torvalds committed Mar 27, 2023
2 parents fc5d1a9 + acd0acb commit 91fe204
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 20 deletions.
4 changes: 3 additions & 1 deletion drivers/platform/surface/aggregator/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions drivers/platform/x86/gigabyte-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
23 changes: 7 additions & 16 deletions drivers/platform/x86/intel/tpmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions drivers/platform/x86/intel/vsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
60 changes: 57 additions & 3 deletions drivers/platform/x86/think-lmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 91fe204

Please sign in to comment.