Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp568478iof; Mon, 6 Jun 2022 08:39:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRKm50c6BzSwRSuVZIr9Cw9GReEvY7MUlDbOwpNM4yN32CtdMx36gZGC2pcps9hXvIQXpO X-Received: by 2002:a17:90b:4a90:b0:1e8:626c:e1b2 with SMTP id lp16-20020a17090b4a9000b001e8626ce1b2mr11767995pjb.141.1654529950199; Mon, 06 Jun 2022 08:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654529950; cv=none; d=google.com; s=arc-20160816; b=R0E9dweDjcs+LikcmdgaP19bROYnQd1ZODV/iEICj463JEOw6gPUmxzsmMTDK8/kHF 55lUSHMXg2GozBjvFLHIn9jCVyCtl4Kix4xvzSMQ+zSDv350To4I6KFnNwDMOs67+HNh pQSe6Qcjhy9Wn2s2pzvbvdxxeyo3V4O4i2jH3K9HdDd7HwpHjjqYCVPlLxN9VnKn7h2P SkkgjroCq7OMKM923tYNfGya4X5Q2JQ218GkqiWMZ0YMt1ctVFAKRZO395RL1lLLqNk0 F9evSuF5v5MRtyWY/gojcBpWfpWMC7l9PGF/WCkKVKMxn1iaVqs1PcL75uK/nK6U8i1z guWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=WFkJN+2bHJOP68QD60aR59WFi/5Szzxwdh/dFApGdr8=; b=MpD3yco3RnfAd8rh1wWe/JMEUEa/5s5mHZiDERngH8Po2YFa8YE9TkzdkHW/E/+Wu/ lqH4htwOdLJ4/nEmJaI7kcxqRCPwSYnGdxlG3y/Q6UpZaNJ4H1SzMSMs6q9BupNnX8Uv ph7hDpQL8Oes1XsNELkSaIGAjy6q3BU9NNTj0F8inmJBqvJ+wR8gjwe9u3XzBNT0g9ue q669EdLdPRPQT1SsXSKVWyyBxjK/LftNdWBUuM/ANcnDgGmy76SrVFbmGxTwcNgDDKND lQDJ7f8s+uG239kVQJQ1uT24p/gqiAldS+XKxM++APZJTgPZp6rkZMqc2lzC3u5UHu+s 6TEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=IPH2UD0S; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k11-20020a056a00168b00b0051b4937f176si23538412pfc.50.2022.06.06.08.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 08:39:10 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=IPH2UD0S; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E7AB252C3D; Mon, 6 Jun 2022 08:23:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240483AbiFFPXZ (ORCPT + 99 others); Mon, 6 Jun 2022 11:23:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240471AbiFFPXU (ORCPT ); Mon, 6 Jun 2022 11:23:20 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 031DB244086 for ; Mon, 6 Jun 2022 08:23:18 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id bg6so9801066ejb.0 for ; Mon, 06 Jun 2022 08:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WFkJN+2bHJOP68QD60aR59WFi/5Szzxwdh/dFApGdr8=; b=IPH2UD0SP8Q8CjHE+h82cSwkBHs6m24a3xylxfsbOKNofKjX8znm58IbF3hRthAoTy ySX4xi911UXUdg36EbMXQptA+SU7EC/vTUU5NjviPyc4T9t5K/z0tFq6dEivrWme6Otz zMZbwpVsgP1t9UgP6bMKz/+JMFOyRxMhKdun4eoS/QGcmhKXh8mMhj0gwT7g1u/BWYen zkWaoROt3wJiuI6X3tjDHKdlNO6V/ygTm3jcQjDjbDBFmPD/m9+rh8TTuh5K1J8shiJD 9+7jYRKqnszygMfPiRUwo/BZXOvaMQ657StTHE+vz+NnaQInQnxInNQ+0gRi7b++Cq9w fXZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WFkJN+2bHJOP68QD60aR59WFi/5Szzxwdh/dFApGdr8=; b=GG+QbwSCpjE9uAGaOSWD7CokkUI1gdRziPHFHmsLPVls+uB291QHKXaf4WPyZlEx4F 6e87l2ig9V+QGsrnKcKC3VOqfisiz/NBOmWWMjur9g3mBnc+Lkfn1HgUJqBNqDjmsCuU kQ177z/1zt3f4zdYer/hA3n/CMh+ynXa3rMT/6bLfgYqLaLFZg2034ScuenrSGWcMqcL wuI7MdXTZxrxXH0PjAu9H7wNpQqNUhJgIegJsnyuVhfwkWOqPn2gFB1Nu8Tr/7fTDmoY GxQEfmRdFZaQ9pflIb9TAflnlcGtmVYlYsEx0xIo7gA0MGiZyiaRrlG0Y/teHys3MyMF 90yQ== X-Gm-Message-State: AOAM530r1Yw0cjNpmJGkYyBtfPL7NQnEcksbt5VGp2++fNvjVMrOV1hk EIs8lSM1cipyPcygKQJjfCA17h8noNkNub4MdTW5zg== X-Received: by 2002:a17:907:6ea4:b0:711:d106:b93a with SMTP id sh36-20020a1709076ea400b00711d106b93amr4576736ejc.189.1654528997217; Mon, 06 Jun 2022 08:23:17 -0700 (PDT) MIME-Version: 1.0 References: <20220606141051.285823-1-tzungbi@kernel.org> <20220606141051.285823-4-tzungbi@kernel.org> In-Reply-To: From: Guenter Roeck Date: Mon, 6 Jun 2022 08:23:06 -0700 Message-ID: Subject: Re: [PATCH 03/13] platform/chrome: use macros for passthru indexes To: Tzung-Bi Shih Cc: Benson Leung , Guenter Roeck , chrome-platform@lists.linux.dev, linux-kernel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 6, 2022 at 8:22 AM Guenter Roeck wrote: > > On Mon, Jun 6, 2022 at 7:12 AM Tzung-Bi Shih wrote: > > > > Move passthru indexes for EC and PD devices to common header. Also use > > them instead of literal constants. > > > > Signed-off-by: Tzung-Bi Shih > > Reviewed-by: Guenter Roeck > Too much auto-typing. Trying again: Reviewed-by: Guenter Roeck > > --- > > drivers/platform/chrome/cros_ec.c | 3 --- > > drivers/platform/chrome/cros_ec_proto.c | 6 +++--- > > drivers/platform/chrome/cros_ec_proto_test.c | 18 ++++++++++++------ > > drivers/platform/chrome/cros_ec_trace.h | 8 ++++---- > > include/linux/platform_data/cros_ec_proto.h | 3 +++ > > 5 files changed, 22 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c > > index b3e94cdf7d1a..e51a3f2176c7 100644 > > --- a/drivers/platform/chrome/cros_ec.c > > +++ b/drivers/platform/chrome/cros_ec.c > > @@ -19,9 +19,6 @@ > > > > #include "cros_ec.h" > > > > -#define CROS_EC_DEV_EC_INDEX 0 > > -#define CROS_EC_DEV_PD_INDEX 1 > > - > > static struct cros_ec_platform ec_p = { > > .ec_name = CROS_EC_DEV_NAME, > > .cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_EC_INDEX), > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c > > index 13ced9d2dd71..65191af5139c 100644 > > --- a/drivers/platform/chrome/cros_ec_proto.c > > +++ b/drivers/platform/chrome/cros_ec_proto.c > > @@ -433,7 +433,7 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev) > > > > /* First try sending with proto v3. */ > > ec_dev->proto_version = 3; > > - ret = cros_ec_host_command_proto_query(ec_dev, 0, proto_msg); > > + ret = cros_ec_host_command_proto_query(ec_dev, CROS_EC_DEV_EC_INDEX, proto_msg); > > > > if (ret == 0) { > > proto_info = (struct ec_response_get_protocol_info *) > > @@ -459,7 +459,7 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev) > > /* > > * Check for PD > > */ > > - ret = cros_ec_host_command_proto_query(ec_dev, 1, proto_msg); > > + ret = cros_ec_host_command_proto_query(ec_dev, CROS_EC_DEV_PD_INDEX, proto_msg); > > > > if (ret) { > > dev_dbg(ec_dev->dev, "no PD chip found: %d\n", ret); > > @@ -609,7 +609,7 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) > > msg->insize = ec_dev->max_response; > > } > > > > - if (msg->command < EC_CMD_PASSTHRU_OFFSET(1)) { > > + if (msg->command < EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX)) { > > if (msg->outsize > ec_dev->max_request) { > > dev_err(ec_dev->dev, > > "request of size %u is too big (max: %u)\n", > > diff --git a/drivers/platform/chrome/cros_ec_proto_test.c b/drivers/platform/chrome/cros_ec_proto_test.c > > index c5e16566a634..5169bf33360b 100644 > > --- a/drivers/platform/chrome/cros_ec_proto_test.c > > +++ b/drivers/platform/chrome/cros_ec_proto_test.c > > @@ -280,7 +280,8 @@ static void cros_ec_proto_test_query_all_normal(struct kunit *test) > > > > KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > > KUNIT_EXPECT_EQ(test, mock->msg.command, > > - EC_CMD_PASSTHRU_OFFSET(1) | EC_CMD_GET_PROTOCOL_INFO); > > + EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) | > > + EC_CMD_GET_PROTOCOL_INFO); > > KUNIT_EXPECT_EQ(test, mock->msg.insize, > > sizeof(struct ec_response_get_protocol_info)); > > KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); > > @@ -393,7 +394,8 @@ static void cros_ec_proto_test_query_all_no_pd(struct kunit *test) > > > > KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > > KUNIT_EXPECT_EQ(test, mock->msg.command, > > - EC_CMD_PASSTHRU_OFFSET(1) | EC_CMD_GET_PROTOCOL_INFO); > > + EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) | > > + EC_CMD_GET_PROTOCOL_INFO); > > KUNIT_EXPECT_EQ(test, mock->msg.insize, > > sizeof(struct ec_response_get_protocol_info)); > > KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); > > @@ -535,7 +537,8 @@ static void cros_ec_proto_test_query_all_no_mkbp(struct kunit *test) > > > > KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > > KUNIT_EXPECT_EQ(test, mock->msg.command, > > - EC_CMD_PASSTHRU_OFFSET(1) | EC_CMD_GET_PROTOCOL_INFO); > > + EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) | > > + EC_CMD_GET_PROTOCOL_INFO); > > KUNIT_EXPECT_EQ(test, mock->msg.insize, > > sizeof(struct ec_response_get_protocol_info)); > > KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); > > @@ -623,7 +626,8 @@ static void cros_ec_proto_test_query_all_no_mkbp2(struct kunit *test) > > > > KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > > KUNIT_EXPECT_EQ(test, mock->msg.command, > > - EC_CMD_PASSTHRU_OFFSET(1) | EC_CMD_GET_PROTOCOL_INFO); > > + EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) | > > + EC_CMD_GET_PROTOCOL_INFO); > > KUNIT_EXPECT_EQ(test, mock->msg.insize, > > sizeof(struct ec_response_get_protocol_info)); > > KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); > > @@ -723,7 +727,8 @@ static void cros_ec_proto_test_query_all_no_host_sleep(struct kunit *test) > > > > KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > > KUNIT_EXPECT_EQ(test, mock->msg.command, > > - EC_CMD_PASSTHRU_OFFSET(1) | EC_CMD_GET_PROTOCOL_INFO); > > + EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) | > > + EC_CMD_GET_PROTOCOL_INFO); > > KUNIT_EXPECT_EQ(test, mock->msg.insize, > > sizeof(struct ec_response_get_protocol_info)); > > KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); > > @@ -833,7 +838,8 @@ static void cros_ec_proto_test_query_all_default_wake_mask(struct kunit *test) > > > > KUNIT_EXPECT_EQ(test, mock->msg.version, 0); > > KUNIT_EXPECT_EQ(test, mock->msg.command, > > - EC_CMD_PASSTHRU_OFFSET(1) | EC_CMD_GET_PROTOCOL_INFO); > > + EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) | > > + EC_CMD_GET_PROTOCOL_INFO); > > KUNIT_EXPECT_EQ(test, mock->msg.insize, > > sizeof(struct ec_response_get_protocol_info)); > > KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0); > > diff --git a/drivers/platform/chrome/cros_ec_trace.h b/drivers/platform/chrome/cros_ec_trace.h > > index 9bb5cd2c98b8..d7e407de88df 100644 > > --- a/drivers/platform/chrome/cros_ec_trace.h > > +++ b/drivers/platform/chrome/cros_ec_trace.h > > @@ -30,8 +30,8 @@ TRACE_EVENT(cros_ec_request_start, > > ), > > TP_fast_assign( > > __entry->version = cmd->version; > > - __entry->offset = cmd->command / EC_CMD_PASSTHRU_OFFSET(1); > > - __entry->command = cmd->command % EC_CMD_PASSTHRU_OFFSET(1); > > + __entry->offset = cmd->command / EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX); > > + __entry->command = cmd->command % EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX); > > __entry->outsize = cmd->outsize; > > __entry->insize = cmd->insize; > > ), > > @@ -55,8 +55,8 @@ TRACE_EVENT(cros_ec_request_done, > > ), > > TP_fast_assign( > > __entry->version = cmd->version; > > - __entry->offset = cmd->command / EC_CMD_PASSTHRU_OFFSET(1); > > - __entry->command = cmd->command % EC_CMD_PASSTHRU_OFFSET(1); > > + __entry->offset = cmd->command / EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX); > > + __entry->command = cmd->command % EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX); > > __entry->outsize = cmd->outsize; > > __entry->insize = cmd->insize; > > __entry->result = cmd->result; > > diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h > > index 138fd912c808..6475a8066f00 100644 > > --- a/include/linux/platform_data/cros_ec_proto.h > > +++ b/include/linux/platform_data/cros_ec_proto.h > > @@ -21,6 +21,9 @@ > > #define CROS_EC_DEV_SCP_NAME "cros_scp" > > #define CROS_EC_DEV_TP_NAME "cros_tp" > > > > +#define CROS_EC_DEV_EC_INDEX 0 > > +#define CROS_EC_DEV_PD_INDEX 1 > > + > > /* > > * The EC is unresponsive for a time after a reboot command. Add a > > * simple delay to make sure that the bus stays locked. > > -- > > 2.36.1.255.ge46751e96f-goog > >