Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ebd2eaa authored by Bob Moore's avatar Bob Moore Committed by Rafael J. Wysocki
Browse files

ACPICA: Cleanup for all string-to-integer conversions

ACPICA commit e2e72a351201fd58e4694418859ae2c247dafca0

Consolidate multiple versions of strtoul64 to one common version.
limit possible bases to either 10 or 16.
Handles both implicit and explicit conversions.
Added a 2-character ascii-to-hex function for GPEs and buffers.
Adds a new file, utstrtoul64.c

Link: https://github.com/acpica/acpica/commit/e2e72a35


Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 60361b75
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@ acpi-y += \
	utresrc.o	\
	utstate.o	\
	utstring.o	\
	utstrtoul64.o	\
	utxface.o	\
	utxfinit.o	\
	utxferror.o	\
+10 −7
Original line number Diff line number Diff line
@@ -196,14 +196,15 @@ void acpi_ut_strlwr(char *src_string);

int acpi_ut_stricmp(char *string1, char *string2);

acpi_status
acpi_ut_strtoul64(char *string,
		  u32 base, u32 max_integer_byte_width, u64 *ret_integer);

/* Values for max_integer_byte_width above */
acpi_status acpi_ut_strtoul64(char *string, u32 flags, u64 *ret_integer);

#define ACPI_MAX32_BYTE_WIDTH       4
#define ACPI_MAX64_BYTE_WIDTH       8
/*
 * Values for Flags above
 * Note: LIMIT values correspond to acpi_gbl_integer_byte_width values (4/8)
 */
#define ACPI_STRTOUL_32BIT          0x04	/* 4 bytes */
#define ACPI_STRTOUL_64BIT          0x08	/* 8 bytes */
#define ACPI_STRTOUL_BASE16         0x10	/* Default: Base10/16 */

/*
 * utglobal - Global data structures and procedures
@@ -233,6 +234,8 @@ const char *acpi_ut_get_event_name(u32 event_id);

char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);

acpi_status acpi_ut_ascii_to_hex_byte(char *two_ascii_chars, u8 *return_byte);

u8 acpi_ut_ascii_char_to_hex(int hex_char);

u8 acpi_ut_valid_object_type(acpi_object_type type);
+4 −3
Original line number Diff line number Diff line
@@ -277,8 +277,9 @@ acpi_db_convert_to_object(acpi_object_type type,
	default:

		object->type = ACPI_TYPE_INTEGER;
		status =
		    acpi_ut_strtoul64(string, 16, acpi_gbl_integer_byte_width,
		status = acpi_ut_strtoul64(string,
					   (acpi_gbl_integer_byte_width |
					    ACPI_STRTOUL_BASE16),
					   &object->integer.value);
		break;
	}
+2 −1
Original line number Diff line number Diff line
@@ -133,7 +133,8 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
	 * Result of predicate evaluation must be an Integer
	 * object. Implicitly convert the argument if necessary.
	 */
	status = acpi_ex_convert_to_integer(obj_desc, &local_obj_desc, 16);
	status = acpi_ex_convert_to_integer(obj_desc, &local_obj_desc,
					    ACPI_STRTOUL_BASE16);
	if (ACPI_FAILURE(status)) {
		goto cleanup;
	}
+5 −2
Original line number Diff line number Diff line
@@ -323,7 +323,9 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle,
	struct acpi_gpe_walk_info *walk_info =
	    ACPI_CAST_PTR(struct acpi_gpe_walk_info, context);
	struct acpi_gpe_event_info *gpe_event_info;
	acpi_status status;
	u32 gpe_number;
	u8 temp_gpe_number;
	char name[ACPI_NAME_SIZE + 1];
	u8 type;

@@ -377,8 +379,8 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle,

	/* 4) The last two characters of the name are the hex GPE Number */

	gpe_number = strtoul(&name[2], NULL, 16);
	if (gpe_number == ACPI_UINT32_MAX) {
	status = acpi_ut_ascii_to_hex_byte(&name[2], &temp_gpe_number);
	if (ACPI_FAILURE(status)) {

		/* Conversion failed; invalid method, just ignore it */

@@ -390,6 +392,7 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle,

	/* Ensure that we have a valid GPE number for this GPE block */

	gpe_number = (u32)temp_gpe_number;
	gpe_event_info =
	    acpi_ev_low_get_gpe_info(gpe_number, walk_info->gpe_block);
	if (!gpe_event_info) {
Loading