Skip to content

Commit f5b4df9

Browse files
committed
Merge branches 'acpi-pci', 'acpi-battery', 'acpi-ec' and 'acpi-apei'
Merge an ACPI PCI root driver update, ACPI battery driver updates, an ACPI EC driver update and APEI updates for 6.16-rc1: - Turn the acpi_pci_root_remap_iospace() fwnode_handle parameter into a const pointer (Pei Xiao). - Round battery capacity percengate in the ACPI battery driver to the closest integer to avoid user confusion (shitao). - Make the ACPI battery driver report the current as a negative number to the power supply framework when the battery is discharging as documented (Peter Marheine). - Add TUXEDO InfinityBook Pro AMD Gen9 to the acpi_ec_no_wakeup[] list to prevent spurious wakeups from suspend-to-idle (Werner Sembach). - Convert the APEI EINJ driver to a faux device one (Sudeep Holla, Jon Hunter). - Remove redundant calls to einj_get_available_error_type() from the APEI EINJ driver (Zaid Alali). * acpi-pci: ACPI: PCI: Constify fwnode_handle in acpi_pci_root_remap_iospace() * acpi-battery: ACPI: battery: negate current when discharging ACPI: battery: Round capacity percengate to closest integer * acpi-ec: ACPI: EC: Add device to acpi_ec_no_wakeup[] qurik list * acpi-apei: ACPI: APEI: EINJ: Remove redundant calls to einj_get_available_error_type() ACPI: APEI: EINJ: Fix probe error message ACPI: APEI: EINJ: Transition to the faux device interface
5 parents 0a17adc + eba614b + 234f715 + 9cd51ee + e54b1dc commit f5b4df9

File tree

4 files changed

+49
-44
lines changed

4 files changed

+49
-44
lines changed

drivers/acpi/apei/einj-core.c

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <linux/nmi.h>
2222
#include <linux/delay.h>
2323
#include <linux/mm.h>
24-
#include <linux/platform_device.h>
24+
#include <linux/device/faux.h>
2525
#include <linux/unaligned.h>
2626

2727
#include "apei-internal.h"
@@ -83,6 +83,8 @@ static struct debugfs_blob_wrapper vendor_blob;
8383
static struct debugfs_blob_wrapper vendor_errors;
8484
static char vendor_dev[64];
8585

86+
static u32 available_error_type;
87+
8688
/*
8789
* Some BIOSes allow parameters to the SET_ERROR_TYPE entries in the
8890
* EINJ table through an unpublished extension. Use with caution as
@@ -648,14 +650,9 @@ static struct { u32 mask; const char *str; } const einj_error_type_string[] = {
648650

649651
static int available_error_type_show(struct seq_file *m, void *v)
650652
{
651-
int rc;
652-
u32 error_type = 0;
653653

654-
rc = einj_get_available_error_type(&error_type);
655-
if (rc)
656-
return rc;
657654
for (int pos = 0; pos < ARRAY_SIZE(einj_error_type_string); pos++)
658-
if (error_type & einj_error_type_string[pos].mask)
655+
if (available_error_type & einj_error_type_string[pos].mask)
659656
seq_printf(m, "0x%08x\t%s\n", einj_error_type_string[pos].mask,
660657
einj_error_type_string[pos].str);
661658

@@ -678,8 +675,7 @@ bool einj_is_cxl_error_type(u64 type)
678675

679676
int einj_validate_error_type(u64 type)
680677
{
681-
u32 tval, vendor, available_error_type = 0;
682-
int rc;
678+
u32 tval, vendor;
683679

684680
/* Only low 32 bits for error type are valid */
685681
if (type & GENMASK_ULL(63, 32))
@@ -695,13 +691,9 @@ int einj_validate_error_type(u64 type)
695691
/* Only one error type can be specified */
696692
if (tval & (tval - 1))
697693
return -EINVAL;
698-
if (!vendor) {
699-
rc = einj_get_available_error_type(&available_error_type);
700-
if (rc)
701-
return rc;
694+
if (!vendor)
702695
if (!(type & available_error_type))
703696
return -EINVAL;
704-
}
705697

706698
return 0;
707699
}
@@ -749,17 +741,12 @@ static int einj_check_table(struct acpi_table_einj *einj_tab)
749741
return 0;
750742
}
751743

752-
static int __init einj_probe(struct platform_device *pdev)
744+
static int __init einj_probe(struct faux_device *fdev)
753745
{
754746
int rc;
755747
acpi_status status;
756748
struct apei_exec_context ctx;
757749

758-
if (acpi_disabled) {
759-
pr_debug("ACPI disabled.\n");
760-
return -ENODEV;
761-
}
762-
763750
status = acpi_get_table(ACPI_SIG_EINJ, 0,
764751
(struct acpi_table_header **)&einj_tab);
765752
if (status == AE_NOT_FOUND) {
@@ -777,6 +764,10 @@ static int __init einj_probe(struct platform_device *pdev)
777764
goto err_put_table;
778765
}
779766

767+
rc = einj_get_available_error_type(&available_error_type);
768+
if (rc)
769+
return rc;
770+
780771
rc = -ENOMEM;
781772
einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir());
782773

