public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bill Gatliff <bgat@billgatliff.com>
To: H Hartley Sweeten <hartleys@visionengravers.com>
Cc: Pavel Machek <pavel@ucw.cz>,
	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 10:26:59 -0600	[thread overview]
Message-ID: <4B758153.2060209@billgatliff.com> (raw)
In-Reply-To: <BD79186B4FD85F4B8E60E381CAEE190902153515@mi8nycmail19.Mi8.com>

H Hartley Sweeten wrote:
>
> FWIW, the gpiolib API will accept any non-zero value to "set" a gpio pin
> and a zero value to "clear" the pin.
>   

It makes me sort of cringe to say this, but I'm going to assume that the
API is intended to work that way so that I can take advantage of it. 
But I'd love to someday have the reassurance that gpiolib really *is*
intended to work that way (might be a bad idea though, see below).  Call
me paranoid, but I've lost a lot of hair over the years undoing the
damage of similar failed assumptions.

I've found the Linux kernel code to be refreshingly forgiving of such
things, however, so I'm willing to risk it this time.  :)

> For that matter, some of the gpiolib drivers end up returning the bit
> position mask for a given gpio pin and not 1 or 0.  For instance if the
> gpio pin in question is bit 6 in an 8-bit register and it is set, a
> __gpio_get_value will end up returning 0x40 and not '1'.
>   

Who's to say that gpios should always be boolean?  On the output side, a
"gpio" that's four bits wide might be a useful way of dealing with bar
graphs, seven-segment displays, etc. (but more specialized abstractions
might be more appropriate, of course).

A two-bit "gpio" input might make it easier to deal with rotary encoders.

But for now, GPIOs are assumed to be booleans and that's why I'm
hesitant to feed the API non-boolean values.  Someday, those values
might mean something subtly but disastrously different.  And given my
luck lately with such things...


b.g.

-- 
Bill Gatliff
Embedded systems training and consulting
http://billgatliff.com
bgat@billgatliff.com


  reply	other threads:[~2010-02-12 16:26 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 18:20   ` 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  7:14 ` [PWM PATCH 2/5] Emulates PWM hardware using a high-resolution timer and a GPIO pin Bill Gatliff
2010-02-11 20:07   ` 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
2010-02-12 13:53       ` H Hartley Sweeten
2010-02-12 16:26         ` Bill Gatliff [this message]
2010-02-16 18:12           ` H Hartley Sweeten
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:16   ` Bill Gatliff
2010-02-02 17:52   ` H Hartley Sweeten
2010-02-03  4:10     ` 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 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=4B758153.2060209@billgatliff.com \
    --to=bgat@billgatliff.com \
    --cc=hartleys@visionengravers.com \
    --cc=linux-embedded@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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