Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2414851imn; Tue, 2 Aug 2022 01:45:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t/KzOLXvMENqNRrnGVXmZpAs3VOJS1PuBA6cf2J3jnrN4fBj5k82T0jzpheZ8YyiqUmHpN X-Received: by 2002:a17:906:dc8d:b0:72f:2993:ed84 with SMTP id cs13-20020a170906dc8d00b0072f2993ed84mr15371160ejc.251.1659429915722; Tue, 02 Aug 2022 01:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659429915; cv=none; d=google.com; s=arc-20160816; b=ZZz/bBPEKG4f5lixoajIP+yPEdr2tgMqYFx1vk8RiCQD0C2DAIdcEgR39gnzgWHwW6 AH1tfbU1Tto0Zz6Z8ONPf6moLd6zIdUhdBCTWgeo29c18/lFREGvMBC50F71xyp4K0A0 4AqRTyF6UkRK6wTWT0tib5jzq8oktIDVvexVIBp5ANpiint12NoQF0lvc1AJ5uwDtGG8 plYlcwSf2LyKrYiJtF6mkcajWc7nqndUkcdkgi+oX/8anG9dWoATfBjTTm9oK9b5jkgC AKRabj5u2eeS0z8xor4sgVme6OoC2m98NVxrQrjAKSKW6La7gjswt8Kl165OZFXobOoT rF1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5FiUzXTnU2kIOVPxrw4DH1356JgVNWCblI0v4aTszFo=; b=KrzZuYfe0sTO+uyyZJiGzn/HX2MbqvJA8VnooUcHqlBDqwyHnYyS9yJMGMlshHjiPX KQq39I7blUJ6kkpKi+e8x1XtqccwuFvXjTFYYckFELym/BJW2B7dWXPIR0xELkK7Jdq+ SyPl/Rve4t7ymulPETepTcnpvrYx74TewVqTggBdUAK+7JXoC5cLXK2rwPW8tZKV4zP0 yc4fY/8SwFWtdX1y6XI+ReEtLXZO6jKRXCkDYEj0RRduhBMJBbM8xArJ5fuVfvSu7nRa diPVgbirzkbu49exyXeUL/tq4ft363edv47aDjvW2ZW9C4QhAtqrgNaQgOEuIX70V/W9 r4Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XjNNHQ4F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a056402510700b0043d82d2a5e9si6672465edd.29.2022.08.02.01.44.50; Tue, 02 Aug 2022 01:45:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XjNNHQ4F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236058AbiHBIci (ORCPT + 99 others); Tue, 2 Aug 2022 04:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232482AbiHBIcg (ORCPT ); Tue, 2 Aug 2022 04:32:36 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CEEE1EC; Tue, 2 Aug 2022 01:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659429155; x=1690965155; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=m4ANagiP0pBWnABd6SaYZfcztDCXLk8K/eo+vzXaOEU=; b=XjNNHQ4FTw0bMy5XnTMKBUhqmtc9RvabPrkZaJMMXlv3xio5e1OFTVnk +cZdWsP+s0i/utOjKoCCAEq28KaYgqTb1ZBtHN4mSrSZMyOFljpWDX+nC v2orYgrqAYN1OyKvFndPWjmZ72XkADHvgZqWV+w2D0EIood3PE8ELpGvI 0ctSV7Ew3hy8X9t0KEsxnHfU35VgZZgssJd2qKPR6No5CuZ+14pfx6nk+ KadoBH/u8QDj2jWPMNpBs1w119jmbWDdg+gPbQnnDJ74/B5snYREqLMCz jduZVi1WVgftAoNakIsjlffa5tsOSokHpKfJgzP2zNf93sClGqonQZOdJ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10426"; a="288113370" X-IronPort-AV: E=Sophos;i="5.93,210,1654585200"; d="scan'208";a="288113370" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2022 01:32:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,210,1654585200"; d="scan'208";a="744590675" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 02 Aug 2022 01:32:30 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 02 Aug 2022 11:32:30 +0300 Date: Tue, 2 Aug 2022 11:32:30 +0300 From: Heikki Krogerus To: Gene Chen Cc: linux@roeck-us.net, gregkh@linuxfoundation.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, gene_chen@richtek.com, cy_huang@richtek.com Subject: Re: [PATCH v3 6/7] usb: typec: tcpci: Move function "tcpci_to_typec_cc" to common Message-ID: References: <20220801101447.86207-1-gene.chen.richtek@gmail.com> <20220801101447.86207-7-gene.chen.richtek@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220801101447.86207-7-gene.chen.richtek@gmail.com> X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham 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, Aug 01, 2022 at 06:14:46PM +0800, Gene Chen wrote: > From: Gene Chen > > Move transition function "tcpci_to_typec_cc" to common header > > Signed-off-by: Gene Chen Acked-by: Heikki Krogerus > --- > drivers/usb/typec/tcpm/tcpci.c | 22 ---------------------- > drivers/usb/typec/tcpm/tcpci.h | 23 +++++++++++++++++++++++ > 2 files changed, 23 insertions(+), 22 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c > index f33e08eb7670..0f45d456df32 100644 > --- a/drivers/usb/typec/tcpm/tcpci.c > +++ b/drivers/usb/typec/tcpm/tcpci.c > @@ -28,11 +28,6 @@ > #define VPPS_VALID_MIN_MV 100 > #define VSINKDISCONNECT_PD_MIN_PERCENT 90 > > -#define tcpc_presenting_rd(reg, cc) \ > - (!(TCPC_ROLE_CTRL_DRP & (reg)) && \ > - (((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; > > @@ -219,23 +214,6 @@ static int tcpci_start_toggling(struct tcpc_dev *tcpc, > TCPC_CMD_LOOK4CONNECTION); > } > > -static enum typec_cc_status tcpci_to_typec_cc(unsigned int cc, bool sink) > -{ > - switch (cc) { > - case 0x1: > - return sink ? TYPEC_CC_RP_DEF : TYPEC_CC_RA; > - case 0x2: > - return sink ? TYPEC_CC_RP_1_5 : TYPEC_CC_RD; > - case 0x3: > - if (sink) > - return TYPEC_CC_RP_3_0; > - fallthrough; > - case 0x0: > - default: > - return TYPEC_CC_OPEN; > - } > -} > - > static int tcpci_get_cc(struct tcpc_dev *tcpc, > enum typec_cc_status *cc1, enum typec_cc_status *cc2) > { > diff --git a/drivers/usb/typec/tcpm/tcpci.h b/drivers/usb/typec/tcpm/tcpci.h > index b2edd45f13c6..3f45cb0426df 100644 > --- a/drivers/usb/typec/tcpm/tcpci.h > +++ b/drivers/usb/typec/tcpm/tcpci.h > @@ -166,6 +166,11 @@ > /* I2C_WRITE_BYTE_COUNT + 1 when TX_BUF_BYTE_x is only accessible I2C_WRITE_BYTE_COUNT */ > #define TCPC_TRANSMIT_BUFFER_MAX_LEN 31 > > +#define tcpc_presenting_rd(reg, cc) \ > + (!(TCPC_ROLE_CTRL_DRP & (reg)) && \ > + (((reg) & (TCPC_ROLE_CTRL_## cc ##_MASK << TCPC_ROLE_CTRL_## cc ##_SHIFT)) == \ > + (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_## cc ##_SHIFT))) > + > struct tcpci; > > /* > @@ -206,4 +211,22 @@ irqreturn_t tcpci_irq(struct tcpci *tcpci); > > struct tcpm_port; > struct tcpm_port *tcpci_get_tcpm_port(struct tcpci *tcpci); > + > +static inline enum typec_cc_status tcpci_to_typec_cc(unsigned int cc, bool sink) > +{ > + switch (cc) { > + case 0x1: > + return sink ? TYPEC_CC_RP_DEF : TYPEC_CC_RA; > + case 0x2: > + return sink ? TYPEC_CC_RP_1_5 : TYPEC_CC_RD; > + case 0x3: > + if (sink) > + return TYPEC_CC_RP_3_0; > + fallthrough; > + case 0x0: > + default: > + return TYPEC_CC_OPEN; > + } > +} > + > #endif /* __LINUX_USB_TCPCI_H */ > -- > 2.25.1 -- heikki