Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1402279

[PATCH] pwm: Fill pwm->args before calling pwm_request_from_chip()

From Boris Brezillon <boris.brezillon@free-electrons.com>
Newsgroups linux.kernel
Subject [PATCH] pwm: Fill pwm->args before calling pwm_request_from_chip()
Date 2016-05-17 12:40 +0200
Message-ID <rzKzT-3om-9@gated-at.bofh.it> (permalink)
References <rzKzT-3om-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <boris.brezillon@free-electrons.com>
Reported-by: Mika Penttilä <mika.penttila@nextfour.com>
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;
 }
 
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] pwm: Fill pwm->args before calling pwm_request_from_chip() Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-05-17 12:40 +0200
  [PATCH] pwm: Fill pwm->args before calling pwm_request_from_chip() Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-05-17 12:40 +0200
    Re: [PATCH] pwm: Fill pwm->args before calling  pwm_request_from_chip() Thierry Reding <thierry.reding@gmail.com> - 2016-05-17 13:10 +0200
      Re: [PATCH] pwm: Fill pwm->args before calling  pwm_request_from_chip() Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-05-17 13:20 +0200

csiph-web