Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp727645imm; Thu, 13 Sep 2018 06:55:22 -0700 (PDT) X-Google-Smtp-Source: ANB0VdahQYu3EpH7e4CwkfQ+IYpbCJSc63sfV1kRyCm7sfopUS8fCKmnPRjqcQ9zaQS6cJ/gcWvx X-Received: by 2002:a63:291:: with SMTP id 139-v6mr7126848pgc.365.1536846922493; Thu, 13 Sep 2018 06:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846922; cv=none; d=google.com; s=arc-20160816; b=c5jtfDiBcl8Ju+oVdI5POWxgr95GanDM7I7Um+O2hjG+o+pUejAQM08YkGYBr306mb CCjqQrWn2Vzf031wJr7FC/CiRr2Qhp2xP+ETBxlLLfAkx7J2QUBYUPioANu7pQgBDRZW +l7lIfCX8H548Pa5UTm5SWXYZhiC9e6igsmEiuzM521kHfkT3/XjDFh7IhwcRxoUCY/4 8d+5NBlZBArRB+MIYfOcXc6ax/CCDM3elRGPlGjEGtn5zHeb0rY59D+MHJydu6BFNNKO jcCkzqIzP0qovLaZgykg8wJtfVrSyIei3+J9XhCOIXEzy+BH/Ug0pWQiFXozgV1eGfaj OW5g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=bpOmT3c0qdRRoZAmjLAF9mM9t/AqUx7r2oXsnvqGCSo=; b=K5kV3c/4+wCUtBwHGFfTZudLGIEn0xKOgsW/ixXSG4jS+QGwXXrEJaz891tiR8bUfw meTnyqj1g1vzZeT/Hzu6ObIN6qGgM91A0yzqCVUysX96DxveEeo7TbCm+63okCI9tDaW YWWs2si18QWTd2d/VT0tZu3jB+swxxqnxtNvc9BffJyEO6deCw91z23gZyUBHwQAG6Cs Rt7ayPLbFTeZZQtfmCQjlakRhYP/4evad9c1DmOFWRtSuyEYEVK11kdBP51VdJldsimM tycJ8U+jP/hiaSC0VZ7FNPVqnPARrqRqI8WdiLFSO6AwVesQrdMBfrF5Ys6Umevik7tt UJjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72-v6si4124036pfq.6.2018.09.13.06.55.06; Thu, 13 Sep 2018 06:55:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731140AbeIMTDV (ORCPT + 99 others); Thu, 13 Sep 2018 15:03:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33732 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728810AbeIMTDU (ORCPT ); Thu, 13 Sep 2018 15:03:20 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BD11BCE7; Thu, 13 Sep 2018 13:53:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Mika Westerberg , Wolfram Sang , Sasha Levin Subject: [PATCH 4.18 055/197] i2c: core: ACPI: Make acpi_gsb_i2c_read_bytes() check i2c_transfer return value Date: Thu, 13 Sep 2018 15:30:04 +0200 Message-Id: <20180913131843.728550783@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hans de Goede [ Upstream commit 0a30446c0dca3483c384b54a431cc951e15f7e79 ] Currently acpi_gsb_i2c_read_bytes() directly returns i2c_transfer's return value. i2c_transfer returns a value < 0 on error and 2 (for 2 successfully executed transfers) on success. But the ACPI code expects 0 on success, so currently acpi_gsb_i2c_read_bytes()'s caller does: if (status > 0) status = 0; This commit makes acpi_gsb_i2c_read_bytes() return a value which can be directly consumed by the ACPI code, mirroring acpi_gsb_i2c_write_bytes(), this commit also makes acpi_gsb_i2c_read_bytes() explitcly check that i2c_transfer returns 2, rather then accepting any value > 0. Signed-off-by: Hans de Goede Acked-by: Mika Westerberg Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-core-acpi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -453,8 +453,12 @@ static int acpi_gsb_i2c_read_bytes(struc else dev_err(&client->adapter->dev, "i2c read %d bytes from client@%#x starting at reg %#x failed, error: %d\n", data_len, client->addr, cmd, ret); - } else { + /* 2 transfers must have completed successfully */ + } else if (ret == 2) { memcpy(data, buffer, data_len); + ret = 0; + } else { + ret = -EIO; } kfree(buffer); @@ -595,8 +599,6 @@ i2c_acpi_space_handler(u32 function, acp if (action == ACPI_READ) { status = acpi_gsb_i2c_read_bytes(client, command, gsb->data, info->access_length); - if (status > 0) - status = 0; } else { status = acpi_gsb_i2c_write_bytes(client, command, gsb->data, info->access_length);