From patchwork Mon Mar 1 16:05:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 388705 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3608724jap; Mon, 1 Mar 2021 10:58:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcCRzOIGPogP2xO/sy1A9AjM1AuDH22Csm8T8FaA8wmyk6mofTris60oFHw0DpnNIkfjXe X-Received: by 2002:a17:907:1607:: with SMTP id hb7mr17052962ejc.265.1614625137023; Mon, 01 Mar 2021 10:58:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614625137; cv=none; d=google.com; s=arc-20160816; b=tWdOVDWKrQOL4mdFwqGoVD1orA4NzPbKIGhqYdANi7cp8Kk2ipylZJs6RU+0ni/Qu0 CJsZnGTWwRxnRGOGCofyc6mbnDbMxctq/3iLkefD6SN2+zyusvzXKh6Hh1KRZEyhDdrA WEpv05auE5maEF/jmfZbyHuVs00CWmEKoKxJSTHFrLrP3G8qCzxCDhWNh7vBqu43Rh/v pFWJokz33SgzleZ16iKPOvvU2PEXzZq+jzyH8ZwOAyGPKMS0YQD5QJriIUDEuWD4lovM Pw5CLjB9Nl/XlM2Q0fNRaUSt3B4M8je3th/mLG0bM9px4SzDHjzHO12Dpd2HoLlQ9CkU 3j/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wb24mw5w9TyA29WtvuYm9hnROcDecMde3iokT739pOw=; b=MrcdsKyesRmvQ6STOkEtGgjkJumL9gZKD962PbfGa+tyGfd8Js++y72xckLsNpdcgB a3j+MKNCMMuE8OT3sXD4qFktl1n7Bfbwfsdd0h4cphEw84bmDo7oeZpmt2BbUZWr25RK kF+/TjKcgaaVVkhsf7fJAE0KxZS8RSHCRs35sLzgk9RyClwBI9Bf6hOFR5eDutpey1Zw IXBDfR9we/EEZd6Y7TfdwgGlpI28WB3+3lWKI1tVZtlkFyb1WD+udwv6aFdur1zDJaFY 2ir6tElyBeVd7CkVZcF8RH/2s3ChnWkyg+95553rUIZrNa6EGHlEQwkT7SmhEVJy2QVV fBUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=af4zszYD; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z18si11104237ejx.409.2021.03.01.10.58.56; Mon, 01 Mar 2021 10:58:57 -0800 (PST) Received-SPF: pass (google.com: domain of stable-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=@linuxfoundation.org header.s=korg header.b=af4zszYD; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237049AbhCAS45 (ORCPT + 13 others); Mon, 1 Mar 2021 13:56:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:57718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240395AbhCASvT (ORCPT ); Mon, 1 Mar 2021 13:51:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CBFD865166; Mon, 1 Mar 2021 17:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614618417; bh=0hy/Litt/zTFvA1HJE9o6wOGall1zdTH4sHAIwi4Wjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=af4zszYDrOzQkrdqoUSH7mQg0Q/6EHZcRY+M7Z90sASSNS+xdKu2JPjgcDbKlUvMb 1rM/C4LrdVvqcORI9fdveWlJhh30kJPt1pUBi8XSmmrCt9mrMAbPgtoAhA4le/d4vz 04UdvJGV2muZSygi7X4cicbkow+/85pWhhMPDVik= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jorge Ramirez-Ortiz , Arnd Bergmann , Jens Wiklander , Sasha Levin Subject: [PATCH 5.10 080/663] optee: simplify i2c access Date: Mon, 1 Mar 2021 17:05:28 +0100 Message-Id: <20210301161145.693534566@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann [ Upstream commit 67bc809752796acb2641ca343cad5b45eef31d7c ] Storing a bogus i2c_client structure on the stack adds overhead and causes a compile-time warning: drivers/tee/optee/rpc.c:493:6: error: stack frame size of 1056 bytes in function 'optee_handle_rpc' [-Werror,-Wframe-larger-than=] void optee_handle_rpc(struct tee_context *ctx, struct optee_rpc_param *param, Change the implementation of handle_rpc_func_cmd_i2c_transfer() to open-code the i2c_transfer() call, which makes it easier to read and avoids the warning. Fixes: c05210ab9757 ("drivers: optee: allow op-tee to access devices on the i2c bus") Tested-by: Jorge Ramirez-Ortiz Signed-off-by: Arnd Bergmann Signed-off-by: Jens Wiklander Signed-off-by: Sasha Levin --- drivers/tee/optee/rpc.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) -- 2.27.0 diff --git a/drivers/tee/optee/rpc.c b/drivers/tee/optee/rpc.c index 1e3614e4798f0..6cbb3643c6c48 100644 --- a/drivers/tee/optee/rpc.c +++ b/drivers/tee/optee/rpc.c @@ -54,8 +54,9 @@ bad: static void handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx, struct optee_msg_arg *arg) { - struct i2c_client client = { 0 }; struct tee_param *params; + struct i2c_adapter *adapter; + struct i2c_msg msg = { }; size_t i; int ret = -EOPNOTSUPP; u8 attr[] = { @@ -85,48 +86,48 @@ static void handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx, goto bad; } - client.adapter = i2c_get_adapter(params[0].u.value.b); - if (!client.adapter) + adapter = i2c_get_adapter(params[0].u.value.b); + if (!adapter) goto bad; if (params[1].u.value.a & OPTEE_MSG_RPC_CMD_I2C_FLAGS_TEN_BIT) { - if (!i2c_check_functionality(client.adapter, + if (!i2c_check_functionality(adapter, I2C_FUNC_10BIT_ADDR)) { - i2c_put_adapter(client.adapter); + i2c_put_adapter(adapter); goto bad; } - client.flags = I2C_CLIENT_TEN; + msg.flags = I2C_M_TEN; } - client.addr = params[0].u.value.c; - snprintf(client.name, I2C_NAME_SIZE, "i2c%d", client.adapter->nr); + msg.addr = params[0].u.value.c; + msg.buf = params[2].u.memref.shm->kaddr; + msg.len = params[2].u.memref.size; switch (params[0].u.value.a) { case OPTEE_MSG_RPC_CMD_I2C_TRANSFER_RD: - ret = i2c_master_recv(&client, params[2].u.memref.shm->kaddr, - params[2].u.memref.size); + msg.flags |= I2C_M_RD; break; case OPTEE_MSG_RPC_CMD_I2C_TRANSFER_WR: - ret = i2c_master_send(&client, params[2].u.memref.shm->kaddr, - params[2].u.memref.size); break; default: - i2c_put_adapter(client.adapter); + i2c_put_adapter(adapter); goto bad; } + ret = i2c_transfer(adapter, &msg, 1); + if (ret < 0) { arg->ret = TEEC_ERROR_COMMUNICATION; } else { - params[3].u.value.a = ret; + params[3].u.value.a = msg.len; if (optee_to_msg_param(arg->params, arg->num_params, params)) arg->ret = TEEC_ERROR_BAD_PARAMETERS; else arg->ret = TEEC_SUCCESS; } - i2c_put_adapter(client.adapter); + i2c_put_adapter(adapter); kfree(params); return; bad: