From patchwork Wed Jun 8 09:21:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 69615 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2390418qgf; Wed, 8 Jun 2016 02:23:50 -0700 (PDT) X-Received: by 10.36.155.2 with SMTP id o2mr3190900itd.54.1465377829885; Wed, 08 Jun 2016 02:23:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s6si490024pal.9.2016.06.08.02.23.49; Wed, 08 Jun 2016 02:23:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161659AbcFHJXT (ORCPT + 7 others); Wed, 8 Jun 2016 05:23:19 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:38750 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423605AbcFHJVs (ORCPT ); Wed, 8 Jun 2016 05:21:48 -0400 Received: by mail-wm0-f48.google.com with SMTP id m124so7687896wme.1 for ; Wed, 08 Jun 2016 02:21:43 -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=2oICj3YME6b8ZZMj6uAlToOa8KsHe5geE7HgxIIDDDg=; b=HJWRfQDqHfMQkfd5vgBcPtaN69ZvFNP+fQNRXPfa0UqN83e3NZHF5FW8GqUMT7AHAs Qo27eLSGLP6xdA9XMnXctXvanBgYViEe6Q/xyVIvJ4dn9NYSutHagFNb98ns6ZYRdqXj aCc+TYF4g9WfFLslr5W08bieIwgWPwEVrVmqQ= 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=2oICj3YME6b8ZZMj6uAlToOa8KsHe5geE7HgxIIDDDg=; b=AajtHpwChWFOkKo+jQPQD6bia+PlYueiO0/iF5ESqcCAGnyKvT57WZ/Xli3OjQy5tp QD685M79YrmuVOGQD1tYbM9HaoWHzqTOAI/MtU/Ln1n9myz7EDr8gnWGAAb8JsCvPlQC Z7aWLlXXXzth+L3Gz4l9rh21ap3rxnAcQx/dA1KhGScblZjAh5BsANgZe5hAqDIFeHoX t0s+lNlSsN5oZsqy2OOiqepBHKS5g5LnvV4Mw2FfiKZH/eWIKLx/VtCi26rqDaeR9pQo B1zq/vJaj47VxjG+MFJUfr8kbqgOC6TIAEyTplafVn4kiVHSRvpvXDRzCgd87+BOBcR5 dIjg== X-Gm-Message-State: ALyK8tJR9OpKJ5GKgaLQvnABCZSMPRLoJls3N0jKqIYvchAC6eMGYuBHy40AScdI85WAZphl X-Received: by 10.28.182.8 with SMTP id g8mr3953727wmf.56.1465377702554; Wed, 08 Jun 2016 02:21:42 -0700 (PDT) Received: from localhost.localdomain (host81-129-171-215.range81-129.btcentralplus.com. [81.129.171.215]) by smtp.gmail.com with ESMTPSA id g192sm23694494wme.15.2016.06.08.02.21.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jun 2016 02:21:42 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: kernel@stlinux.com, maxime.coquelin@st.com, patrice.chotard@st.com, thierry.reding@gmail.com, robh+dt@kernel.org, linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, Lee Jones Subject: [PATCH v3 18/20] pwm: sti: It's now valid for number of PWM channels to be zero Date: Wed, 8 Jun 2016 10:21:33 +0100 Message-Id: <20160608092135.21184-19-lee.jones@linaro.org> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160608092135.21184-1-lee.jones@linaro.org> References: <20160608092135.21184-1-lee.jones@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Setting up the STI PWM IP as capture only, with zero PWM-out devices is a perfectly valued configuration. It is no longer okay to assume that there must be at least 1 PWM-out devices. In this patch we make the default number of PWM-out devices zero and only configure channels explicitly requested. Reported-by: Peter Griffin Signed-off-by: Lee Jones --- drivers/pwm/pwm-sti.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) -- 2.8.3 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c index cecb6d4..64db5a5 100644 --- a/drivers/pwm/pwm-sti.c +++ b/drivers/pwm/pwm-sti.c @@ -483,6 +483,11 @@ static int sti_pwm_probe_dt(struct sti_pwm_chip *pc) if (!ret) cdata->cpt_num_devs = num_devs; + if (cdata->pwm_num_devs && !cdata->cpt_num_devs) { + dev_err(dev, "No channels configured\n"); + return -EINVAL; + } + reg_fields = cdata->reg_fields; pc->prescale_low = devm_regmap_field_alloc(dev, pc->regmap, @@ -573,7 +578,7 @@ static int sti_pwm_probe(struct platform_device *pdev) cdata->reg_fields = &sti_pwm_regfields[0]; cdata->max_prescale = 0xff; cdata->max_pwm_cnt = 255; - cdata->pwm_num_devs = 1; + cdata->pwm_num_devs = 0; cdata->cpt_num_devs = 0; pc->cdata = cdata; @@ -585,6 +590,9 @@ static int sti_pwm_probe(struct platform_device *pdev) if (ret) return ret; + if (!cdata->pwm_num_devs) + goto skip_pwm; + pc->pwm_clk = of_clk_get_by_name(dev->of_node, "pwm"); if (IS_ERR(pc->pwm_clk)) { dev_err(dev, "failed to get PWM clock\n"); @@ -597,6 +605,10 @@ static int sti_pwm_probe(struct platform_device *pdev) return ret; } +skip_pwm: + if (!cdata->cpt_num_devs) + goto skip_cpt; + pc->cpt_clk = of_clk_get_by_name(dev->of_node, "capture"); if (IS_ERR(pc->cpt_clk)) { dev_err(dev, "failed to get PWM capture clock\n"); @@ -609,6 +621,7 @@ static int sti_pwm_probe(struct platform_device *pdev) return ret; } +skip_cpt: pc->chip.dev = dev; pc->chip.ops = &sti_pwm_ops; pc->chip.base = -1;