Skip to content

Commit 47828d2

Browse files
malattiaandy-shev
authored andcommitted
platform/x86: sony-laptop: SNC calls should handle BUFFER types
After commit 6d232b2 ("ACPICA: Dispatcher: always generate buffer objects for ASL create_field() operator") ACPICA creates buffers even when new fields are small enough to fit into an integer. Many SNC calls counted on the old behaviour. Since sony-laptop already handles the INTEGER/BUFFER case in sony_nc_buffer_call, switch sony_nc_int_call to use its more generic function instead. Fixes: 6d232b2 ("ACPICA: Dispatcher: always generate buffer objects for ASL create_field() operator") Reported-by: Dominik Mierzejewski <[email protected]> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207491 Reported-by: William Bader <[email protected]> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1830150 Signed-off-by: Mattia Dongili <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]>
1 parent b14cd9d commit 47828d2

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

drivers/platform/x86/sony-laptop.c

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -757,33 +757,6 @@ static union acpi_object *__call_snc_method(acpi_handle handle, char *method,
757757
return result;
758758
}
759759

760-
static int sony_nc_int_call(acpi_handle handle, char *name, int *value,
761-
int *result)
762-
{
763-
union acpi_object *object = NULL;
764-
if (value) {
765-
u64 v = *value;
766-
object = __call_snc_method(handle, name, &v);
767-
} else
768-
object = __call_snc_method(handle, name, NULL);
769-
770-
if (!object)
771-
return -EINVAL;
772-
773-
if (object->type != ACPI_TYPE_INTEGER) {
774-
pr_warn("Invalid acpi_object: expected 0x%x got 0x%x\n",
775-
ACPI_TYPE_INTEGER, object->type);
776-
kfree(object);
777-
return -EINVAL;
778-
}
779-
780-
if (result)
781-
*result = object->integer.value;
782-
783-
kfree(object);
784-
return 0;
785-
}
786-
787760
#define MIN(a, b) (a > b ? b : a)
788761
static int sony_nc_buffer_call(acpi_handle handle, char *name, u64 *value,
789762
void *buffer, size_t buflen)
@@ -795,24 +768,44 @@ static int sony_nc_buffer_call(acpi_handle handle, char *name, u64 *value,
795768
if (!object)
796769
return -EINVAL;
797770

798-
if (object->type == ACPI_TYPE_BUFFER) {
771+
if (!buffer) {
772+
/* do nothing */
773+
} else if (object->type == ACPI_TYPE_BUFFER) {
799774
len = MIN(buflen, object->buffer.length);
775+
memset(buffer, 0, buflen);
800776
memcpy(buffer, object->buffer.pointer, len);
801777

802778
} else if (object->type == ACPI_TYPE_INTEGER) {
803779
len = MIN(buflen, sizeof(object->integer.value));
780+
memset(buffer, 0, buflen);
804781
memcpy(buffer, &object->integer.value, len);
805782

806783
} else {
807-
pr_warn("Invalid acpi_object: expected 0x%x got 0x%x\n",
808-
ACPI_TYPE_BUFFER, object->type);
784+
pr_warn("Unexpected acpi_object: 0x%x\n", object->type);
809785
ret = -EINVAL;
810786
}
811787

812788
kfree(object);
813789
return ret;
814790
}
815791

792+
static int sony_nc_int_call(acpi_handle handle, char *name, int *value, int
793+
*result)
794+
{
795+
int ret;
796+
797+
if (value) {
798+
u64 v = *value;
799+
800+
ret = sony_nc_buffer_call(handle, name, &v, result,
801+
sizeof(*result));
802+
} else {
803+
ret = sony_nc_buffer_call(handle, name, NULL, result,
804+
sizeof(*result));
805+
}
806+
return ret;
807+
}
808+
816809
struct sony_nc_handles {
817810
u16 cap[0x10];
818811
struct device_attribute devattr;

0 commit comments

Comments
 (0)