Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp662207pxf; Wed, 10 Mar 2021 14:38:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRuc6X+2kru51mKc+f2EALrK3mcKJu5esX8xJ9YQJ1moZu/BpGvdKVu0gVLjXESRDKMME8 X-Received: by 2002:aa7:d54c:: with SMTP id u12mr5881817edr.234.1615415898807; Wed, 10 Mar 2021 14:38:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615415898; cv=none; d=google.com; s=arc-20160816; b=cfeL4pmQ006bWZk+L0FwyeID4NByI9CKsgG+3jvhjoghO4O1yrXV3UbDXXrmMFceIc uEdfyNK8GGUEUj57hbi6HhPQWHiDuTykqcDKzSapyNGHGR1k2tWTwQ1JMj2XoUfXix/i qlFT98//8DoRe9FX0sBN4jGSEcj6ELYipTQnC6Fn6LlOth3tN15DWw+VVZVf6bhdVSdf +zO3PkCikqh5QHMHLx3GU+VlIAfyb/pd4YMRQfkwwwY6gjkVAubvxTbgiv6fdIbEB+y1 BvAeqemfWuj+W4HOmjvu8MPv+iVoW+VtLtMqnF6Ad61NzSkmb1s0nliliNEQ//ntJq7l ibbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=jKCctkp41npEmYGaMid+GoHQ1jboW5jXBjadu8S78Eg=; b=ytOq0ly1cHz5X9NvHzHIYNMKlf5cfaUcdqg3H/NDEW0Rl2/9TdFyAWzofFSChgTEpV wZ4m5iJ4GaJlxL0kob0IwAOOdLQEX7Ul9zRD1SEuc3QHABOk8H8UBybOaAEt50Nuv28I gHXqok7i3JwaxCOC1ZQaLEr16RGMFJbTvh8o7yr0x7Ba7AJr1ckyOLddOJsB8+srCXZW Ir+1R73gs8ELdxjamkOt9CYkLVP+ZLkMgh8PpRavlxX8iBC/dm2+qgRAtZsyvtJ92pvR 8IjKSIyfO4MkzJkgw6hD0G19vwNZKggl4laMVAQRisgfGUofTzDpLrnsnSwHEcCBXiA9 VOow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LNGAhwSa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f22si454452edw.372.2021.03.10.14.37.34; Wed, 10 Mar 2021 14:38:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@google.com header.s=20161025 header.b=LNGAhwSa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232523AbhCJWf4 (ORCPT + 99 others); Wed, 10 Mar 2021 17:35:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231207AbhCJWfm (ORCPT ); Wed, 10 Mar 2021 17:35:42 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CFDDC061574 for ; Wed, 10 Mar 2021 14:35:42 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id p136so23290707ybc.21 for ; Wed, 10 Mar 2021 14:35:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=jKCctkp41npEmYGaMid+GoHQ1jboW5jXBjadu8S78Eg=; b=LNGAhwSaw+X7d35VBWAjBBhYgWQxaoIreiUusF3wljDUXwaQSD3Kdh2rOH6ugzGF1E 2N5Lfbn2T4/c+IZP00FN0s1qE/6royVKd9Qdad8D8sUgaI9xO6zjtqwK3/2Uvk132Fa6 7qBjUIRMUiTbzSAx66IAmEWwuPrQe8gAdeu8F6n1MiIU4LrqioS1vebuBPcK0fj6RS3y NUnvBa9VgJa1lEVFD3LyDBWOTRVcUh2fUyhAnfSfVEu2rMu+0iurdu/QMK83xiibq78H G26419f/Snj4St0ElyzYbG6VYnkyo6MkTLdG/mD6ZIYNqoQ/rePRQdavVqENgthCzKp+ HJXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=jKCctkp41npEmYGaMid+GoHQ1jboW5jXBjadu8S78Eg=; b=qXKUG+aVp9vjJLT1yOXm5+miBO64yHYLsQTjX87a55O6mveXfw6/LoN4gc8rwkOJz8 BBoL/RKoeYG1b8/CJcsrX4i5HVeMgw4l0uRvcaSusNmgQe4R47+5DtwwewiOe7diLhDo +sPNnx6I04k7iXOdIY+wM4IHKZyIln5svbNAbgCyVelq+LR9ZsahnF/Xd8wHkuPeQSaU 8qB0n8njyqcUi/lUL9FLY8j4uM/doC08pzf3oW18ZWFcMOmMnSIuNVp3PIoJTmJlYEpL tRwuH+9O9DH93hBZZeimSttc+Fw6sM+u0/xhuIl+WSZH+XUt8KjbHtGujeFK2jCWeJJo 6xKA== X-Gm-Message-State: AOAM530HtDnzuz3YO333aMnOSti0pQo7g20e26h7DcSrmSwGAyBU3ZYH oG56Rhyt2zhyZGaF8MbUdUuuVs3JS3Y= X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:2879:299f:c377:83c9]) (user=badhri job=sendgmr) by 2002:a25:d1ca:: with SMTP id i193mr5335984ybg.355.1615415741693; Wed, 10 Mar 2021 14:35:41 -0800 (PST) Date: Wed, 10 Mar 2021 14:35:36 -0800 Message-Id: <20210310223536.3471243-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.rc1.246.gcd05c9c855-goog Subject: [PATCH v1] usb: typec: tcpci: Refactor tcpc_presenting_cc1_rd macro From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso , stable@vger.kernel.org, Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Defining one macro instead of two for tcpc_presenting_*_rd. This is a follow up of the comment left by Heikki Krogerus. https://patchwork.kernel.org/project/linux-usb/patch/ 20210304070931.1947316-1-badhri@google.com/ Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/tcpci.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c index 027afd7dfdce..25b480752266 100644 --- a/drivers/usb/typec/tcpm/tcpci.c +++ b/drivers/usb/typec/tcpm/tcpci.c @@ -24,14 +24,10 @@ #define AUTO_DISCHARGE_PD_HEADROOM_MV 850 #define AUTO_DISCHARGE_PPS_HEADROOM_MV 1250 -#define tcpc_presenting_cc1_rd(reg) \ +#define tcpc_presenting_rd(reg, cc) \ (!(TCPC_ROLE_CTRL_DRP & (reg)) && \ - (((reg) & (TCPC_ROLE_CTRL_CC1_MASK << TCPC_ROLE_CTRL_CC1_SHIFT)) == \ - (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC1_SHIFT))) -#define tcpc_presenting_cc2_rd(reg) \ - (!(TCPC_ROLE_CTRL_DRP & (reg)) && \ - (((reg) & (TCPC_ROLE_CTRL_CC2_MASK << TCPC_ROLE_CTRL_CC2_SHIFT)) == \ - (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC2_SHIFT))) + (((reg) & (TCPC_ROLE_CTRL_## cc ##_MASK << TCPC_ROLE_CTRL_## cc ##_SHIFT)) == \ + (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_## cc ##_SHIFT))) struct tcpci { struct device *dev; @@ -201,11 +197,11 @@ static int tcpci_get_cc(struct tcpc_dev *tcpc, *cc1 = tcpci_to_typec_cc((reg >> TCPC_CC_STATUS_CC1_SHIFT) & TCPC_CC_STATUS_CC1_MASK, reg & TCPC_CC_STATUS_TERM || - tcpc_presenting_cc1_rd(role_control)); + tcpc_presenting_rd(role_control, CC1)); *cc2 = tcpci_to_typec_cc((reg >> TCPC_CC_STATUS_CC2_SHIFT) & TCPC_CC_STATUS_CC2_MASK, reg & TCPC_CC_STATUS_TERM || - tcpc_presenting_cc2_rd(role_control)); + tcpc_presenting_rd(role_control, CC2)); return 0; } -- 2.31.0.rc1.246.gcd05c9c855-goog