From patchwork Fri Apr 22 10:18:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 8908971 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 98E4BBF29F for ; Fri, 22 Apr 2016 10:22:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7B74201F2 for ; Fri, 22 Apr 2016 10:22:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A941820221 for ; Fri, 22 Apr 2016 10:22:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1atYCX-0003U3-2w; Fri, 22 Apr 2016 10:20:41 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1atYAl-0000Ab-Iw for linux-arm-kernel@lists.infradead.org; Fri, 22 Apr 2016 10:18:52 +0000 Received: by mail-wm0-x230.google.com with SMTP id e201so13255600wme.0 for ; Fri, 22 Apr 2016 03:18:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eBzsIVT4n2oVi/EYjdI7ridEK4adeomzMMFtqB+bipU=; b=SLkfFGg7XSPRL9FsvGYnQm9Zlm+KIbm4bJ2/bc1VxS2zkc0oJWYu7NtudZa/Jr37ax y0RJpwIou81adfJXtlyo1YZ4lmcsllCUl2jFfSiY1ZllziQZJAlQN3VAlDomVcMSfXjB 1sEDL5qNXMWt9MwqXMZvrYrjeyvc3VGKKnCkA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eBzsIVT4n2oVi/EYjdI7ridEK4adeomzMMFtqB+bipU=; b=Tx770ZsZ6wcq14JiINL3enYtN5wZWPOpY02Vjo2vz8xj8YwEaq4syC1ssz6amA5CoA IPQyXZV+R3VHLmivY+nTKhW0hlsRX2FaA2TrnxpCSzIYIRQv9+rsoOAwJQZLfwN7+PIo xuKYuU9mXHGZeBL9ZTTjIcosUTIoGOqSUN5LvQSCzqoNW4B+qMT2Jw29ZSW0JC5UWwGl kQhzk6zeHzphFSA1OmsZnlGnS1JrhEJ4nYt46dq3QA6B2z64jkM4kBUF/eHHuAMgXM9e +vsM4XAL31dzShemvqhWVQYkUMStRLRjVYSvThBF9szIlYrWV+0l/pDHDaXu3R+L/8cF kp5A== X-Gm-Message-State: AOPr4FX3Q9Dt36J9wEmulq8uvfHOzQCkdwbPkvcY6/LY2ae13dqxwEKhz6iJw225MrX5kTZ8 X-Received: by 10.194.122.199 with SMTP id lu7mr3249835wjb.40.1461320311634; Fri, 22 Apr 2016 03:18:31 -0700 (PDT) Received: from dell.localdomain (host81-129-172-5.range81-129.btcentralplus.com. [81.129.172.5]) by smtp.gmail.com with ESMTPSA id a1sm7316345wje.43.2016.04.22.03.18.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2016 03:18:30 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [[PATCH v2] 11/11] pwm: sti: Take the opportunity to conduct a little house keeping Date: Fri, 22 Apr 2016 11:18:15 +0100 Message-Id: <1461320295-20414-12-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1461320295-20414-1-git-send-email-lee.jones@linaro.org> References: <1461320295-20414-1-git-send-email-lee.jones@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160422_031851_779323_7CDE45C3 X-CRM114-Status: GOOD ( 15.24 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, kernel@stlinux.com, ajitpal.singh@st.com, thierry.reding@gmail.com, Lee Jones , maxime.coquelin@st.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This includes fixing some Coding Style issues and re-ordering/ simplifying a little code. Signed-off-by: Lee Jones --- drivers/pwm/pwm-sti.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c index cecb6d4..ac37973 100644 --- a/drivers/pwm/pwm-sti.c +++ b/drivers/pwm/pwm-sti.c @@ -1,8 +1,10 @@ /* - * PWM device driver for ST SoCs. - * Author: Ajit Pal Singh + * PWM device driver for ST SoCs + * + * Copyright (C) 2013-2016 STMicroelectronics (R&D) Limited * - * Copyright (C) 2013-2014 STMicroelectronics (R&D) Limited + * Author: Ajit Pal Singh + * Lee Jones * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -142,13 +144,13 @@ static int sti_pwm_get_prescale(struct sti_pwm_chip *pc, unsigned long period, val = NSEC_PER_SEC / clk_rate; val *= cdata->max_pwm_cnt + 1; - if (period % val) { + if (period % val) return -EINVAL; - } else { - ps = period / val - 1; - if (ps > cdata->max_prescale) - return -EINVAL; - } + + ps = period / val - 1; + if (ps > cdata->max_prescale) + return -EINVAL; + *prescale = ps; return 0; @@ -164,7 +166,7 @@ static int sti_pwm_get_prescale(struct sti_pwm_chip *pc, unsigned long period, * 256 values. */ static int sti_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, - int duty_ns, int period_ns) + int duty_ns, int period_ns) { struct sti_pwm_chip *pc = to_sti_pwmchip(chip); struct sti_pwm_compat_data *cdata = pc->cdata; @@ -210,7 +212,7 @@ static int sti_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, ret = regmap_field_write(pc->prescale_low, - prescale & PWM_PRESCALE_LOW_MASK); + prescale & PWM_PRESCALE_LOW_MASK); if (ret) goto clk_dis; @@ -273,7 +275,7 @@ static int sti_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) ret = regmap_field_write(pc->pwm_out_en, 1); if (ret) { - dev_err(dev, "failed to enable PWM device:%d\n", + dev_err(dev, "failed to enable PWM device %d\n", pwm->hwpwm); goto out; } @@ -293,10 +295,12 @@ static void sti_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) mutex_unlock(&pc->sti_pwm_lock); return; } + regmap_field_write(pc->pwm_out_en, 0); clk_disable(pc->pwm_clk); clk_disable(pc->cpt_clk); + mutex_unlock(&pc->sti_pwm_lock); } @@ -507,7 +511,7 @@ static int sti_pwm_probe_dt(struct sti_pwm_chip *pc) return PTR_ERR(pc->pwm_cpt_en); pc->pwm_cpt_int_en = devm_regmap_field_alloc(dev, pc->regmap, - reg_fields[PWM_CPT_INT_EN]); + reg_fields[PWM_CPT_INT_EN]); if (IS_ERR(pc->pwm_cpt_int_en)) return PTR_ERR(pc->pwm_cpt_int_en); @@ -570,11 +574,11 @@ static int sti_pwm_probe(struct platform_device *pdev) * Setup PWM data with default values: some values could be replaced * with specific ones provided from Device Tree. */ - cdata->reg_fields = &sti_pwm_regfields[0]; - cdata->max_prescale = 0xff; - cdata->max_pwm_cnt = 255; - cdata->pwm_num_devs = 1; - cdata->cpt_num_devs = 0; + cdata->reg_fields = &sti_pwm_regfields[0]; + cdata->max_prescale = 0xff; + cdata->max_pwm_cnt = 255; + cdata->pwm_num_devs = 1; + cdata->cpt_num_devs = 0; pc->cdata = cdata; pc->dev = dev;