--- zzzz-none-000/linux-5.15.111/drivers/acpi/acpica/nsxfobj.c 2023-05-11 14:00:40.000000000 +0000 +++ puma7-atom-6670-761/linux-5.15.111/drivers/acpi/acpica/nsxfobj.c 2024-02-07 10:22:36.000000000 +0000 @@ -11,10 +11,64 @@ #include #include "accommon.h" #include "acnamesp.h" +#include "amlcode.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME("nsxfobj") +/* + * This table maps the various Attrib protocols to the byte transfer + * length. Used for the generic serial bus. + */ +#define ACPI_INVALID_PROTOCOL_ID 0x80 +#define ACPI_MAX_PROTOCOL_ID 0x0F +const u8 acpi_protocol_lengths[] = { + ACPI_INVALID_PROTOCOL_ID, /* 0 - reserved */ + ACPI_INVALID_PROTOCOL_ID, /* 1 - reserved */ + 0x00, /* 2 - ATTRIB_QUICK */ + ACPI_INVALID_PROTOCOL_ID, /* 3 - reserved */ + 0x01, /* 4 - ATTRIB_SEND_RECEIVE */ + ACPI_INVALID_PROTOCOL_ID, /* 5 - reserved */ + 0x01, /* 6 - ATTRIB_BYTE */ + ACPI_INVALID_PROTOCOL_ID, /* 7 - reserved */ + 0x02, /* 8 - ATTRIB_WORD */ + ACPI_INVALID_PROTOCOL_ID, /* 9 - reserved */ + 0xFF, /* A - ATTRIB_BLOCK */ + 0xFF, /* B - ATTRIB_BYTES */ + 0x02, /* C - ATTRIB_PROCESS_CALL */ + 0xFF, /* D - ATTRIB_BLOCK_PROCESS_CALL */ + 0xFF, /* E - ATTRIB_RAW_BYTES */ + 0xFF /* F - ATTRIB_RAW_PROCESS_BYTES */ +}; + +/******************************************************************************* + * + * FUNCTION: acpi_get_serial_access_length + * + * PARAMETERS: accessor_type - The type of the protocol indicated by region + * field access attributes + * access_length - The access length of the region field + * + * RETURN: Decoded access length + * + * DESCRIPTION: This routine returns the length of the generic_serial_bus + * protocol bytes + * + ******************************************************************************/ +u32 acpi_get_serial_access_length(u32 accessor_type, u32 access_length) +{ + if ((accessor_type > ACPI_MAX_PROTOCOL_ID) || + (acpi_protocol_lengths[accessor_type] == ACPI_INVALID_PROTOCOL_ID)) + { + ACPI_ERROR((AE_INFO, "Invalid Field/AccessAs protocol ID: 0x%4.4X", + accessor_type)); + return (ACPI_MAX_GSBUS_BUFFER_SIZE); + } + + return (acpi_protocol_lengths[accessor_type]); +} +ACPI_EXPORT_SYMBOL(acpi_get_serial_access_length); + /******************************************************************************* * * FUNCTION: acpi_get_type