Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1407876
| Path | csiph.com!feeder.erje.net!1.us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news.mixmin.net!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Boris Brezillon <boris.brezillon@free-electrons.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] pwm: don't allow duty cycle higher than period |
| Date | Fri, 27 May 2016 09:40:02 +0200 |
| Message-ID | <rDkxc-uS-15@gated-at.bofh.it> (permalink) |
| References | <rDaHw-2Xq-17@gated-at.bofh.it> |
| X-Original-To | Brian Norris <briannorris@chromium.org> |
| X-Mailer | Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 59 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Thierry Reding <thierry.reding@gmail.com>, linux-pwm@vger.kernel.org, <linux-kernel@vger.kernel.org>, Brian Norris <computersforpeace@gmail.com>, Doug Anderson <dianders@chromium.org> |
| X-Original-Date | Fri, 27 May 2016 09:34:39 +0200 |
| X-Original-Message-ID | <20160527093439.5ad237c5@bbrezillon> |
| X-Original-References | <1464296730-121773-1-git-send-email-briannorris@chromium.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1407876 |
Show key headers only | View raw
Hi Brian, On Thu, 26 May 2016 14:05:30 -0700 Brian Norris <briannorris@chromium.org> wrote: > It doesn't make sense to allow the duty cycle to be larger than the > period. I can see this behavior by, e.g.: > > # echo 1 > /sys/class/pwm/pwmchip0/export > # cat /sys/class/pwm/pwmchip0/pwm1/period > 100 > # echo 101 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle > [... driver may or may not reject the value, or trigger some logic bug ...] > > It's better to see: > > # echo 1 > /sys/class/pwm/pwmchip0/export > # cat /sys/class/pwm/pwmchip0/pwm1/period > 100 > # echo 101 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle > -bash: echo: write error: Invalid argument > > Signed-off-by: Brian Norris <briannorris@chromium.org> > --- > drivers/pwm/core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c > index dba3843c53b8..9246b60f894a 100644 > --- a/drivers/pwm/core.c > +++ b/drivers/pwm/core.c > @@ -463,6 +463,9 @@ int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state) > if (!memcmp(state, &pwm->state, sizeof(*state))) > return 0; > > + if (state->duty_cycle > state->period) > + return -EINVAL; > + Argh, I forgot to move the pwm_config() checks [1] into pwm_apply_state() :-/. I think we should check all the corner cases (see this diff [2]), once done you can add my Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> Thierry, can you include that in your material for 4.7-rc1? Thanks, Boris [1]http://lxr.free-electrons.com/source/drivers/pwm/core.c#L443 [2]http://code.bulix.org/wtqja4-99473 -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] pwm: don't allow duty cycle higher than period Brian Norris <briannorris@chromium.org> - 2016-05-26 23:10 +0200
Re: [PATCH] pwm: don't allow duty cycle higher than period Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-05-27 09:40 +0200
Re: [PATCH] pwm: don't allow duty cycle higher than period Brian Norris <briannorris@chromium.org> - 2016-05-27 18:40 +0200
Re: [PATCH] pwm: don't allow duty cycle higher than period Brian Norris <briannorris@chromium.org> - 2016-05-27 19:00 +0200
Re: [PATCH] pwm: don't allow duty cycle higher than period Brian Norris <briannorris@chromium.org> - 2016-05-27 18:40 +0200
Re: [PATCH] pwm: don't allow duty cycle higher than period Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-05-27 18:40 +0200
Re: [PATCH] pwm: don't allow duty cycle higher than period Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-05-27 18:50 +0200
csiph-web