* [PATCH v3] input: pwm-beeper: Add devicetree probing support
@ 2012-11-02 8:44 Sascha Hauer
2012-11-02 9:10 ` Thierry Reding
2012-11-03 19:03 ` Dmitry Torokhov
0 siblings, 2 replies; 4+ messages in thread
From: Sascha Hauer @ 2012-11-02 8:44 UTC (permalink / raw)
To: linux-input
Cc: Dmitry Torokhov, Lars-Peter Clausen, Thierry Reding, kernel,
Sascha Hauer
A very simple binding, the only property is the phandle to the PWM.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
changes since v2:
- protect of match table with #ifdef CONFIG_OF
changes since v1:
- first use new pwm API, if that fails, use legacy API
- add 'depends on PWM'
Documentation/devicetree/bindings/input/pwm-beeper.txt | 7 +++++++
drivers/input/misc/Kconfig | 2 +-
drivers/input/misc/pwm-beeper.c | 14 +++++++++++++-
3 files changed, 21 insertions(+), 2 deletions(-)
create mode 100644 Documentation/devicetree/bindings/input/pwm-beeper.txt
diff --git a/Documentation/devicetree/bindings/input/pwm-beeper.txt b/Documentation/devicetree/bindings/input/pwm-beeper.txt
new file mode 100644
index 0000000..7388b82
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/pwm-beeper.txt
@@ -0,0 +1,7 @@
+* PWM beeper device tree bindings
+
+Registers a PWM device as beeper.
+
+Required properties:
+- compatible: should be "pwm-beeper"
+- pwms: phandle to the physical pwm device
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7c0f1ec..ff5dbd6 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -444,7 +444,7 @@ config INPUT_PCF8574
config INPUT_PWM_BEEPER
tristate "PWM beeper support"
- depends on HAVE_PWM
+ depends on HAVE_PWM || PWM
help
Say Y here to get support for PWM based beeper devices.
diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
index fc84c8a..e95a7c8 100644
--- a/drivers/input/misc/pwm-beeper.c
+++ b/drivers/input/misc/pwm-beeper.c
@@ -75,7 +75,11 @@ static int __devinit pwm_beeper_probe(struct platform_device *pdev)
if (!beeper)
return -ENOMEM;
- beeper->pwm = pwm_request(pwm_id, "pwm beeper");
+ beeper->pwm = pwm_get(&pdev->dev, NULL);
+ if (IS_ERR(beeper->pwm)) {
+ dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n");
+ beeper->pwm = pwm_request(pwm_id, "pwm beeper");
+ }
if (IS_ERR(beeper->pwm)) {
error = PTR_ERR(beeper->pwm);
@@ -171,6 +175,13 @@ static SIMPLE_DEV_PM_OPS(pwm_beeper_pm_ops,
#define PWM_BEEPER_PM_OPS NULL
#endif
+#ifdef CONFIG_OF
+static const struct of_device_id pwm_beeper_match[] = {
+ { .compatible = "pwm-beeper", },
+ { },
+};
+#endif
+
static struct platform_driver pwm_beeper_driver = {
.probe = pwm_beeper_probe,
.remove = __devexit_p(pwm_beeper_remove),
@@ -178,6 +189,7 @@ static struct platform_driver pwm_beeper_driver = {
.name = "pwm-beeper",
.owner = THIS_MODULE,
.pm = PWM_BEEPER_PM_OPS,
+ .of_match_table = of_match_ptr(pwm_beeper_match),
},
};
module_platform_driver(pwm_beeper_driver);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] input: pwm-beeper: Add devicetree probing support
2012-11-02 8:44 [PATCH v3] input: pwm-beeper: Add devicetree probing support Sascha Hauer
@ 2012-11-02 9:10 ` Thierry Reding
2012-11-03 19:03 ` Dmitry Torokhov
1 sibling, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2012-11-02 9:10 UTC (permalink / raw)
To: Sascha Hauer; +Cc: linux-input, Dmitry Torokhov, Lars-Peter Clausen, kernel
[-- Attachment #1: Type: text/plain, Size: 1382 bytes --]
On Fri, Nov 02, 2012 at 09:44:02AM +0100, Sascha Hauer wrote:
> A very simple binding, the only property is the phandle to the PWM.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>
> changes since v2:
>
> - protect of match table with #ifdef CONFIG_OF
>
> changes since v1:
>
> - first use new pwm API, if that fails, use legacy API
> - add 'depends on PWM'
>
> Documentation/devicetree/bindings/input/pwm-beeper.txt | 7 +++++++
> drivers/input/misc/Kconfig | 2 +-
> drivers/input/misc/pwm-beeper.c | 14 +++++++++++++-
> 3 files changed, 21 insertions(+), 2 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/input/pwm-beeper.txt
>
> diff --git a/Documentation/devicetree/bindings/input/pwm-beeper.txt b/Documentation/devicetree/bindings/input/pwm-beeper.txt
> new file mode 100644
> index 0000000..7388b82
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/pwm-beeper.txt
> @@ -0,0 +1,7 @@
> +* PWM beeper device tree bindings
> +
> +Registers a PWM device as beeper.
> +
> +Required properties:
> +- compatible: should be "pwm-beeper"
> +- pwms: phandle to the physical pwm device
I'd like to see this rewritten as "physical PWM device", but other than
that:
Reviewed-by: Thierry Reding <thierry.reding@avionic-design.de>
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] input: pwm-beeper: Add devicetree probing support
2012-11-02 8:44 [PATCH v3] input: pwm-beeper: Add devicetree probing support Sascha Hauer
2012-11-02 9:10 ` Thierry Reding
@ 2012-11-03 19:03 ` Dmitry Torokhov
2012-11-03 21:33 ` Sascha Hauer
1 sibling, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2012-11-03 19:03 UTC (permalink / raw)
To: Sascha Hauer; +Cc: linux-input, Lars-Peter Clausen, Thierry Reding, kernel
Hi Sascha.
On Fri, Nov 02, 2012 at 09:44:02AM +0100, Sascha Hauer wrote:
>
> - beeper->pwm = pwm_request(pwm_id, "pwm beeper");
> + beeper->pwm = pwm_get(&pdev->dev, NULL);
> + if (IS_ERR(beeper->pwm)) {
> + dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n");
This is not an error, I'll switch it over to dev_dbg().
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] input: pwm-beeper: Add devicetree probing support
2012-11-03 19:03 ` Dmitry Torokhov
@ 2012-11-03 21:33 ` Sascha Hauer
0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2012-11-03 21:33 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Lars-Peter Clausen, Thierry Reding, kernel
Hi Dmitry,
On Sat, Nov 03, 2012 at 12:03:01PM -0700, Dmitry Torokhov wrote:
> Hi Sascha.
>
> On Fri, Nov 02, 2012 at 09:44:02AM +0100, Sascha Hauer wrote:
> >
> > - beeper->pwm = pwm_request(pwm_id, "pwm beeper");
> > + beeper->pwm = pwm_get(&pdev->dev, NULL);
> > + if (IS_ERR(beeper->pwm)) {
> > + dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n");
>
> This is not an error, I'll switch it over to dev_dbg().
This is cut and paste from some other driver. I suppose it's dev_err to
motivate people to update their boards. Anyway, dev_dbg is fine with me.
Thanks,
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 |
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-03 21:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-02 8:44 [PATCH v3] input: pwm-beeper: Add devicetree probing support Sascha Hauer
2012-11-02 9:10 ` Thierry Reding
2012-11-03 19:03 ` Dmitry Torokhov
2012-11-03 21:33 ` Sascha Hauer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.