From patchwork Tue Aug 16 09:35:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 73968 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1896336qga; Tue, 16 Aug 2016 02:36:33 -0700 (PDT) X-Received: by 10.98.56.207 with SMTP id f198mr62529352pfa.83.1471340192991; Tue, 16 Aug 2016 02:36:32 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay6si31361428pab.279.2016.08.16.02.36.32; Tue, 16 Aug 2016 02:36:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932431AbcHPJgY (ORCPT + 27 others); Tue, 16 Aug 2016 05:36:24 -0400 Received: from mail-wm0-f43.google.com ([74.125.82.43]:37578 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753645AbcHPJfz (ORCPT ); Tue, 16 Aug 2016 05:35:55 -0400 Received: by mail-wm0-f43.google.com with SMTP id i5so154559762wmg.0 for ; Tue, 16 Aug 2016 02:35:54 -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=B89tKz4ZXdmU/evEyXWVMDPALD06V25RzOoArNluGBU=; b=K2WgM7MLSbfO3u4qUqmJBDEMh4Cj5Q+McdjawB7RAIhaoE1mdnvg8g5Z89n4SjzhMD 0RlEH3M1lIj6TnS1irRAVZcCSYMYlEV2Rz4W30a13AlOh7hABcYRo36rEk2Fx3L7ctJO NwMSXjmMBcbq82dIlOdRwe8IwCO7mj+PwV2yE= 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=B89tKz4ZXdmU/evEyXWVMDPALD06V25RzOoArNluGBU=; b=OEJawfpdBLDN4bx9/b3RXAQke3QsPlgPdzxlZxlDbx4ysHS6yle8dfAECvTVLiGo79 lBYeUZTZMfelzuLn0yiPgMifwTGsXEQLIQR557zEIyYlRZqFa8/SXGXYCbtyez01w1y5 vWgoW+q6D2rBRv7KY+aZ1MdUM1GNDUKZUAWKlmViWyFLRMK1tBbDslgQNy0TVUcVrNos 4n6e3teTG8JwzeS2qXbMn5Im+Wfz5X1bA2t62tfd2i6tJ0JLJkdeCgUcfdrvMG3+sadn exRQnMNNiyw/GSWU5l3UJNiiTDlHDIMjYzAyT4eMwS68iJ6YU7xJZe7tsTtK0R4Dn6l7 Bxnw== X-Gm-Message-State: AEkoouutfrBmkRsX5wMs2YgnB5hkRnxfPXrcCQKaPJ1mimzPaOgGV3oUHxPOoSWjIcf6C50p X-Received: by 10.28.164.130 with SMTP id n124mr5549075wme.105.1471340153858; Tue, 16 Aug 2016 02:35:53 -0700 (PDT) Received: from localhost.localdomain (host81-129-169-93.range81-129.btcentralplus.com. [81.129.169.93]) by smtp.gmail.com with ESMTPSA id g1sm16614889wjy.5.2016.08.16.02.35.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Aug 2016 02:35:53 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: kernel@stlinux.com, patrice.chotard@st.com, thierry.reding@gmail.com, linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, Lee Jones Subject: [PATCH v4 16/17] pwm: sti: Take the opportunity to conduct a little house keeping Date: Tue, 16 Aug 2016 10:35:07 +0100 Message-Id: <20160816093508.28307-17-lee.jones@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160816093508.28307-1-lee.jones@linaro.org> References: <20160816093508.28307-1-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.9.0 diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c index a1319c0..3d5b9aa 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); } @@ -512,7 +516,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); @@ -575,11 +579,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 = 0; - 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 = 0; + cdata->cpt_num_devs = 0; pc->cdata = cdata; pc->dev = dev;