Skip to content

Commit b7ff715

Browse files
committed
Merge tag 'hwmon-for-v6.19-final' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck: - occ: Mark occ_init_attribute() as __printf to avoid build failure due to '-Werror=suggest-attribute=format' - gpio-fan: Allow to stop fans when CONFIG_PM is disabled, and fix set_rpm() return value - acpi_power_meter: Fix deadlocks related to acpi_power_meter_notify() - dell-smm: Add Dell G15 5510 to fan control whitelist * tag 'hwmon-for-v6.19-final' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (occ) Mark occ_init_attribute() as __printf hwmon: (gpio-fan) Allow to stop FANs when CONFIG_PM is disabled hwmon: (gpio-fan) Fix set_rpm() return value hwmon: (acpi_power_meter) Fix deadlocks related to acpi_power_meter_notify() hwmon: (dell-smm) Add Dell G15 5510 to fan control whitelist
2 parents 8185461 + 831a2b2 commit b7ff715

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

drivers/hwmon/acpi_power_meter.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
static int cap_in_hardware;
4848
static bool force_cap_on;
4949

50+
static DEFINE_MUTEX(acpi_notify_lock);
51+
5052
static int can_cap_in_hardware(void)
5153
{
5254
return force_cap_on || cap_in_hardware;
@@ -823,18 +825,26 @@ static void acpi_power_meter_notify(struct acpi_device *device, u32 event)
823825

824826
resource = acpi_driver_data(device);
825827

828+
guard(mutex)(&acpi_notify_lock);
829+
826830
switch (event) {
827831
case METER_NOTIFY_CONFIG:
832+
if (!IS_ERR(resource->hwmon_dev))
833+
hwmon_device_unregister(resource->hwmon_dev);
834+
828835
mutex_lock(&resource->lock);
836+
829837
free_capabilities(resource);
830838
remove_domain_devices(resource);
831-
hwmon_device_unregister(resource->hwmon_dev);
832839
res = read_capabilities(resource);
833840
if (res)
834841
dev_err_once(&device->dev, "read capabilities failed.\n");
835842
res = read_domain_devices(resource);
836843
if (res && res != -ENODEV)
837844
dev_err_once(&device->dev, "read domain devices failed.\n");
845+
846+
mutex_unlock(&resource->lock);
847+
838848
resource->hwmon_dev =
839849
hwmon_device_register_with_info(&device->dev,
840850
ACPI_POWER_METER_NAME,
@@ -843,7 +853,7 @@ static void acpi_power_meter_notify(struct acpi_device *device, u32 event)
843853
power_extra_groups);
844854
if (IS_ERR(resource->hwmon_dev))
845855
dev_err_once(&device->dev, "register hwmon device failed.\n");
846-
mutex_unlock(&resource->lock);
856+
847857
break;
848858
case METER_NOTIFY_TRIP:
849859
sysfs_notify(&device->dev.kobj, NULL, POWER_AVERAGE_NAME);
@@ -953,7 +963,8 @@ static void acpi_power_meter_remove(struct acpi_device *device)
953963
return;
954964

955965
resource = acpi_driver_data(device);
956-
hwmon_device_unregister(resource->hwmon_dev);
966+
if (!IS_ERR(resource->hwmon_dev))
967+
hwmon_device_unregister(resource->hwmon_dev);
957968

958969
remove_domain_devices(resource);
959970
free_capabilities(resource);

drivers/hwmon/dell-smm-hwmon.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,14 @@ static const struct dmi_system_id i8k_whitelist_fan_control[] __initconst = {
16391639
},
16401640
.driver_data = (void *)&i8k_fan_control_data[I8K_FAN_30A3_31A3],
16411641
},
1642+
{
1643+
.ident = "Dell G15 5510",
1644+
.matches = {
1645+
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
1646+
DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"),
1647+
},
1648+
.driver_data = (void *)&i8k_fan_control_data[I8K_FAN_30A3_31A3],
1649+
},
16421650
{
16431651
.ident = "Dell G15 5511",
16441652
.matches = {

drivers/hwmon/gpio-fan.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static int set_fan_speed(struct gpio_fan_data *fan_data, int speed_index)
148148
int ret;
149149

150150
ret = pm_runtime_put_sync(fan_data->dev);
151-
if (ret < 0)
151+
if (ret < 0 && ret != -ENOSYS)
152152
return ret;
153153
}
154154

@@ -291,7 +291,7 @@ static ssize_t set_rpm(struct device *dev, struct device_attribute *attr,
291291
{
292292
struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
293293
unsigned long rpm;
294-
int ret = count;
294+
int ret;
295295

296296
if (kstrtoul(buf, 10, &rpm))
297297
return -EINVAL;
@@ -308,7 +308,7 @@ static ssize_t set_rpm(struct device *dev, struct device_attribute *attr,
308308
exit_unlock:
309309
mutex_unlock(&fan_data->lock);
310310

311-
return ret;
311+
return ret ? ret : count;
312312
}
313313

314314
static DEVICE_ATTR_RW(pwm1);

drivers/hwmon/occ/common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ static ssize_t occ_show_extended(struct device *dev,
749749
* are dynamically allocated, we cannot use the existing kernel macros which
750750
* stringify the name argument.
751751
*/
752+
__printf(7, 8)
752753
static void occ_init_attribute(struct occ_attribute *attr, int mode,
753754
ssize_t (*show)(struct device *dev, struct device_attribute *attr, char *buf),
754755
ssize_t (*store)(struct device *dev, struct device_attribute *attr,

0 commit comments

Comments
 (0)