From patchwork Thu Mar 7 16:36:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10843353 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77537139A for ; Thu, 7 Mar 2019 16:36:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 655EC2F528 for ; Thu, 7 Mar 2019 16:36:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5978F2F579; Thu, 7 Mar 2019 16:36:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F06FC2F528 for ; Thu, 7 Mar 2019 16:36:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726380AbfCGQgS (ORCPT ); Thu, 7 Mar 2019 11:36:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55038 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726346AbfCGQgS (ORCPT ); Thu, 7 Mar 2019 11:36:18 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 926B5309E972; Thu, 7 Mar 2019 16:36:17 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4C5960856; Thu, 7 Mar 2019 16:36:14 +0000 (UTC) From: Hans de Goede To: Greg Kroah-Hartman , Guenter Roeck , Heikki Krogerus Cc: Hans de Goede , linux-usb@vger.kernel.org Subject: [PATCH v2 3/8] usb: typec: fusb302: Fold fusb302_set_cc_pull into tcpm_set_cc Date: Thu, 7 Mar 2019 17:36:02 +0100 Message-Id: <20190307163607.24016-4-hdegoede@redhat.com> In-Reply-To: <20190307163607.24016-1-hdegoede@redhat.com> References: <20190307163607.24016-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 07 Mar 2019 16:36:17 +0000 (UTC) Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After the recent cleanups, tcpm_set_cc is the only caller of fusb302_set_cc_pull, fold fusb302_set_cc_pull directly into tcpm_set_cc for a nice cleanup. Signed-off-by: Hans de Goede Reviewed-by: Guenter Roeck --- drivers/usb/typec/tcpm/fusb302.c | 51 ++++++++------------------------ 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c index bcb38e397712..cb6637e82f32 100644 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -518,31 +518,6 @@ static int tcpm_get_current_limit(struct tcpc_dev *dev) return current_limit; } -static int fusb302_set_cc_pull(struct fusb302_chip *chip, - bool pull_up, bool pull_down) -{ - int ret = 0; - u8 data = 0x00; - u8 mask = FUSB_REG_SWITCHES0_CC1_PU_EN | - FUSB_REG_SWITCHES0_CC2_PU_EN | - FUSB_REG_SWITCHES0_CC1_PD_EN | - FUSB_REG_SWITCHES0_CC2_PD_EN; - - if (pull_up) - data |= (chip->cc_polarity == TYPEC_POLARITY_CC1) ? - FUSB_REG_SWITCHES0_CC1_PU_EN : - FUSB_REG_SWITCHES0_CC2_PU_EN; - if (pull_down) - data |= FUSB_REG_SWITCHES0_CC1_PD_EN | - FUSB_REG_SWITCHES0_CC2_PD_EN; - ret = fusb302_i2c_mask_write(chip, FUSB_REG_SWITCHES0, - mask, data); - if (ret < 0) - return ret; - - return ret; -} - static int fusb302_set_src_current(struct fusb302_chip *chip, enum src_current_status status) { @@ -674,27 +649,30 @@ static int tcpm_set_cc(struct tcpc_dev *dev, enum typec_cc_status cc) { struct fusb302_chip *chip = container_of(dev, struct fusb302_chip, tcpc_dev); + u8 switches0_mask = FUSB_REG_SWITCHES0_CC1_PU_EN | + FUSB_REG_SWITCHES0_CC2_PU_EN | + FUSB_REG_SWITCHES0_CC1_PD_EN | + FUSB_REG_SWITCHES0_CC2_PD_EN; + u8 switches0_data = 0x00; int ret = 0; - bool pull_up, pull_down; enum toggling_mode mode; mutex_lock(&chip->lock); switch (cc) { case TYPEC_CC_OPEN: - pull_up = false; - pull_down = false; mode = TOGGLING_MODE_OFF; break; case TYPEC_CC_RD: - pull_up = false; - pull_down = true; + switches0_data |= FUSB_REG_SWITCHES0_CC1_PD_EN | + FUSB_REG_SWITCHES0_CC2_PD_EN; mode = TOGGLING_MODE_SNK; break; case TYPEC_CC_RP_DEF: case TYPEC_CC_RP_1_5: case TYPEC_CC_RP_3_0: - pull_up = true; - pull_down = false; + switches0_data |= (chip->cc_polarity == TYPEC_POLARITY_CC1) ? + FUSB_REG_SWITCHES0_CC1_PU_EN : + FUSB_REG_SWITCHES0_CC2_PU_EN; mode = TOGGLING_MODE_SRC; break; default: @@ -706,13 +684,10 @@ static int tcpm_set_cc(struct tcpc_dev *dev, enum typec_cc_status cc) fusb302_log(chip, "cc := %s", typec_cc_status_name[cc]); - ret = fusb302_set_cc_pull(chip, pull_up, pull_down); + ret = fusb302_i2c_mask_write(chip, FUSB_REG_SWITCHES0, + switches0_mask, switches0_data); if (ret < 0) { - fusb302_log(chip, - "cannot set cc pulling up %s, down %s, ret = %d", - pull_up ? "True" : "False", - pull_down ? "True" : "False", - ret); + fusb302_log(chip, "cannot set pull-up/-down, ret = %d", ret); goto done; } /* reset the cc status */