linux-embedded.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: Bill Gatliff <bgat@billgatliff.com>,
	Mike Frysinger <vapier.adi@gmail.com>,
	linux-embedded@vger.kernel.org
Subject: Re: [PATCH 0/6] Generic PWM API implementation
Date: Sat, 28 Nov 2009 13:59:35 -0800	[thread overview]
Message-ID: <200911281359.35565.david-b@pacbell.net> (raw)
In-Reply-To: <fa686aa40911230939q3c65c681jee8c4098331f70ee@mail.gmail.com>

On Monday 23 November 2009, Grant Likely wrote:
> 			I take issue
> with all the common code behind the API to make it work and to allow
> GPIOs or PWMs to be registered at runtime.  The overlap is the code
> and behaviour used to register pins and to obtain a reference to a
> pin.
> 
> On the PWM side; it's the code backing pwm_register().
> pwm_unregister(), pwm_request(), pwm_free(), and the sysfs hooks.
> 
> For GPIO; it's gpiochip_add(), gpiochip_remove(), gpio_request(),
> gpio_free(), the sysfs hooks, and the device tree bindings.
> 
> They perform exactly the same task.  The difference is that PWM
> devices implement the PWM API and GPIO devices implement the GPIO API;
> but the behaviour needed to manage them is identical.  I don't like
> the fact that it will be implemented twice with subtle differences
> between them.

Most of that stuff sits inside sysfs.  What's actually sharable?


> The argument has been made that the split is appropriate because the
> use case between GPIO and PWM is considerably different, and to a
> point I agree.  The PWM use case definitely requires a different API.
> However, the argument also makes the assumption that what is a GPIO
> and what is a PWM can easily be pinned down.  For example, I've got
> output only GPIOs, input only GPIOs, and a device that implements both
> PWM and GPIO behaviour (not pin muxing).

In object oriented programming there's this thing called an "interface",
and its application here is:  you write a driver implementing both
the "gpio" and "pwm" interfaces.  Someone wanting a given behavior
goes through that interface.


> If a hard distinction is 
> made now to manage GPIO and PWM pins separately, what then do we do
> with other similar-yet-different pin controllers?  What about a
> multi-voltage output GPIO pin?  Or a Frequency generator pin?  Is it
> appropriate to create a new subsystem for managing each one?

None of those are particularly common.  The Linux approach is to come
up with interfaces as needed ... then generalize once there's enough
data, if indeed there is enough.  Just because you *can* come up with
hardware doesn't mean it's widespread enough to need a shared API.


> What an API can do is capture the common use cases, but it can never
> capture the full range of behaviour implemented by a particular
> device.

Right, so you need to become accustomed to the notion that there
can be platform-specific capabilities.  Kitchen-sink APIs are bad.

  parent reply	other threads:[~2009-11-28 21:59 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-15 18:14 [PATCH 0/6] Generic PWM API implementation Bill Gatliff
2008-10-15 18:14 ` [PATCH 1/6] [PWM] " Bill Gatliff
2008-10-17 15:59   ` Mike Frysinger
2008-11-04 20:16     ` Bill Gatliff
2008-11-04 20:51       ` Mike Frysinger
2008-11-04 23:55       ` David Brownell
2008-11-05  0:17         ` Mike Frysinger
2008-11-05  2:59           ` Bill Gatliff
2008-11-05  5:08           ` David Brownell
2008-11-05  2:56         ` Bill Gatliff
2008-10-15 18:14 ` [PATCH 2/6] [PWM] Changes to existing include/linux/pwm.h to adapt to generic PWM API Bill Gatliff
2008-10-15 18:14 ` [PATCH 3/6] [PWM] Documentation Bill Gatliff
2008-10-15 18:14 ` [PATCH 4/6] [PWM] Driver for Atmel PWMC peripheral Bill Gatliff
2008-10-15 18:14 ` [PATCH 5/6] [PWM] Install new Atmel PWMC driver in Kconfig, expunge old one Bill Gatliff
2008-10-15 18:14 ` [PATCH 6/6] [PWM] New LED driver and trigger that use PWM API Bill Gatliff
2009-11-13 19:08 ` [PATCH 0/6] Generic PWM API implementation Grant Likely
2009-11-14  4:22   ` Mike Frysinger
2009-11-14  7:55     ` Grant Likely
2009-11-17  7:47       ` David Brownell
2009-11-17 15:48         ` Bill Gatliff
2009-11-17 16:53           ` David Brownell
2009-11-20 22:51             ` Grant Likely
2009-11-20 22:14         ` Grant Likely
2009-11-23 14:12           ` Bill Gatliff
2009-11-23 17:39             ` Grant Likely
2009-11-23 20:51               ` Albrecht Dreß
2009-11-28 21:38               ` David Brownell
2009-11-28 21:59               ` David Brownell [this message]
2009-11-17 15:45       ` Bill Gatliff
2009-11-17  8:27   ` David Brownell
2009-11-17 15:54     ` Bill Gatliff
2009-11-20 22:21     ` Grant Likely
2009-11-23 14:13       ` Bill Gatliff
2009-11-23 17:40         ` Grant Likely
2009-11-23 15:29       ` Mark Brown
2009-11-23 17:44         ` Grant Likely
2009-11-23 18:09           ` Mark Brown
2009-11-28 21:54             ` David Brownell
2009-11-17 15:39   ` Bill Gatliff
2009-11-20 22:49     ` Grant Likely
2009-11-28 21:28       ` David Brownell

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=200911281359.35565.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=bgat@billgatliff.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-embedded@vger.kernel.org \
    --cc=vapier.adi@gmail.com \
    /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).