From da62908efe80f132f691efc2ace4ca67626de86b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sun, 12 Mar 2023 03:47:57 +0000 Subject: platform/x86: think-lmi: Properly interpret return value of tlmi_setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The return value of tlmi_settings() is an errorcode, not an acpi_status. Signed-off-by: Thomas Weißschuh Link: https://lore.kernel.org/r/20230312-think-lmi-status-v1-1-4e9f36322cc4@weissschuh.net Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- drivers/platform/x86/think-lmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/platform/x86/think-lmi.c') diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index 86b33b74519b..c924e9e4a6a5 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -1353,7 +1353,6 @@ static struct tlmi_pwd_setting *tlmi_create_auth(const char *pwd_type, static int tlmi_analyze(void) { - acpi_status status; int i, ret; if (wmi_has_guid(LENOVO_SET_BIOS_SETTINGS_GUID) && @@ -1390,8 +1389,8 @@ static int tlmi_analyze(void) char *p; tlmi_priv.setting[i] = NULL; - status = tlmi_setting(i, &item, LENOVO_BIOS_SETTING_GUID); - if (ACPI_FAILURE(status)) + ret = tlmi_setting(i, &item, LENOVO_BIOS_SETTING_GUID); + if (ret) break; if (!item) break; -- cgit v1.2.3 From daaa2a1f78347d73016b3a331fd48a0ca9e62192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 14 Mar 2023 00:07:52 +0000 Subject: platform/x86: think-lmi: Remove custom kobject sysfs_ops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit think-lmi defines its own sysfs_ops that are identical to the standard kobj_sysfs_ops. Use the standard definitions. Signed-off-by: Thomas Weißschuh Link: https://lore.kernel.org/r/20230314-think-lmi-sysfs_ops-v1-1-9d4f1cf9caec@weissschuh.net Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- drivers/platform/x86/think-lmi.c | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) (limited to 'drivers/platform/x86/think-lmi.c') diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index c924e9e4a6a5..cc66f7cbccf2 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -1047,33 +1047,6 @@ static const struct attribute_group tlmi_attr_group = { .attrs = tlmi_attrs, }; -static ssize_t tlmi_attr_show(struct kobject *kobj, struct attribute *attr, - char *buf) -{ - struct kobj_attribute *kattr; - - kattr = container_of(attr, struct kobj_attribute, attr); - if (kattr->show) - return kattr->show(kobj, kattr, buf); - return -EIO; -} - -static ssize_t tlmi_attr_store(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t count) -{ - struct kobj_attribute *kattr; - - kattr = container_of(attr, struct kobj_attribute, attr); - if (kattr->store) - return kattr->store(kobj, kattr, buf, count); - return -EIO; -} - -static const struct sysfs_ops tlmi_kobj_sysfs_ops = { - .show = tlmi_attr_show, - .store = tlmi_attr_store, -}; - static void tlmi_attr_setting_release(struct kobject *kobj) { struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); @@ -1091,12 +1064,12 @@ static void tlmi_pwd_setting_release(struct kobject *kobj) static const struct kobj_type tlmi_attr_setting_ktype = { .release = &tlmi_attr_setting_release, - .sysfs_ops = &tlmi_kobj_sysfs_ops, + .sysfs_ops = &kobj_sysfs_ops, }; static const struct kobj_type tlmi_pwd_setting_ktype = { .release = &tlmi_pwd_setting_release, - .sysfs_ops = &tlmi_kobj_sysfs_ops, + .sysfs_ops = &kobj_sysfs_ops, }; static ssize_t pending_reboot_show(struct kobject *kobj, struct kobj_attribute *attr, -- cgit v1.2.3 From 3e9adae9336f1d530f342e5d5fbfc7d349f25b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 29 Mar 2023 04:50:25 +0000 Subject: platform/x86: think-lmi: Remove unnecessary casts for attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These casts are unnecessary and could break if structure layouts are randomized or implementation details change. Use the proper syntax that works without casts. Also remove some unnecessary braces that checkpatch complains about. Signed-off-by: Thomas Weißschuh Link: https://lore.kernel.org/r/20230329-think-lmi-attrs-v1-1-5794f2367cc2@weissschuh.net Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- drivers/platform/x86/think-lmi.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'drivers/platform/x86/think-lmi.c') diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index cc66f7cbccf2..5a7ac5ca283c 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -862,19 +862,18 @@ static umode_t auth_attr_is_visible(struct kobject *kobj, struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj); /* We only want to display level and index settings on HDD/NVMe */ - if ((attr == (struct attribute *)&auth_index) || - (attr == (struct attribute *)&auth_level)) { + if (attr == &auth_index.attr || attr == &auth_level.attr) { if ((setting == tlmi_priv.pwd_hdd) || (setting == tlmi_priv.pwd_nvme)) return attr->mode; return 0; } /* We only display certificates on Admin account, if supported */ - if ((attr == (struct attribute *)&auth_certificate) || - (attr == (struct attribute *)&auth_signature) || - (attr == (struct attribute *)&auth_save_signature) || - (attr == (struct attribute *)&auth_cert_thumb) || - (attr == (struct attribute *)&auth_cert_to_password)) { + if (attr == &auth_certificate.attr || + attr == &auth_signature.attr || + attr == &auth_save_signature.attr || + attr == &auth_cert_thumb.attr || + attr == &auth_cert_to_password.attr) { if ((setting == tlmi_priv.pwd_admin) && tlmi_priv.certificate_support) return attr->mode; return 0; -- cgit v1.2.3