Skip to content

Commit c883118

Browse files
committed
Merge tag 'platform-drivers-x86-v5.16-4' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
Pull x86 platform driver fixes from Hans de Goede: "Various bug-fixes" * tag 'platform-drivers-x86-v5.16-4' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: platform/x86: intel_pmc_core: fix memleak on registration failure platform/x86/intel: Remove X86_PLATFORM_DRIVERS_INTEL platform/x86: system76_acpi: Guard System76 EC specific functionality platform/x86: apple-gmux: use resource_size() with res platform/x86: amd-pmc: only use callbacks for suspend platform/mellanox: mlxbf-pmc: Fix an IS_ERR() vs NULL bug in mlxbf_pmc_map_counters
2 parents 7a29b11 + 26a8b09 commit c883118

7 files changed

Lines changed: 37 additions & 49 deletions

File tree

drivers/platform/mellanox/mlxbf-pmc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,8 +1374,8 @@ static int mlxbf_pmc_map_counters(struct device *dev)
13741374
pmc->block[i].counters = info[2];
13751375
pmc->block[i].type = info[3];
13761376

1377-
if (IS_ERR(pmc->block[i].mmio_base))
1378-
return PTR_ERR(pmc->block[i].mmio_base);
1377+
if (!pmc->block[i].mmio_base)
1378+
return -ENOMEM;
13791379

13801380
ret = mlxbf_pmc_create_groups(dev, i);
13811381
if (ret)

drivers/platform/x86/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o
6868
obj-$(CONFIG_THINKPAD_LMI) += think-lmi.o
6969

7070
# Intel
71-
obj-$(CONFIG_X86_PLATFORM_DRIVERS_INTEL) += intel/
71+
obj-y += intel/
7272

7373
# MSI
7474
obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o

drivers/platform/x86/amd-pmc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ static int __maybe_unused amd_pmc_resume(struct device *dev)
508508
}
509509

510510
static const struct dev_pm_ops amd_pmc_pm_ops = {
511-
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(amd_pmc_suspend, amd_pmc_resume)
511+
.suspend_noirq = amd_pmc_suspend,
512+
.resume_noirq = amd_pmc_resume,
512513
};
513514

514515
static const struct pci_device_id pmc_pci_ids[] = {

drivers/platform/x86/apple-gmux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
625625
}
626626

627627
gmux_data->iostart = res->start;
628-
gmux_data->iolen = res->end - res->start;
628+
gmux_data->iolen = resource_size(res);
629629

