platform/x86: think-lmi: Convert container_of() macros to static inline
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 12 Apr 2024 13:09:03 +0000 (16:09 +0300)
committerHans de Goede <hdegoede@redhat.com>
Mon, 29 Apr 2024 08:52:02 +0000 (10:52 +0200)
The macros to_tlmi_pwd_setting() and to_tlmi_attr_setting() are fragile
because they expect the variable name to be 'kobj', otherwise the build
will fail because container_of()'s 3rd parameter (member) is taken from
the parameter given to the macro.

While at it, move them into a more logical place.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by Mark Pearson <mpearson-lenovo@squebbb.ca>
Link: https://lore.kernel.org/r/20240412130903.2836-1-ilpo.jarvinen@linux.intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/think-lmi.c

index 9345316b45dbe42476da55917178afeaedea432c..0f2264bb75775cba72f65a88fd0a86e9230cb395 100644 (file)
@@ -175,9 +175,6 @@ MODULE_PARM_DESC(debug_support, "Enable debug command support");
 #define TLMI_SMP_PWD BIT(6) /* System Management */
 #define TLMI_CERT    BIT(7) /* Certificate Based */
 
-#define to_tlmi_pwd_setting(kobj)  container_of(kobj, struct tlmi_pwd_setting, kobj)
-#define to_tlmi_attr_setting(kobj)  container_of(kobj, struct tlmi_attr_setting, kobj)
-
 static const struct tlmi_err_codes tlmi_errs[] = {
        {"Success", 0},
        {"Not Supported", -EOPNOTSUPP},
@@ -198,6 +195,16 @@ static struct think_lmi tlmi_priv;
 static const struct class *fw_attr_class;
 static DEFINE_MUTEX(tlmi_mutex);
 
+static inline struct tlmi_pwd_setting *to_tlmi_pwd_setting(struct kobject *kobj)
+{
+       return container_of(kobj, struct tlmi_pwd_setting, kobj);
+}
+
+static inline struct tlmi_attr_setting *to_tlmi_attr_setting(struct kobject *kobj)
+{
+       return container_of(kobj, struct tlmi_attr_setting, kobj);
+}
+
 /* Convert BIOS WMI error string to suitable error code */
 static int tlmi_errstr_to_err(const char *errstr)
 {