@@ -851,7 +842,7 @@ static int __init einj_probe(struct platform_device *pdev)
851842
return rc;
852843
}
853844

854-
static void __exit einj_remove(struct platform_device *pdev)
845+
static void __exit einj_remove(struct faux_device *fdev)
855846
{
856847
struct apei_exec_context ctx;
857848

@@ -872,44 +863,39 @@ static void __exit einj_remove(struct platform_device *pdev)
872863
acpi_put_table((struct acpi_table_header *)einj_tab);
873864
}
874865

875-
static struct platform_device *einj_dev;
866+
static struct faux_device *einj_dev;
876867
/*
877868
* einj_remove() lives in .exit.text. For drivers registered via
878869
* platform_driver_probe() this is ok because they cannot get unbound at
879870
* runtime. So mark the driver struct with __refdata to prevent modpost
880871
* triggering a section mismatch warning.
881872
*/
882-
static struct platform_driver einj_driver __refdata = {
873+
static struct faux_device_ops einj_device_ops __refdata = {
874+
.probe = einj_probe,
883875
.remove = __exit_p(einj_remove),
884-
.driver = {
885-
.name = "acpi-einj",
886-
},
887876
};
888877

889878
static int __init einj_init(void)
890879
{
891-
struct platform_device_info einj_dev_info = {
892-
.name = "acpi-einj",
893-
.id = -1,
894-
};
895-
int rc;
880+
if (acpi_disabled) {
881+
pr_debug("ACPI disabled.\n");
882+
return -ENODEV;
883+
}
896884

897-
einj_dev = platform_device_register_full(&einj_dev_info);
898-
if (IS_ERR(einj_dev))
899-
return PTR_ERR(einj_dev);
885+
einj_dev = faux_device_create("acpi-einj", NULL, &einj_device_ops);
886+
if (!einj_dev)
887+
return -ENODEV;
900888

901-
rc = platform_driver_probe(&einj_driver, einj_probe);
902-
einj_initialized = rc == 0;
889+
einj_initialized = true;
903890

904891
return 0;
905892
}
906893

907894
static void __exit einj_exit(void)
908895
{
909896
if (einj_initialized)
910-
platform_driver_unregister(&einj_driver);
897+
faux_device_destroy(einj_dev);
911898

912-
platform_device_unregister(einj_dev);
913899
}
914900

915901
module_init(einj_init);

drivers/acpi/battery.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,23 @@ static int acpi_battery_get_property(struct power_supply *psy,
243243
break;
244244
case POWER_SUPPLY_PROP_CURRENT_NOW:
245245
case POWER_SUPPLY_PROP_POWER_NOW:
246-
if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN)
246+
if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN) {
247247
ret = -ENODEV;
248-
else
249-
val->intval = battery->rate_now * 1000;
248+
break;
249+
}
250+
251+
val->intval = battery->rate_now * 1000;
252+
/*
253+
* When discharging, the current should be reported as a
254+
* negative number as per the power supply class interface
255+
* definition.
256+
*/
257+
if (psp == POWER_SUPPLY_PROP_CURRENT_NOW &&
258+
(battery->state & ACPI_BATTERY_STATE_DISCHARGING) &&
259+
acpi_battery_handle_discharging(battery)
260+
== POWER_SUPPLY_STATUS_DISCHARGING)
261+
val->intval = -val->intval;
262+
250263
break;
251264
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
252265
case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
@@ -279,8 +292,8 @@ static int acpi_battery_get_property(struct power_supply *psy,
279292
full_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
280293
ret = -ENODEV;
281294
else
282-
val->intval = battery->capacity_now * 100/
283-
full_capacity;
295+
val->intval = DIV_ROUND_CLOSEST_ULL(battery->capacity_now * 100ULL,
296+
full_capacity);
284297
break;
285298
case POWER_SUPPLY_PROP_CAPACITY_LEVEL:
286299
if (battery->state & ACPI_BATTERY_STATE_CRITICAL)

drivers/acpi/ec.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,6 +2329,12 @@ static const struct dmi_system_id acpi_ec_no_wakeup[] = {
23292329
DMI_MATCH(DMI_PRODUCT_NAME, "83Q3"),
23302330
}
23312331
},
2332+
{
2333+
// TUXEDO InfinityBook Pro AMD Gen9
2334+
.matches = {
2335+
DMI_MATCH(DMI_BOARD_NAME, "GXxHRXx"),
2336+
},
2337+
},
23322338
{ },
23332339
};
23342340

drivers/acpi/pci_root.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ static void acpi_pci_root_validate_resources(struct device *dev,
858858
}
859859
}
860860

861-
static void acpi_pci_root_remap_iospace(struct fwnode_handle *fwnode,
861+
static void acpi_pci_root_remap_iospace(const struct fwnode_handle *fwnode,
862862
struct resource_entry *entry)
863863
{
864864
#ifdef PCI_IOBASE

0 commit comments

Comments
 (0)