630630
if (gmux_data->iolen < GMUX_MIN_IO_LEN) {
631631
pr_err("gmux I/O region too small (%lu < %u)\n",

drivers/platform/x86/intel/Kconfig

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@
33
# Intel x86 Platform Specific Drivers
44
#
55

6-
menuconfig X86_PLATFORM_DRIVERS_INTEL
7-
bool "Intel x86 Platform Specific Device Drivers"
8-
default y
9-
help
10-
Say Y here to get to see options for device drivers for
11-
various Intel x86 platforms, including vendor-specific
12-
drivers. This option alone does not add any kernel code.
13-
14-
If you say N, all options in this submenu will be skipped
15-
and disabled.
16-
17-
if X86_PLATFORM_DRIVERS_INTEL
18-
196
source "drivers/platform/x86/intel/atomisp2/Kconfig"
207
source "drivers/platform/x86/intel/int1092/Kconfig"
218
source "drivers/platform/x86/intel/int33fe/Kconfig"
@@ -183,5 +170,3 @@ config INTEL_UNCORE_FREQ_CONTROL
183170

184171
To compile this driver as a module, choose M here: the module
185172
will be called intel-uncore-frequency.
186-
187-
endif # X86_PLATFORM_DRIVERS_INTEL

drivers/platform/x86/intel/pmc/pltdrv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static int __init pmc_core_platform_init(void)
6565

6666
retval = platform_device_register(pmc_core_device);
6767
if (retval)
68-
kfree(pmc_core_device);
68+
platform_device_put(pmc_core_device);
6969

7070
return retval;
7171
}

drivers/platform/x86/system76_acpi.c

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct system76_data {
3535
union acpi_object *nfan;
3636
union acpi_object *ntmp;
3737
struct input_dev *input;
38+
bool has_open_ec;
3839
};
3940

4041
static const struct acpi_device_id device_ids[] = {
@@ -279,20 +280,12 @@ static struct acpi_battery_hook system76_battery_hook = {
279280

280281
static void system76_battery_init(void)
281282
{
282-
acpi_handle handle;
283-
284-
handle = ec_get_handle();
285-
if (handle && acpi_has_method(handle, "GBCT"))
286-
battery_hook_register(&system76_battery_hook);
283+
battery_hook_register(&system76_battery_hook);
287284
}
288285

289286
static void system76_battery_exit(void)
290287
{
291-
acpi_handle handle;
292-
293-
handle = ec_get_handle();
294-
if (handle && acpi_has_method(handle, "GBCT"))
295-
battery_hook_unregister(&system76_battery_hook);
288+
battery_hook_unregister(&system76_battery_hook);
296289
}
297290

298291
// Get the airplane mode LED brightness
@@ -673,6 +666,10 @@ static int system76_add(struct acpi_device *acpi_dev)
673666
acpi_dev->driver_data = data;
674667
data->acpi_dev = acpi_dev;
675668

669+
// Some models do not run open EC firmware. Check for an ACPI method
670+
// that only exists on open EC to guard functionality specific to it.
671+
data->has_open_ec = acpi_has_method(acpi_device_handle(data->acpi_dev), "NFAN");
672+
676673
err = system76_get(data, "INIT");
677674
if (err)
678675
return err;
@@ -718,27 +715,31 @@ static int system76_add(struct acpi_device *acpi_dev)
718715
if (err)
719716
goto error;
720717

721-
err = system76_get_object(data, "NFAN", &data->nfan);
722-
if (err)
723-
goto error;
718+
if (data->has_open_ec) {
719+
err = system76_get_object(data, "NFAN", &data->nfan);
720+
if (err)
721+
goto error;
724722

725-
err = system76_get_object(data, "NTMP", &data->ntmp);
726-
if (err)
727-
goto error;
723+
err = system76_get_object(data, "NTMP", &data->ntmp);
724+
if (err)
725+
goto error;
728726

729-
data->therm = devm_hwmon_device_register_with_info(&acpi_dev->dev,
730-
"system76_acpi", data, &thermal_chip_info, NULL);
731-
err = PTR_ERR_OR_ZERO(data->therm);
732-
if (err)
733-
goto error;
727+
data->therm = devm_hwmon_device_register_with_info(&acpi_dev->dev,
728+
"system76_acpi", data, &thermal_chip_info, NULL);
729+
err = PTR_ERR_OR_ZERO(data->therm);
730+
if (err)
731+
goto error;
734732

735-
system76_battery_init();
733+
system76_battery_init();
734+
}
736735

737736
return 0;
738737

739738
error:
740-
kfree(data->ntmp);
741-
kfree(data->nfan);
739+
if (data->has_open_ec) {
740+
kfree(data->ntmp);
741+
kfree(data->nfan);
742+
}
742743
return err;
743744
}
744745

@@ -749,14 +750,15 @@ static int system76_remove(struct acpi_device *acpi_dev)
749750

750751
data = acpi_driver_data(acpi_dev);
751752

752-
system76_battery_exit();
753+
if (data->has_open_ec) {
754+
system76_battery_exit();
755+
kfree(data->nfan);
756+
kfree(data->ntmp);
757+
}
753758

754759
devm_led_classdev_unregister(&acpi_dev->dev, &data->ap_led);
755760
devm_led_classdev_unregister(&acpi_dev->dev, &data->kb_led);
756761

757-
kfree(data->nfan);
758-
kfree(data->ntmp);
759-
760762
system76_get(data, "FINI");
761763

762764
return 0;

0 commit comments

Comments
 (0)