mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	 d91a1d129b
			
		
	
	
		d91a1d129b
		
	
	
	
	
		
			
			Device-managed resources are cleaned up when the driver unbinds from
the underlying device. In our case this is the platform device as this
driver is a platform driver. Registering device-managed resources on
the associated ACPI device will thus result in a resource leak when
this driver unbinds.
Ensure that any device-managed resources are only registered on the
platform device to ensure that they are cleaned up during removal.
Fixes: 35c50d853a ("ACPI: fan: Add hwmon support")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Cc: 6.11+ <stable@vger.kernel.org> # 6.11+
Link: https://patch.msgid.link/20251007234149.2769-4-W_Armin@gmx.de
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
		
	
			
		
			
				
	
	
		
			73 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /* SPDX-License-Identifier: GPL-2.0-only */
 | |
| 
 | |
| /*
 | |
|  * ACPI fan device IDs are shared between the fan driver and the device power
 | |
|  * management code.
 | |
|  *
 | |
|  * Add new device IDs before the generic ACPI fan one.
 | |
|  */
 | |
| 
 | |
| #ifndef _ACPI_FAN_H_
 | |
| #define _ACPI_FAN_H_
 | |
| 
 | |
| #include <linux/kconfig.h>
 | |
| 
 | |
| #define ACPI_FAN_DEVICE_IDS	\
 | |
| 	{"INT3404", }, /* Fan */ \
 | |
| 	{"INTC1044", }, /* Fan for Tiger Lake generation */ \
 | |
| 	{"INTC1048", }, /* Fan for Alder Lake generation */ \
 | |
| 	{"INTC1063", }, /* Fan for Meteor Lake generation */ \
 | |
| 	{"INTC106A", }, /* Fan for Lunar Lake generation */ \
 | |
| 	{"INTC10A2", }, /* Fan for Raptor Lake generation */ \
 | |
| 	{"INTC10D6", }, /* Fan for Panther Lake generation */ \
 | |
| 	{"INTC10FE", }, /* Fan for Wildcat Lake generation */ \
 | |
| 	{"PNP0C0B", } /* Generic ACPI fan */
 | |
| 
 | |
| #define ACPI_FPS_NAME_LEN	20
 | |
| 
 | |
| struct acpi_fan_fps {
 | |
| 	u64 control;
 | |
| 	u64 trip_point;
 | |
| 	u64 speed;
 | |
| 	u64 noise_level;
 | |
| 	u64 power;
 | |
| 	char name[ACPI_FPS_NAME_LEN];
 | |
| 	struct device_attribute dev_attr;
 | |
| };
 | |
| 
 | |
| struct acpi_fan_fif {
 | |
| 	u8 revision;
 | |
| 	u8 fine_grain_ctrl;
 | |
| 	u8 step_size;
 | |
| 	u8 low_speed_notification;
 | |
| };
 | |
| 
 | |
| struct acpi_fan_fst {
 | |
| 	u64 revision;
 | |
| 	u64 control;
 | |
| 	u64 speed;
 | |
| };
 | |
| 
 | |
| struct acpi_fan {
 | |
| 	acpi_handle handle;
 | |
| 	bool acpi4;
 | |
| 	bool has_fst;
 | |
| 	struct acpi_fan_fif fif;
 | |
| 	struct acpi_fan_fps *fps;
 | |
| 	int fps_count;
 | |
| 	struct thermal_cooling_device *cdev;
 | |
| 	struct device_attribute fst_speed;
 | |
| 	struct device_attribute fine_grain_control;
 | |
| };
 | |
| 
 | |
| int acpi_fan_get_fst(acpi_handle handle, struct acpi_fan_fst *fst);
 | |
| int acpi_fan_create_attributes(struct acpi_device *device);
 | |
| void acpi_fan_delete_attributes(struct acpi_device *device);
 | |
| 
 | |
| #if IS_REACHABLE(CONFIG_HWMON)
 | |
| int devm_acpi_fan_create_hwmon(struct device *dev);
 | |
| #else
 | |
| static inline int devm_acpi_fan_create_hwmon(struct device *dev) { return 0; };
 | |
| #endif
 | |
| 
 | |
| #endif
 |