Skip to content

Commit

Permalink
Merge tag 'platform-drivers-x86-v5.16-4' of git://git.kernel.org/pub/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
torvalds committed Dec 24, 2021
2 parents 7a29b11 + 26a8b09 commit c883118
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 49 deletions.
4 changes: 2 additions & 2 deletions drivers/platform/mellanox/mlxbf-pmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,8 +1374,8 @@ static int mlxbf_pmc_map_counters(struct device *dev)
pmc->block[i].counters = info[2];
pmc->block[i].type = info[3];

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

ret = mlxbf_pmc_create_groups(dev, i);
if (ret)
Expand Down
2 changes: 1 addition & 1 deletion drivers/platform/x86/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o
obj-$(CONFIG_THINKPAD_LMI) += think-lmi.o

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

# MSI
obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
Expand Down
3 changes: 2 additions & 1 deletion drivers/platform/x86/amd-pmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,8 @@ static int __maybe_unused amd_pmc_resume(struct device *dev)
}

static const struct dev_pm_ops amd_pmc_pm_ops = {
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(amd_pmc_suspend, amd_pmc_resume)
.suspend_noirq = amd_pmc_suspend,
.resume_noirq = amd_pmc_resume,
};

static const struct pci_device_id pmc_pci_ids[] = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/platform/x86/apple-gmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
}

gmux_data->iostart = res->start;
gmux_data->iolen = res->end - res->start;
gmux_data->iolen = resource_size(res);

if (gmux_data->iolen < GMUX_MIN_IO_LEN) {
pr_err("gmux I/O region too small (%lu < %u)\n",
Expand Down
15 changes: 0 additions & 15 deletions drivers/platform/x86/intel/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
# Intel x86 Platform Specific Drivers
#

menuconfig X86_PLATFORM_DRIVERS_INTEL
bool "Intel x86 Platform Specific Device Drivers"
default y
help
Say Y here to get to see options for device drivers for
various Intel x86 platforms, including vendor-specific
drivers. This option alone does not add any kernel code.

If you say N, all options in this submenu will be skipped
and disabled.

if X86_PLATFORM_DRIVERS_INTEL

source "drivers/platform/x86/intel/atomisp2/Kconfig"
source "drivers/platform/x86/intel/int1092/Kconfig"
source "drivers/platform/x86/intel/int33fe/Kconfig"
Expand Down Expand Up @@ -183,5 +170,3 @@ config INTEL_UNCORE_FREQ_CONTROL

To compile this driver as a module, choose M here: the module
will be called intel-uncore-frequency.

endif # X86_PLATFORM_DRIVERS_INTEL
2 changes: 1 addition & 1 deletion drivers/platform/x86/intel/pmc/pltdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static int __init pmc_core_platform_init(void)

retval = platform_device_register(pmc_core_device);
if (retval)
kfree(pmc_core_device);
platform_device_put(pmc_core_device);

return retval;
}
Expand Down
58 changes: 30 additions & 28 deletions drivers/platform/x86/system76_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct system76_data {
union acpi_object *nfan;
union acpi_object *ntmp;
struct input_dev *input;
bool has_open_ec;
};

static const struct acpi_device_id device_ids[] = {
Expand Down Expand Up @@ -279,20 +280,12 @@ static struct acpi_battery_hook system76_battery_hook = {

static void system76_battery_init(void)
{
acpi_handle handle;

handle = ec_get_handle();
if (handle && acpi_has_method(handle, "GBCT"))
battery_hook_register(&system76_battery_hook);
battery_hook_register(&system76_battery_hook);
}

static void system76_battery_exit(void)
{
acpi_handle handle;

handle = ec_get_handle();
if (handle && acpi_has_method(handle, "GBCT"))
battery_hook_unregister(&system76_battery_hook);
battery_hook_unregister(&system76_battery_hook);
}

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

// Some models do not run open EC firmware. Check for an ACPI method
// that only exists on open EC to guard functionality specific to it.
data->has_open_ec = acpi_has_method(acpi_device_handle(data->acpi_dev), "NFAN");

err = system76_get(data, "INIT");
if (err)
return err;
Expand Down Expand Up @@ -718,27 +715,31 @@ static int system76_add(struct acpi_device *acpi_dev)
if (err)
goto error;

err = system76_get_object(data, "NFAN", &data->nfan);
if (err)
goto error;
if (data->has_open_ec) {
err = system76_get_object(data, "NFAN", &data->nfan);
if (err)
goto error;

err = system76_get_object(data, "NTMP", &data->ntmp);
if (err)
goto error;
err = system76_get_object(data, "NTMP", &data->ntmp);
if (err)
goto error;

data->therm = devm_hwmon_device_register_with_info(&acpi_dev->dev,
"system76_acpi", data, &thermal_chip_info, NULL);
err = PTR_ERR_OR_ZERO(data->therm);
if (err)
goto error;
data->therm = devm_hwmon_device_register_with_info(&acpi_dev->dev,
"system76_acpi", data, &thermal_chip_info, NULL);
err = PTR_ERR_OR_ZERO(data->therm);
if (err)
goto error;

system76_battery_init();
system76_battery_init();
}

return 0;

error:
kfree(data->ntmp);
kfree(data->nfan);
if (data->has_open_ec) {
kfree(data->ntmp);
kfree(data->nfan);
}
return err;
}

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

data = acpi_driver_data(acpi_dev);

system76_battery_exit();
if (data->has_open_ec) {
system76_battery_exit();
kfree(data->nfan);
kfree(data->ntmp);
}

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

kfree(data->nfan);
kfree(data->ntmp);

system76_get(data, "FINI");

return 0;
Expand Down

0 comments on commit c883118

Please sign in to comment.