From: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] pwm: Call pwm_enable() before pwm_config()
Date: Thu, 23 Aug 2012 14:19:47 +0000 [thread overview]
Message-ID: <217877237.2758643.1345731587941.JavaMail.root@advansee.com> (raw)
In-Reply-To: <320569847.2756382.1345729013971.JavaMail.root@advansee.com>
Some PWM drivers enable the clock of the PWM peripheral in pwm_enable(). Hence,
for these drivers, a call to pwm_config() does not have any effect before
pwm_enable() has been called.
This patch fixes the PWM users to make sure that they call pwm_enable() before
pwm_config().
This fixes the first setting of brightness through sysfs that had no effect with
leds-pwm and the i.MX PWM driver.
Cc: Thierry Reding <thierry.reding@avionic-design.de>
Cc: <linux-kernel@vger.kernel.org>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: <linux-arm-kernel@lists.infradead.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: <linux-input@vger.kernel.org>
Cc: Bryan Wu <bryan.wu@canonical.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: <linux-leds@vger.kernel.org>
Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: <linux-fbdev@vger.kernel.org>
Cc: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
---
.../drivers/input/misc/pwm-beeper.c | 6 +++---
.../drivers/leds/leds-pwm.c | 2 +-
.../drivers/video/backlight/pwm_bl.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git linux-next-c94456b.orig/drivers/input/misc/pwm-beeper.c linux-next-c94456b/drivers/input/misc/pwm-beeper.c
index fc84c8a..97d322b 100644
--- linux-next-c94456b.orig/drivers/input/misc/pwm-beeper.c
+++ linux-next-c94456b/drivers/input/misc/pwm-beeper.c
@@ -53,10 +53,10 @@ static int pwm_beeper_event(struct input_dev *input,
pwm_disable(beeper->pwm);
} else {
period = HZ_TO_NANOSECONDS(value);
- ret = pwm_config(beeper->pwm, period / 2, period);
+ ret = pwm_enable(beeper->pwm);
if (ret)
return ret;
- ret = pwm_enable(beeper->pwm);
+ ret = pwm_config(beeper->pwm, period / 2, period);
if (ret)
return ret;
beeper->period = period;
@@ -156,8 +156,8 @@ static int pwm_beeper_resume(struct device *dev)
struct pwm_beeper *beeper = dev_get_drvdata(dev);
if (beeper->period) {
- pwm_config(beeper->pwm, beeper->period / 2, beeper->period);
pwm_enable(beeper->pwm);
+ pwm_config(beeper->pwm, beeper->period / 2, beeper->period);
}
return 0;
diff --git linux-next-c94456b.orig/drivers/leds/leds-pwm.c linux-next-c94456b/drivers/leds/leds-pwm.c
index f2e44c7..c2e0c22 100644
--- linux-next-c94456b.orig/drivers/leds/leds-pwm.c
+++ linux-next-c94456b/drivers/leds/leds-pwm.c
@@ -42,8 +42,8 @@ static void led_pwm_set(struct led_classdev *led_cdev,
pwm_config(led_dat->pwm, 0, period);
pwm_disable(led_dat->pwm);
} else {
- pwm_config(led_dat->pwm, brightness * period / max, period);
pwm_enable(led_dat->pwm);
+ pwm_config(led_dat->pwm, brightness * period / max, period);
}
}
diff --git linux-next-c94456b.orig/drivers/video/backlight/pwm_bl.c linux-next-c94456b/drivers/video/backlight/pwm_bl.c
index 995f016..a4bb95c 100644
--- linux-next-c94456b.orig/drivers/video/backlight/pwm_bl.c
+++ linux-next-c94456b/drivers/video/backlight/pwm_bl.c
@@ -65,8 +65,8 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
duty_cycle = pb->lth_brightness +
(duty_cycle * (pb->period - pb->lth_brightness) / max);
- pwm_config(pb->pwm, duty_cycle, pb->period);
pwm_enable(pb->pwm);
+ pwm_config(pb->pwm, duty_cycle, pb->period);
}
if (pb->notify_after)
next parent reply other threads:[~2012-08-23 14:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <320569847.2756382.1345729013971.JavaMail.root@advansee.com>
2012-08-23 14:19 ` Benoît Thébaudeau [this message]
2012-08-23 15:43 ` [PATCH] pwm: Call pwm_enable() before pwm_config() Lars-Peter Clausen
2012-08-23 16:57 ` Benoît Thébaudeau
2012-08-23 17:12 ` Lars-Peter Clausen
2012-08-23 17:19 ` Lars-Peter Clausen
2012-08-23 19:04 ` Thierry Reding
2012-09-20 19:05 ` Mark Brown
2012-08-23 19:11 ` Thierry Reding
2012-08-23 20:58 ` [PATCH] pwm-imx: Fix config / enable / disable Benoît Thébaudeau
2012-08-28 7:37 ` Sascha Hauer
2012-09-20 19:03 ` [PATCH] pwm: Call pwm_enable() before pwm_config() Mark Brown
2012-08-30 7:10 ` Jingoo Han
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=217877237.2758643.1345731587941.JavaMail.root@advansee.com \
--to=benoit.thebaudeau@advansee.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).