From: Pavel Machek <pavel@ucw.cz>
To: "Stanislav O. Bezzubtsev" <stas@lvk.cs.msu.su>
Cc: Bill Gatliff <bgat@billgatliff.com>,
linux-embedded@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PWM PATCH 2/5] Emulates PWM hardware using a high-resolution timer and a GPIO pin
Date: Fri, 12 Feb 2010 14:41:04 +0100 [thread overview]
Message-ID: <20100212134103.GA24949@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <A8919B3D-43EF-4EA5-8334-F1B52AE97E5A@lvk.cs.msu.su>
>
> 11.02.2010, ? 23:58, Pavel Machek ???????(?):
>
> > On Thu 2010-02-11 14:35:14, Bill Gatliff wrote:
> >> Pavel Machek wrote:
> >>>> +static void
> >>>> +gpio_pwm_work (struct work_struct *work)
> >>>> +{
> >>>> + struct gpio_pwm *gp = container_of(work, struct gpio_pwm, work);
> >>>> +
> >>>> + if (gp->active)
> >>>> + gpio_direction_output(gp->gpio, gp->polarity ? 1 : 0);
> >>>> + else
> >>>> + gpio_direction_output(gp->gpio, gp->polarity ? 0 : 1);
> >>>> +}
> >>>>
> >>>
> >>> ...polarity ^ active ?
> >>>
> >>
> >> ... except that if polarity and/or active are >1, I don't send the
> >> values 1 or 0 to gpio_direction_output. I don't know if the API is
> >> specifically intended to accept nonzero values that are greater than 1.
> >
> > !polarity ^ !active ? :-).
>
>
> One the one hand that wouldn't be 100% right because according to
> ANSI C !(0) is just != 0 but no one says it is 1.
I believe you are wrong here.
!!x is common idiom using to turn anything into 0/1, used all over kernel.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
next prev parent reply other threads:[~2010-02-12 13:41 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-02 7:14 [PWM PATCH 0/5] Implements a common PWM API Bill Gatliff
2010-02-02 7:14 ` [PWM PATCH 1/5] API to consolidate PWM devices behind a common user and kernel interface Bill Gatliff
2010-02-02 7:14 ` [PWM PATCH 2/5] Emulates PWM hardware using a high-resolution timer and a GPIO pin Bill Gatliff
2010-02-02 7:14 ` [PWM PATCH 3/5] Expunge old Atmel PWMC driver, replacing it with one that conforms to the PWM API Bill Gatliff
2010-02-02 7:14 ` [PWM PATCH 4/5] PWM-based LED control Bill Gatliff
2010-02-02 7:14 ` [PWM PATCH 5/5] LED "dimmer" trigger Bill Gatliff
2010-02-02 7:16 ` [PWM PATCH 3/5] Expunge old Atmel PWMC driver, replacing it with one that conforms to the PWM API Bill Gatliff
2010-02-02 17:52 ` H Hartley Sweeten
2010-02-03 4:10 ` Bill Gatliff
2010-02-11 20:07 ` [PWM PATCH 2/5] Emulates PWM hardware using a high-resolution timer and a GPIO pin Pavel Machek
2010-02-11 20:35 ` Bill Gatliff
2010-02-11 20:58 ` Pavel Machek
2010-02-12 7:22 ` Stanislav O. Bezzubtsev
2010-02-12 13:13 ` Geert Uytterhoeven
2010-02-12 13:41 ` Pavel Machek [this message]
2010-02-12 13:53 ` H Hartley Sweeten
2010-02-12 16:26 ` Bill Gatliff
2010-02-16 18:12 ` H Hartley Sweeten
2010-02-02 18:20 ` [PWM PATCH 1/5] API to consolidate PWM devices behind a common user and kernel interface H Hartley Sweeten
2010-02-03 4:12 ` Bill Gatliff
2010-02-04 1:39 ` H Hartley Sweeten
2010-02-04 5:31 ` Bill Gatliff
2010-02-04 17:30 ` Bill Gatliff
2010-02-11 20:04 ` Pavel Machek
2010-02-11 20:51 ` Bill Gatliff
2010-02-11 21:00 ` Pavel Machek
2010-02-02 17:44 ` [PWM PATCH 0/5] Implements a common PWM API H Hartley Sweeten
2010-02-03 4:08 ` Bill Gatliff
2010-02-04 23:20 ` H Hartley Sweeten
2010-02-05 18:53 ` Bill Gatliff
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=20100212134103.GA24949@atrey.karlin.mff.cuni.cz \
--to=pavel@ucw.cz \
--cc=bgat@billgatliff.com \
--cc=linux-embedded@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stas@lvk.cs.msu.su \
/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
all inboxes | Powered by JetHome®