Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1416995lqj; Tue, 4 Jun 2024 00:13:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUb5THqwmiwY+ezyxjG5KN5i5StVaGYnvrr8+u35dB+PL4cgb3ndmYQAAco2zGwr508m8sQN+fVbpQV4bY6gOT3bO2NBdnDiUt0qk5+EQ== X-Google-Smtp-Source: AGHT+IG9/9GRfVfIqtd7Y7cm5/YnzOpg4ywoCekxsacmXmefZFbIlUIfY1MT7NV/5E+cHjXnrnFa X-Received: by 2002:a05:6808:3010:b0:3c9:9636:eb48 with SMTP id 5614622812f47-3d1e34935b3mr12798677b6e.17.1717485183178; Tue, 04 Jun 2024 00:13:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717485183; cv=pass; d=google.com; s=arc-20160816; b=eZYJXKdXNpx5smgZmx9lhumn93XTmYcKZh9TqCpMrbi2glGMrAcloiuYGEZu2kuJDs T+boy9YMpiCl5QIxEf9Lu3vch4mn9iP0ykX8HUiQTyzZkKiYHf+I7UGu118T5yXJJhXX 8BGTYI+YV8cEZ/BYFnwBx9xdozySX8+4xC2ByNTi6nZlJ8K7uT30+pai0S9e1Zuwv2k4 oOGbLw3cDbsNKjJZaBvSoz6QKX1c0jJXkzgMBokWCpjt2TlFQZvaVRIw3Tqi0ROFIiTg qYSdlyecr1UhePf/3N2tEr16tVVR+WGj1MABk/c69qyr89zDkLcZal9UWxzNwsbECcDz qPXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=x5XGR3aSMREVjpnJPLS8gCmXguO6yjczNgEYlWmCxUU=; fh=rz0JTVdBJ3Pn6g1C60m/r9OPpmK5LlEZ6Q6qH6dmUkk=; b=JSG2Af1dgKrVDc0cgG21Gj7o62R6v4/nVHxvY68j4e81U5atViNuTq9cJ8szxm6Zkk J6607Ax9qJqfeJx5/z5YZWADPBRprIDJDjWopHSxCg3gUkUe9M8QfEvSm0mNnBUvPLn+ lOzVJIWjsru6SAoX3E9NaITUGo4aFenSs5ft4tGBgzGcSmL8PpNyp1uyOdwUsVKuAbK9 zSJmFhmaZKxV/4pcoqFj+xj1ZfyVShQJdNw1tT/h+r0VQYzcGVeJxd3a58AaIomuoErQ w+VMtjdfcfuuXHscmYXqegV4varzznTNY/Sh5xqr0+kExGvei3P8KqxutaswyFBcvwvH 2EaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@jubnut.com header.s=MBO0001 header.b=V3qgGZXR; arc=pass (i=1 spf=pass spfdomain=jubnut.com dkim=pass dkdomain=jubnut.com dmarc=pass fromdomain=jubnut.com); spf=pass (google.com: domain of linux-kernel+bounces-199639-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=jubnut.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4a741ec9si104827516d6.145.2024.06.04.00.13.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 00:13:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199639-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@jubnut.com header.s=MBO0001 header.b=V3qgGZXR; arc=pass (i=1 spf=pass spfdomain=jubnut.com dkim=pass dkdomain=jubnut.com dmarc=pass fromdomain=jubnut.com); spf=pass (google.com: domain of linux-kernel+bounces-199639-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=jubnut.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F17DA1C2152D for ; Mon, 3 Jun 2024 19:26:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC9231386DF; Mon, 3 Jun 2024 19:26:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=jubnut.com header.i=@jubnut.com header.b="V3qgGZXR" Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) (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 8CC23137748 for ; Mon, 3 Jun 2024 19:26:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.161 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717442789; cv=none; b=FqOVvpQE2YOVGeyiip3DUYIjoBX+qUzPMKm8yDI8LU7QcSkM2UmL+JQjwW8APwNiLDJu8oe8w2+3cYCMEDpkwdNfrMtplluewRFLUoRpXqceShfw4yYBit/KlPPssHJ6e9Da12ptACBvl9XTg+umeM/30OLe1C0EWZr9pDTJExA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717442789; c=relaxed/simple; bh=d0aIKj9hD9AEClfSD2ht6q5cfgkUkDFP5cQwyrie3II=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=btpQtYkVFIzhpqSzkmC/rAAbZStp8/yLM+2sph7ix315M4rgJQ5mXh0heijRMv9D9q9Hs56i1qdhVR3BmpFW4cdfJyp4CaZ7sMMroYKaFwn7orBIyIBLiesbGKgk1+cF+RO3vf2p2Fc/LWpL0BkhlQzKpKaoFU36EjpDJJ+RKcg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=jubnut.com; spf=pass smtp.mailfrom=jubnut.com; dkim=pass (2048-bit key) header.d=jubnut.com header.i=@jubnut.com header.b=V3qgGZXR; arc=none smtp.client-ip=80.241.56.161 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=jubnut.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=jubnut.com Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4VtNxq0SV9z9sQb; Mon, 3 Jun 2024 21:26:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jubnut.com; s=MBO0001; t=1717442783; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=x5XGR3aSMREVjpnJPLS8gCmXguO6yjczNgEYlWmCxUU=; b=V3qgGZXR4DEpLmYZq1YGI/CFTPLNLZZZYJXrwhRn8IU/BTLoBnGQ41D8L6rQtDX6hZDm73 mLISi21yq0bib2XurB7v+2acJJLDzIXgRWatCuPmB9Ukz/6WUZz6uvKdlqJbfMq9nkVpz2 fAdFH+QmFrB6gWxtJpO8/AwiWJRqnd7MTSgzS0aZLe0A8bm3VlR0mjaPUj+KTPXho8ptv0 jn0pxU3dTFfPPUctlYjKs1tT9DvKyMrX7OXr6gOZUclHFG1nW6eheXHrohIcSA1pOjWMgp A6GCcAiK9kQ/eDUYKfUIbF4qDylMGNH7t894kCQxmdRDwJpO9t2uiQe6Dnix4A== From: Ben Walsh To: Tzung-Bi Shih Cc: Benson Leung , Guenter Roeck , "Dustin L. Howett" , Kieran Levin , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Mario Limonciello , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/5] platform/chrome: cros_ec_lpc: MEC access can return error code In-Reply-To: References: <20240603063834.5580-1-ben@jubnut.com> <20240603063834.5580-2-ben@jubnut.com> Date: Mon, 03 Jun 2024 20:26:19 +0100 Message-ID: <87le3l25gk.fsf@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 Tzung-Bi Shih writes: > On Mon, Jun 03, 2024 at 07:38:30AM +0100, Ben Walsh wrote: >> @@ -425,8 +469,8 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) >> */ >> cros_ec_lpc_ops.read = cros_ec_lpc_mec_read_bytes; >> cros_ec_lpc_ops.write = cros_ec_lpc_mec_write_bytes; >> - cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID, 2, buf); >> - if (buf[0] != 'E' || buf[1] != 'C') { >> + ret = cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID, 2, buf); >> + if (ret < 0 || buf[0] != 'E' || buf[1] != 'C') { > > Slight concern: if the read failed (-EBUSY, because of the lock contention > failed for example), does it still need to probe for non-MEC devices? That's a very good point! Negative ret here means there's really an error, not just "no MEC". I think it's better to return early with the return code (not -ENODEV) in these cases. >> @@ -436,9 +480,9 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) >> /* Re-assign read/write operations for the non MEC variant */ >> cros_ec_lpc_ops.read = cros_ec_lpc_read_bytes; >> cros_ec_lpc_ops.write = cros_ec_lpc_write_bytes; >> - cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + EC_MEMMAP_ID, 2, >> - buf); >> - if (buf[0] != 'E' || buf[1] != 'C') { >> + ret = cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + EC_MEMMAP_ID, 2, >> + buf); >> + if (ret < 0 || buf[0] != 'E' || buf[1] != 'C') { >> dev_err(dev, "EC ID not detected\n"); >> return -ENODEV; > > Similar concern here: should `ret < 0` see as a -ENODEV? As above, I think it should "return ret".