[PATCH 1/2] PWM: add pwm framework support
From: s.hauer@pengutronix.de (Sascha Hauer)
Date: 2011-06-28 16:19:55
Also in:
lkml
On Tue, Jun 28, 2011 at 02:27:04PM +0200, Arnd Bergmann wrote:
On Tuesday 28 June 2011, Sascha Hauer wrote:quoted
This patch adds framework support for PWM (pulse width modulation) devices. The is a barebone PWM API already in the kernel under include/linux/pwm.h, but it does not allow for multiple drivers as each of them implements the pwm_*() functions.Hi Sascha, This looks very nice. I have only trivial comments, except for the suggestion to use idr.quoted
+PWM core +M: Sascha Hauer [off-list ref] +L: linux-kernel at vger.kernel.org +S: MaintainedI would add F: drivers/pwm/quoted
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig new file mode 100644 index 0000000..93c1052 --- /dev/null +++ b/drivers/pwm/Kconfig@@ -0,0 +1,12 @@ +menuconfig PWM + bool "PWM Support" + help + This enables PWM support through the generic PWM framework. + You only need to enable this, if you also want to enable + one or more of the PWM drivers below.Remove the comma.quoted
+ +/* + * The next pwm id to assign. We do not bother to fill gaps which + * occur during dynamic registering/deregistering of pwms, but + * instead assign a uniq id to each new pwm.uniquequoted
+ */ +static int next_pwm_id;How about using idr? It provides you a fast lookup and handles giving out unique numbers.
Sounds like a good idea, but is idr compatible with the pwmchip_reserve function below? idr gives no guarantee that the first id is zero, but I need exactly this to make the ids for the internal PWMs known at compile time. (In the longer term it probably makes sense to implement a pwm_get(struct device *, const char *id) similar to the clk api, I just wanted to stay compatible to the current PWM API for now) Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |