Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2340540lqo; Mon, 20 May 2024 02:46:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVmJe2IyKCQJXoP1Y82TjOZuD3MkrMqusr+doIyOKrwTKJPn5t+kT3VA/rVPPtv9TJqnSqFm56S2m8Opz7QkhH0vjSnfsxo/gUPkTZg5w== X-Google-Smtp-Source: AGHT+IGkYWKGTtbVvLiFqEok+AaFTtZit23TBYf3MAO+mPylGTNAUdf8K4uvE7qkhSuDCKGsPoL/ X-Received: by 2002:a17:90a:296:b0:2b3:463d:992b with SMTP id 98e67ed59e1d1-2b6ccef6431mr25117787a91.42.1716198391879; Mon, 20 May 2024 02:46:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716198391; cv=pass; d=google.com; s=arc-20160816; b=cdJK8FmHwOQuBTwTCICUUqwrt6Y7MlbNX0k78TytDVyoOAF4Gr0LEI5g8VUKY2OOz2 6lQAkRokGrTIBQ2deZJm8QEyOeWKQHEDxtoDqMRp6ozy8rVHUWtESlgwQtSpua2WsSW0 zqiltZDp7JRRsoCNEQSQCthVjDMzbsrzXMvCydyXyBIRbOqk7dkDZMC867THG1o8XE4O VmACXr9o0282CFiU/NyswRVGfulJAdiQFnU53VZoxnj/2DYesbUGY07KP/fsCNDNFv/X zytyjQRbZ6pKYJWFB4z9rNU4m6OM80/1Qw4v71jXZRufANHLLWMne3aGl1CZyZsEfUuJ OiBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=G0dO6DbL0uhY/Wx1353DQO+h9YkJXLCVRy25eCIhHIs=; fh=O7W32hzrxLioy2lU7cq0myUffGADZNPHRUPmOpshY3A=; b=MShs3kVRbp/f2/SyPkZR7nkall+JSKHCpClUy7vkHyWAl6rkNEwA2rb1QmkjSjcxi/ GpHWN6CSMLsbI/HaZhQLCMZPka57ESciVGjTjGyLYaquPTMnX2PncLwPVjQ80xIFsX5o 5j9BBU9Q4HPMLdILKMZ5HufrpaAAfEz3LqbeExQRdCGsr4iZna02Ei/fzagIOEVAlDHY RE2wa+YH2RB96TOO3tu8x3FXpJO2ZJlTn9MxmlY/sL4uA9H23QmC93a7BvAS5XchJ2jG 4xMRiqLdUVQyO3woDiHwcF8x8zwT/bS3CqCA/4wzfJaMTjuyq6STte+cKRhJNuGWGrOX BfCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TF0f6pns; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-183561-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183561-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b670e354d1si2706116a91.13.2024.05.20.02.46.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 02:46:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183561-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TF0f6pns; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-183561-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183561-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id ADD312829C9 for ; Mon, 20 May 2024 09:45:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A1B136AFE; Mon, 20 May 2024 09:45:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TF0f6pns" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64ED724B5B; Mon, 20 May 2024 09:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716198353; cv=none; b=OhERLr1AMAlYWIKftGYjR7me0dUG6U774EAYZH6AIRxZiyMSY2dzdFuDJPNt+fN/0RQs50zLOx/FUtSv6saB9KLai4egJEdrSl0XjgrsV2bQpdUc4etZDIB2Y3ysvxOrACxcn8iHFTjGFLwAWOxxFpGvQgN5WNUIEQlsE2xgRkM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716198353; c=relaxed/simple; bh=Zdw3Q1wFX6fCgYfdSfW3vPj43L9qIOAEPDK3nk6Nlzg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UXNME1jxrnOgS/DMH0Dms+ltKohvqO/SMnocP/sWlrgHnbzYjgj9syTyk6jgW7hHA7o0JJ6nL3TtBakNLvciv2+n0s1txx4QxVHVvTn+1hedkFfKEj8muySZPAQ/TR3yGE05UgXR/9kycmOAlIq0GLl0aC/UpzNjd+7EllbzolA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TF0f6pns; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68295C2BD10; Mon, 20 May 2024 09:45:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716198352; bh=Zdw3Q1wFX6fCgYfdSfW3vPj43L9qIOAEPDK3nk6Nlzg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TF0f6pns3XbIdT7W5y9eXDZ5S7ibijiJQj0K399dm6EaOxSpxgpag2sU6fH1j+9lY qUOlTEaaBJo66i5j4W8x/Q1MkHw/mV6DyAcxe2BGhk1ADk5nGMhSEL98If5spJ8aT9 hEp8zZx62bul4k3Pv+5YikKa3fx8VTLk69jS0fvZkiGR6jN1gUz5nnm7phNr8RX6mI pHfyIFsPjbZPCjqOqYKYy7E6jINTzEVmbf4ICXyn4jdAyaQ1YLtXjLIL6AwsKRjpfs yjBBNKjzeXUKk2eYOi8EK+Pm6gpALhyya0S8E0KZ/oVZl5yEMFi6AGcMuyqrJHYPJR sG96754ebMMRg== Date: Mon, 20 May 2024 17:45:49 +0800 From: Tzung-Bi Shih To: Ben Walsh Cc: Benson Leung , Guenter Roeck , "Dustin L. Howett" , Kieran Levin , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Mario Limonciello , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/6] platform/chrome: cros_ec_lpc: MEC access can return error code Message-ID: References: <20240515055631.5775-1-ben@jubnut.com> <20240515055631.5775-2-ben@jubnut.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240515055631.5775-2-ben@jubnut.com> On Wed, May 15, 2024 at 06:56:26AM +0100, Ben Walsh wrote: > diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c [...] > @@ -116,14 +118,19 @@ static u8 cros_ec_lpc_write_bytes(unsigned int offset, unsigned int length, > * An instance of the read function of struct lpc_driver_ops, used for the > * MEC variant of LPC EC. > */ > -static u8 cros_ec_lpc_mec_read_bytes(unsigned int offset, unsigned int length, > - u8 *dest) > +static int cros_ec_lpc_mec_read_bytes(unsigned int offset, unsigned int length, > + u8 *dest) > { > - int in_range = cros_ec_lpc_mec_in_range(offset, length); > + int in_range; > > - if (in_range < 0) > + if (length == 0) > return 0; > > + in_range = cros_ec_lpc_mec_in_range(offset, length); > + > + if (in_range < 0) > + return in_range; > + > return in_range ? > cros_ec_lpc_io_bytes_mec(MEC_IO_READ, > offset - EC_HOST_CMD_REGION0, The `in_range` change looks irrelevant to the patch. Or it should rather be an independent patch if it fixes something. > @@ -135,14 +142,19 @@ static u8 cros_ec_lpc_mec_read_bytes(unsigned int offset, unsigned int length, > * An instance of the write function of struct lpc_driver_ops, used for the > * MEC variant of LPC EC. > */ > -static u8 cros_ec_lpc_mec_write_bytes(unsigned int offset, unsigned int length, > - const u8 *msg) > +static int cros_ec_lpc_mec_write_bytes(unsigned int offset, unsigned int length, > + const u8 *msg) > { > - int in_range = cros_ec_lpc_mec_in_range(offset, length); > + int in_range; > > - if (in_range < 0) > + if (length == 0) > return 0; > > + in_range = cros_ec_lpc_mec_in_range(offset, length); > + > + if (in_range < 0) > + return in_range; > + > return in_range ? > cros_ec_lpc_io_bytes_mec(MEC_IO_WRITE, > offset - EC_HOST_CMD_REGION0, Same as above. > @@ -179,28 +194,41 @@ static int cros_ec_pkt_xfer_lpc(struct cros_ec_device *ec, [...] > /* Check result */ > - msg->result = cros_ec_lpc_ops.read(EC_LPC_ADDR_HOST_DATA, 1, &sum); > + ret = cros_ec_lpc_ops.read(EC_LPC_ADDR_HOST_DATA, 1, &sum); > + if (ret < 0) > + goto done; > + msg->result = sum; Even though they are equivalent, `msg->result = ret` looks more intuitive. > @@ -255,32 +286,47 @@ static int cros_ec_cmd_xfer_lpc(struct cros_ec_device *ec, [...] > /* Check result */ > - msg->result = cros_ec_lpc_ops.read(EC_LPC_ADDR_HOST_DATA, 1, &sum); > + ret = cros_ec_lpc_ops.read(EC_LPC_ADDR_HOST_DATA, 1, &sum); > + if (ret < 0) > + goto done; > + msg->result = sum; Same as above.