[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMEXYWcuZXx285npcPB3q0Umit2bAwmFzo1sBPLYnyhoUT0EnQ@mail.gmail.com>
Date: Tue, 23 Dec 2025 11:24:09 -0800
From: Benjamin Philip <benjamin.philip495@...il.com>
To: platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Mark Pearson <mpearson-lenovo@...ebb.ca>, "Derek J. Clark" <derekjohn.clark@...il.com>,
Hans de Goede <hansg@...nel.org>, Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
Benjamin Philip <benjamin.philip495@...il.com>
Subject: [PATCH 3/5] platform/x86: think-lmi: Clean up misc checks
This commit cleans up the following checks:
- CHECK: braces {} should be used on all arms of this statement
- CHECK: Please use a blank line after function/struct/union/enum
declarations
- CHECK: Prefer kzalloc(sizeof(*new_pwd)...) over
kzalloc(sizeof(struct tlmi_pwd_setting)...)
- CHECK: spaces preferred around that '/' (ctx:VxV)
- CHECK: Unbalanced braces around else statement
Signed-off-by: Benjamin Philip <benjamin.philip495@...il.com>
---
drivers/platform/x86/lenovo/think-lmi.c | 32 +++++++++++++------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/drivers/platform/x86/lenovo/think-lmi.c
b/drivers/platform/x86/lenovo/think-lmi.c
index 1fac8986d077..1ada4d800383 100644
--- a/drivers/platform/x86/lenovo/think-lmi.c
+++ b/drivers/platform/x86/lenovo/think-lmi.c
@@ -223,14 +223,16 @@ static const struct tlmi_err_codes tlmi_errs[] = {
{"Set Certificate operation failed with status:Certificate too
large.", -EFBIG},
};
-static const char * const encoding_options[] = {
+static const char *const encoding_options[] = {
[TLMI_ENCODING_ASCII] = "ascii",
[TLMI_ENCODING_SCANCODE] = "scancode",
};
-static const char * const level_options[] = {
+
+static const char *const level_options[] = {
[TLMI_LEVEL_USER] = "user",
[TLMI_LEVEL_MASTER] = "master",
};
+
static struct think_lmi tlmi_priv;
static DEFINE_MUTEX(tlmi_mutex);
@@ -249,7 +251,7 @@ static int tlmi_errstr_to_err(const char *errstr)
{
int i;
- for (i = 0; i < sizeof(tlmi_errs)/sizeof(struct tlmi_err_codes); i++) {
+ for (i = 0; i < sizeof(tlmi_errs) / sizeof(struct tlmi_err_codes); i++) {
if (!strcmp(tlmi_errs[i].err_str, errstr))
return tlmi_errs[i].err_code;
}
@@ -570,19 +572,19 @@ static ssize_t mechanism_show(struct kobject
*kobj, struct kobj_attribute *attr,
return sysfs_emit(buf, "certificate\n");
return sysfs_emit(buf, "password\n");
}
+
static struct kobj_attribute auth_mechanism = __ATTR_RO(mechanism);
static ssize_t encoding_show(struct kobject *kobj, struct kobj_attribute *attr,
- char *buf)
+ char *buf)
{
struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
return sysfs_emit(buf, "%s\n", encoding_options[setting->encoding]);
}
-static ssize_t encoding_store(struct kobject *kobj,
- struct kobj_attribute *attr,
- const char *buf, size_t count)
+static ssize_t encoding_store(struct kobject *kobj, struct
kobj_attribute *attr,
+ const char *buf, size_t count)
{
struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
int i;
@@ -632,19 +634,19 @@ static ssize_t role_show(struct kobject *kobj,
struct kobj_attribute *attr,
return sysfs_emit(buf, "%s\n", setting->role);
}
+
static struct kobj_attribute auth_role = __ATTR_RO(role);
static ssize_t index_show(struct kobject *kobj, struct kobj_attribute *attr,
- char *buf)
+ char *buf)
{
struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
return sysfs_emit(buf, "%d\n", setting->index);
}
-static ssize_t index_store(struct kobject *kobj,
- struct kobj_attribute *attr,
- const char *buf, size_t count)
+static ssize_t index_store(struct kobject *kobj, struct kobj_attribute *attr,
+ const char *buf, size_t count)
{
struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
int err, val;
@@ -1047,9 +1049,9 @@ static ssize_t current_value_show(struct kobject
*kobj, struct kobj_attribute *a
/* validate and split from `item,value` -> `value` */
value = strpbrk(item, ",");
- if (!value || value == item || !strlen(value + 1))
+ if (!value || value == item || !strlen(value + 1)) {
ret = -EINVAL;
- else {
+ } else {
/* On Workstations remove the Options part after the value */
strreplace(value, ';', '\0');
ret = sysfs_emit(buf, "%s\n", value + 1);
@@ -1585,11 +1587,11 @@ static int tlmi_sysfs_init(void)
/* ---- Base Driver -------------------------------------------------------- */
static struct tlmi_pwd_setting *tlmi_create_auth(const char *pwd_type,
- const char *pwd_role)
+ const char *pwd_role)
{
struct tlmi_pwd_setting *new_pwd;
- new_pwd = kzalloc(sizeof(struct tlmi_pwd_setting), GFP_KERNEL);
+ new_pwd = kzalloc(sizeof(*new_pwd), GFP_KERNEL);
if (!new_pwd)
return NULL;
--
2.52.0
Powered by blists - more mailing lists