Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp106879ybg; Mon, 8 Jun 2020 17:46:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyFi9+RMrGu5eBqMj1oOMowvlUlGUHoYsDLiSiYHP8oWTgH3ouveEMq3/MU4zF9OCl3d5M X-Received: by 2002:a17:906:2c44:: with SMTP id f4mr5352574ejh.183.1591663612942; Mon, 08 Jun 2020 17:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591663612; cv=none; d=google.com; s=arc-20160816; b=hJ8Yqk5fOwnPHHD318B4PuQ0ZCjRdTODwTFrCPftsaZeRbQLSxU5kIZAD/I+eMyIew K1swrqC1RShgOdJklsiRu6/uqlsYiaIxZp0uMD+KzxTasP4JQ0JdW4CINwTt28gKCCgu Y2ZCp3pC+ELMdpLoMqAPN9Eo60j2JQl2CDdxO4LRQ6H141mwS1cFbsta7mk4AHRgJuhX 0knlfh9A21UxtQMUah8EcRvuctI8ue0+4/2I0Ngoa41/vPOVKpLA/ev58foIzzu3/2Dm N2DmRyRMOZst6QoXF74udmG1JMQjOBZOzjzkHyJqFUFylZBSuEeErbXW/3KwoA0ctl/V 68hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dVL1uLsGhN62z8vYaLIOAK28SwCrtMA2wu0pd5jOga8=; b=SPRTUIC9iAbQCyPKvHCqOnFppB2WUvzVXPYFAk7F22eNFMW+LW3pg51dzE9bdkTzmL jKaPLwXX8wMn8J6vZF6iHozgnO4+iwK27pkflLUPUb0nKBvEs3usPq7PNJay9Dw6ppvi PsIECVkMq5xkl4qmIsqMa/SOk1ZooSEnj0Jz3JMr1eiumP3hNsHi7I17ntPa9lmhqOy2 giv9xtH1DppS6yLZ4ENQW1C7gFeU4Fpw1ru0W4weMk8LvwyC/nqgkp5y3AxS+XrrddE8 bWv9bwaoUpJkiT0/gknusxBdUcDuwKRxZgcfg3gHCEgFasIn42Ms1PUGno3B17LyOlMb E2Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i4EiJ4Aa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y2si1758479edp.396.2020.06.08.17.46.29; Mon, 08 Jun 2020 17:46:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i4EiJ4Aa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729018AbgFHXL6 (ORCPT + 99 others); Mon, 8 Jun 2020 19:11:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:56360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728593AbgFHXKO (ORCPT ); Mon, 8 Jun 2020 19:10:14 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B8C17214F1; Mon, 8 Jun 2020 23:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657814; bh=aAJYvm9d6p5eO8dZlrOnhcqUZPhDSrpeh5Xn8NraI1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i4EiJ4Aa9art/OcN1e+Ro7TpC7JKLxd+oHj64pUT1Yb7SlaUw3C9jJo+jWfEPXukh bVuXWnFuuulSl2uyDuf872AhFx77ToIn+SbLPWSD4T/7Z2Qmff1lBpjja2wnxXT3Nm oUW8W2Zjgg7JDyz+jxvkHlXBUAr/mUoO4WhQwOgs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mattia Dongili , Dominik Mierzejewski , William Bader , Andy Shevchenko , Sasha Levin , platform-driver-x86@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 189/274] platform/x86: sony-laptop: SNC calls should handle BUFFER types Date: Mon, 8 Jun 2020 19:04:42 -0400 Message-Id: <20200608230607.3361041-189-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mattia Dongili [ Upstream commit 47828d22539f76c8c9dcf2a55f18ea3a8039d8ef ] After commit 6d232b29cfce ("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: 6d232b29cfce ("ACPICA: Dispatcher: always generate buffer objects for ASL create_field() operator") Reported-by: Dominik Mierzejewski Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207491 Reported-by: William Bader Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1830150 Signed-off-by: Mattia Dongili Signed-off-by: Andy Shevchenko Signed-off-by: Sasha Levin --- drivers/platform/x86/sony-laptop.c | 53 +++++++++++++----------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c index e4ef3dc3bc2f..e5a1b5533408 100644 --- a/drivers/platform/x86/sony-laptop.c +++ b/drivers/platform/x86/sony-laptop.c @@ -757,33 +757,6 @@ static union acpi_object *__call_snc_method(acpi_handle handle, char *method, return result; } -static int sony_nc_int_call(acpi_handle handle, char *name, int *value, - int *result) -{ - union acpi_object *object = NULL; - if (value) { - u64 v = *value; - object = __call_snc_method(handle, name, &v); - } else - object = __call_snc_method(handle, name, NULL); - - if (!object) - return -EINVAL; - - if (object->type != ACPI_TYPE_INTEGER) { - pr_warn("Invalid acpi_object: expected 0x%x got 0x%x\n", - ACPI_TYPE_INTEGER, object->type); - kfree(object); - return -EINVAL; - } - - if (result) - *result = object->integer.value; - - kfree(object); - return 0; -} - #define MIN(a, b) (a > b ? b : a) static int sony_nc_buffer_call(acpi_handle handle, char *name, u64 *value, void *buffer, size_t buflen) @@ -795,17 +768,20 @@ static int sony_nc_buffer_call(acpi_handle handle, char *name, u64 *value, if (!object) return -EINVAL; - if (object->type == ACPI_TYPE_BUFFER) { + if (!buffer) { + /* do nothing */ + } else if (object->type == ACPI_TYPE_BUFFER) { len = MIN(buflen, object->buffer.length); + memset(buffer, 0, buflen); memcpy(buffer, object->buffer.pointer, len); } else if (object->type == ACPI_TYPE_INTEGER) { len = MIN(buflen, sizeof(object->integer.value)); + memset(buffer, 0, buflen); memcpy(buffer, &object->integer.value, len); } else { - pr_warn("Invalid acpi_object: expected 0x%x got 0x%x\n", - ACPI_TYPE_BUFFER, object->type); + pr_warn("Unexpected acpi_object: 0x%x\n", object->type); ret = -EINVAL; } @@ -813,6 +789,23 @@ static int sony_nc_buffer_call(acpi_handle handle, char *name, u64 *value, return ret; } +static int sony_nc_int_call(acpi_handle handle, char *name, int *value, int + *result) +{ + int ret; + + if (value) { + u64 v = *value; + + ret = sony_nc_buffer_call(handle, name, &v, result, + sizeof(*result)); + } else { + ret = sony_nc_buffer_call(handle, name, NULL, result, + sizeof(*result)); + } + return ret; +} + struct sony_nc_handles { u16 cap[0x10]; struct device_attribute devattr; -- 2.25.1