From patchwork Tue May 17 10:35:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 9111521 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 CA5C0BF29F for ; Tue, 17 May 2016 10:37:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 03735202EB for ; Tue, 17 May 2016 10:37:33 +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 33D762011B for ; Tue, 17 May 2016 10:37:32 +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 1b2cMB-0007JA-DO; Tue, 17 May 2016 10:36:07 +0000 Received: from down.free-electrons.com ([37.187.137.238] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b2cM0-0007CV-VE for linux-arm-kernel@lists.infradead.org; Tue, 17 May 2016 10:35:58 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id AD50024B; Tue, 17 May 2016 12:35:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,FSL_HELO_HOME, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bbrezillon.home (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 5D02F1CF; Tue, 17 May 2016 12:35:35 +0200 (CEST) From: Boris Brezillon To: Thierry Reding , linux-pwm@vger.kernel.org, =?UTF-8?q?Mika=20Penttil=C3=A4?= Subject: [PATCH] pwm: Fill pwm->args before calling pwm_request_from_chip() Date: Tue, 17 May 2016 12:35:33 +0200 Message-Id: <1463481333-23438-2-git-send-email-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1463481333-23438-1-git-send-email-boris.brezillon@free-electrons.com> References: <1463481333-23438-1-git-send-email-boris.brezillon@free-electrons.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160517_033557_193885_AE5879AF X-CRM114-Status: GOOD ( 13.70 ) X-Spam-Score: -2.3 (--) 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: Boris Brezillon , linux-kernel@vger.kernel.org, Haojian Zhuang , linux-arm-kernel@lists.infradead.org, Robert Jarzmik , Daniel Mack Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Commit e39c0df1be5a ("pwm: Introduce the pwm_args concept"), moved the period and polarity initialization steps into pwm_request_device() (called by pwm_request_from_chip()) based on the pwm->args information. Make sure we fill pwm->args fields before calling pwm_request_from_chip(). Signed-off-by: Boris Brezillon Reported-by: Mika Penttilä Fixes: e39c0df1be5a ("pwm: Introduce the pwm_args concept") --- Mika, Can you test after applying this patch and let me know if it fixes your bug. Thanks, Boris drivers/pwm/core.c | 12 ++++++------ drivers/pwm/pwm-pxa.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 427142d..3d2eeaa 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -143,10 +143,6 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args) if (args->args[0] >= pc->npwm) return ERR_PTR(-EINVAL); - pwm = pwm_request_from_chip(pc, args->args[0], NULL); - if (IS_ERR(pwm)) - return pwm; - pwm->args.period = args->args[1]; if (args->args[2] & PWM_POLARITY_INVERTED) @@ -154,6 +150,10 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args) else pwm->args.polarity = PWM_POLARITY_NORMAL; + pwm = pwm_request_from_chip(pc, args->args[0], NULL); + if (IS_ERR(pwm)) + return pwm; + return pwm; } EXPORT_SYMBOL_GPL(of_pwm_xlate_with_flags); @@ -169,12 +169,12 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) if (args->args[0] >= pc->npwm) return ERR_PTR(-EINVAL); + pwm->args.period = args->args[1]; + pwm = pwm_request_from_chip(pc, args->args[0], NULL); if (IS_ERR(pwm)) return pwm; - pwm->args.period = args->args[1]; - return pwm; } diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c index 58b709f..c33bd42 100644 --- a/drivers/pwm/pwm-pxa.c +++ b/drivers/pwm/pwm-pxa.c @@ -156,12 +156,12 @@ pxa_pwm_of_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) { struct pwm_device *pwm; + pwm->args.period = args->args[0]; + pwm = pwm_request_from_chip(pc, 0, NULL); if (IS_ERR(pwm)) return pwm; - pwm->args.period = args->args[0]; - return pwm; }