Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: firmware_attributes_class: Create helper file for handling firmware-attributes class registration events

This offers shared code for registering the firmware_attributes_class,
which is used by the Dell and Lenovo WMI management drivers.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Mark Pearson <markpearson@lenovo.com>
Link: https://lore.kernel.org/r/20210530223111.25929-1-markpearson@lenovo.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Mark Pearson and committed by
Hans de Goede
17b707fe 6cbaee2e

+68
+4
drivers/platform/x86/Kconfig
··· 1077 1077 the OS-image for the device. This option supplies the missing info. 1078 1078 Enable this for x86 tablets with Silead or Chipone touchscreens. 1079 1079 1080 + config FW_ATTR_CLASS 1081 + tristate 1082 + default n 1083 + 1080 1084 config INTEL_IMR 1081 1085 bool "Intel Isolated Memory Region support" 1082 1086 depends on X86_INTEL_QUARK && IOSF_MBI
+1
drivers/platform/x86/Makefile
··· 111 111 obj-$(CONFIG_TOPSTAR_LAPTOP) += topstar-laptop.o 112 112 113 113 # Platform drivers 114 + obj-$(CONFIG_FW_ATTR_CLASS) += firmware_attributes_class.o 114 115 obj-$(CONFIG_I2C_MULTI_INSTANTIATE) += i2c-multi-instantiate.o 115 116 obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o 116 117 obj-$(CONFIG_TOUCHSCREEN_DMI) += touchscreen_dmi.o
+52
drivers/platform/x86/firmware_attributes_class.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + 3 + /* Firmware attributes class helper module */ 4 + 5 + #include <linux/mutex.h> 6 + #include <linux/device/class.h> 7 + #include <linux/module.h> 8 + #include "firmware_attributes_class.h" 9 + 10 + static DEFINE_MUTEX(fw_attr_lock); 11 + int fw_attr_inuse; 12 + 13 + static struct class firmware_attributes_class = { 14 + .name = "firmware-attributes", 15 + }; 16 + 17 + int fw_attributes_class_get(struct class **fw_attr_class) 18 + { 19 + int err; 20 + 21 + mutex_lock(&fw_attr_lock); 22 + if (!fw_attr_inuse) { /*first time class is being used*/ 23 + err = class_register(&firmware_attributes_class); 24 + if (err) { 25 + mutex_unlock(&fw_attr_lock); 26 + return err; 27 + } 28 + } 29 + fw_attr_inuse++; 30 + *fw_attr_class = &firmware_attributes_class; 31 + mutex_unlock(&fw_attr_lock); 32 + return 0; 33 + } 34 + EXPORT_SYMBOL_GPL(fw_attributes_class_get); 35 + 36 + int fw_attributes_class_put(void) 37 + { 38 + mutex_lock(&fw_attr_lock); 39 + if (!fw_attr_inuse) { 40 + mutex_unlock(&fw_attr_lock); 41 + return -EINVAL; 42 + } 43 + fw_attr_inuse--; 44 + if (!fw_attr_inuse) /* No more consumers */ 45 + class_unregister(&firmware_attributes_class); 46 + mutex_unlock(&fw_attr_lock); 47 + return 0; 48 + } 49 + EXPORT_SYMBOL_GPL(fw_attributes_class_put); 50 + 51 + MODULE_AUTHOR("Mark Pearson <markpearson@lenovo.com>"); 52 + MODULE_LICENSE("GPL");
+11
drivers/platform/x86/firmware_attributes_class.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + /* Firmware attributes class helper module */ 4 + 5 + #ifndef FW_ATTR_CLASS_H 6 + #define FW_ATTR_CLASS_H 7 + 8 + int fw_attributes_class_get(struct class **fw_attr_class); 9 + int fw_attributes_class_put(void); 10 + 11 + #endif /* FW_ATTR_CLASS_H */