From patchwork Wed Apr 3 08:45:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 15840 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3D09623E21 for ; Wed, 3 Apr 2013 08:47:34 +0000 (UTC) Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by fiordland.canonical.com (Postfix) with ESMTP id 60DF9A184B9 for ; Wed, 3 Apr 2013 08:47:33 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id b4sf2176111qen.0 for ; Wed, 03 Apr 2013 01:47:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=5iSzzflT5ptCwK9Fw9rHrYSjz3xxhvLqBmyMvXvnj2o=; b=Oe+ngpmSiMpc2doOWLKXak8+c0ctQR2IneXAcOk6ek3GxvsJ+bU2/1taH90U2/4F1o EMbUKCjKDAQ3epBiCbQeJlNTCVsEz8JPQo29GW+mBvlSAi/h0n5bhYQMAb1cR79b0o54 zjWNEVuYShGWgp5tTniJc0GFS06vpmX2w6RXyS/Z41n5dYTXwbcvcTI1b2OebjdLQZ1s 08rCCZtbsD4Yx9cl9oGgliMw0JnR+cqHVQkP8yyODT4drVCEDpo6IoE5r9A2vd//GjHD JFbUoqyj1xhstwcEsIlpdmJM3fi1k84S0G1Db65je2FDTyn6CXPDbTShgU45yh2e9IFc 5Qag== X-Received: by 10.224.157.1 with SMTP id z1mr695848qaw.8.1364978852917; Wed, 03 Apr 2013 01:47:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.127.111 with SMTP id nf15ls855106qeb.25.gmail; Wed, 03 Apr 2013 01:47:32 -0700 (PDT) X-Received: by 10.52.245.6 with SMTP id xk6mr398901vdc.114.1364978852826; Wed, 03 Apr 2013 01:47:32 -0700 (PDT) Received: from mail-vb0-x22a.google.com (mail-vb0-x22a.google.com [2607:f8b0:400c:c02::22a]) by mx.google.com with ESMTPS id a1si4282403vef.2.2013.04.03.01.47.32 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Apr 2013 01:47:32 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22a is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::22a; Received: by mail-vb0-f42.google.com with SMTP id p12so264298vbe.1 for ; Wed, 03 Apr 2013 01:47:32 -0700 (PDT) X-Received: by 10.220.153.143 with SMTP id k15mr511918vcw.33.1364978852652; Wed, 03 Apr 2013 01:47:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp160636ved; Wed, 3 Apr 2013 01:47:31 -0700 (PDT) X-Received: by 10.14.207.200 with SMTP id n48mr1964261eeo.4.1364978851501; Wed, 03 Apr 2013 01:47:31 -0700 (PDT) Received: from mail-ea0-x230.google.com (mail-ea0-x230.google.com [2a00:1450:4013:c01::230]) by mx.google.com with ESMTPS id g8si7534157eem.235.2013.04.03.01.47.31 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Apr 2013 01:47:31 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:4013:c01::230 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=2a00:1450:4013:c01::230; Received: by mail-ea0-f176.google.com with SMTP id h10so567907eaj.35 for ; Wed, 03 Apr 2013 01:47:31 -0700 (PDT) X-Received: by 10.15.111.202 with SMTP id cj50mr1932420eeb.6.1364978851014; Wed, 03 Apr 2013 01:47:31 -0700 (PDT) Received: from localhost ([2a01:2003:1:1e91:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPS id s3sm6909385eem.4.2013.04.03.01.47.24 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 03 Apr 2013 01:47:30 -0700 (PDT) From: Fabio Baltieri To: Felipe Balbi Cc: Linus Walleij , Praveena Nadahally , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Fabio Baltieri Subject: [PATCH 06/12] usb: phy: ab8500-usb: split ab8500_usb_phy_ctrl Date: Wed, 3 Apr 2013 10:45:07 +0200 Message-Id: <1364978713-19612-7-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1364978713-19612-1-git-send-email-fabio.baltieri@linaro.org> References: <1364978713-19612-1-git-send-email-fabio.baltieri@linaro.org> X-Gm-Message-State: ALoCoQkPuPTOvCg/HnpzrTMCl15RBetfT5mDhcLNiRjwsVOW7NKXVeOmlW7QVceDpkDyTef8LqOC X-Original-Sender: fabio.baltieri@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22a is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Split ab8500_usb_phy_ctrl into separate enable/disable functions to make the code more linear and readable. Acked-by: Linus Walleij Signed-off-by: Fabio Baltieri --- drivers/usb/phy/phy-ab8500-usb.c | 55 +++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c index 4caa820..1c6eec9 100644 --- a/drivers/usb/phy/phy-ab8500-usb.c +++ b/drivers/usb/phy/phy-ab8500-usb.c @@ -172,40 +172,37 @@ static void ab8500_usb_wd_linkstatus(struct ab8500_usb *ab, u8 bit) } } -static void ab8500_usb_phy_ctrl(struct ab8500_usb *ab, bool sel_host, - bool enable) +static void ab8500_usb_phy_enable(struct ab8500_usb *ab, bool sel_host) { - u8 ctrl_reg; - abx500_get_register_interruptible(ab->dev, - AB8500_USB, - AB8500_USB_PHY_CTRL_REG, - &ctrl_reg); - if (sel_host) { - if (enable) - ctrl_reg |= AB8500_BIT_PHY_CTRL_HOST_EN; - else - ctrl_reg &= ~AB8500_BIT_PHY_CTRL_HOST_EN; - } else { - if (enable) - ctrl_reg |= AB8500_BIT_PHY_CTRL_DEVICE_EN; - else - ctrl_reg &= ~AB8500_BIT_PHY_CTRL_DEVICE_EN; - } + u8 bit; + bit = sel_host ? AB8500_BIT_PHY_CTRL_HOST_EN : + AB8500_BIT_PHY_CTRL_DEVICE_EN; - abx500_set_register_interruptible(ab->dev, - AB8500_USB, - AB8500_USB_PHY_CTRL_REG, - ctrl_reg); + abx500_mask_and_set_register_interruptible(ab->dev, + AB8500_USB, AB8500_USB_PHY_CTRL_REG, + bit, bit); +} - /* Needed to enable the phy.*/ - if (enable) - ab8500_usb_wd_workaround(ab); +static void ab8500_usb_phy_disable(struct ab8500_usb *ab, bool sel_host) +{ + u8 bit; + bit = sel_host ? AB8500_BIT_PHY_CTRL_HOST_EN : + AB8500_BIT_PHY_CTRL_DEVICE_EN; + + ab8500_usb_wd_linkstatus(ab, bit); + + abx500_mask_and_set_register_interruptible(ab->dev, + AB8500_USB, AB8500_USB_PHY_CTRL_REG, + bit, 0); + + /* Needed to disable the phy.*/ + ab8500_usb_wd_workaround(ab); } -#define ab8500_usb_host_phy_en(ab) ab8500_usb_phy_ctrl(ab, true, true) -#define ab8500_usb_host_phy_dis(ab) ab8500_usb_phy_ctrl(ab, true, false) -#define ab8500_usb_peri_phy_en(ab) ab8500_usb_phy_ctrl(ab, false, true) -#define ab8500_usb_peri_phy_dis(ab) ab8500_usb_phy_ctrl(ab, false, false) +#define ab8500_usb_host_phy_en(ab) ab8500_usb_phy_enable(ab, true) +#define ab8500_usb_host_phy_dis(ab) ab8500_usb_phy_disable(ab, true) +#define ab8500_usb_peri_phy_en(ab) ab8500_usb_phy_enable(ab, false) +#define ab8500_usb_peri_phy_dis(ab) ab8500_usb_phy_disable(ab, false) static int ab8505_usb_link_status_update(struct ab8500_usb *ab, enum ab8505_usb_link_status lsts)