diff mbox

input: pwm-beeper: Add devicetree probing support

Message ID 1348472258-31519-1-git-send-email-s.hauer@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Sascha Hauer Sept. 24, 2012, 7:37 a.m. UTC
A very simple binding, the only property is the phandle to the PWM.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 Documentation/devicetree/bindings/input/pwm-beeper.txt |    7 +++++++
 drivers/input/misc/pwm-beeper.c                        |   11 ++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/input/pwm-beeper.txt

Comments

Rob Herring Sept. 24, 2012, 12:55 p.m. UTC | #1
On 09/24/2012 02:37 AM, 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>

Acked-by: Rob Herring <rob.herring@calxeda.com>

> ---
>  Documentation/devicetree/bindings/input/pwm-beeper.txt |    7 +++++++
>  drivers/input/misc/pwm-beeper.c                        |   11 ++++++++++-
>  2 files changed, 17 insertions(+), 1 deletion(-)
>  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/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
> index fc84c8a..a6aa48c 100644
> --- a/drivers/input/misc/pwm-beeper.c
> +++ b/drivers/input/misc/pwm-beeper.c
> @@ -75,7 +75,10 @@ static int __devinit pwm_beeper_probe(struct platform_device *pdev)
>  	if (!beeper)
>  		return -ENOMEM;
>  
> -	beeper->pwm = pwm_request(pwm_id, "pwm beeper");
> +	if (pdev->dev.platform_data)
> +		beeper->pwm = pwm_request(pwm_id, "pwm beeper");
> +	else
> +		beeper->pwm = pwm_get(&pdev->dev, NULL);
>  
>  	if (IS_ERR(beeper->pwm)) {
>  		error = PTR_ERR(beeper->pwm);
> @@ -171,6 +174,11 @@ static SIMPLE_DEV_PM_OPS(pwm_beeper_pm_ops,
>  #define PWM_BEEPER_PM_OPS NULL
>  #endif
>  
> +static const struct of_device_id pwm_beeper_match[] = {
> +	{ .compatible = "pwm-beeper", },
> +	{ },
> +};
> +
>  static struct platform_driver pwm_beeper_driver = {
>  	.probe	= pwm_beeper_probe,
>  	.remove = __devexit_p(pwm_beeper_remove),
> @@ -178,6 +186,7 @@ static struct platform_driver pwm_beeper_driver = {
>  		.name	= "pwm-beeper",
>  		.owner	= THIS_MODULE,
>  		.pm	= PWM_BEEPER_PM_OPS,
> +		.of_match_table = pwm_beeper_match,
>  	},
>  };
>  module_platform_driver(pwm_beeper_driver);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov Sept. 24, 2012, 3:56 p.m. UTC | #2
On Mon, Sep 24, 2012 at 07:55:38AM -0500, Rob Herring wrote:
> On 09/24/2012 02:37 AM, 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>
> 
> Acked-by: Rob Herring <rob.herring@calxeda.com>
> 
> > ---
> >  Documentation/devicetree/bindings/input/pwm-beeper.txt |    7 +++++++
> >  drivers/input/misc/pwm-beeper.c                        |   11 ++++++++++-
> >  2 files changed, 17 insertions(+), 1 deletion(-)
> >  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/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
> > index fc84c8a..a6aa48c 100644
> > --- a/drivers/input/misc/pwm-beeper.c
> > +++ b/drivers/input/misc/pwm-beeper.c
> > @@ -75,7 +75,10 @@ static int __devinit pwm_beeper_probe(struct platform_device *pdev)
> >  	if (!beeper)
> >  		return -ENOMEM;
> >  
> > -	beeper->pwm = pwm_request(pwm_id, "pwm beeper");
> > +	if (pdev->dev.platform_data)
> > +		beeper->pwm = pwm_request(pwm_id, "pwm beeper");
> > +	else
> > +		beeper->pwm = pwm_get(&pdev->dev, NULL);

Hmm, pwm_id == 0 is a valid ID I think, but your change makes it go into
DT branch, potentially breaking it.

Thanks.
diff mbox

Patch

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/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
index fc84c8a..a6aa48c 100644
--- a/drivers/input/misc/pwm-beeper.c
+++ b/drivers/input/misc/pwm-beeper.c
@@ -75,7 +75,10 @@  static int __devinit pwm_beeper_probe(struct platform_device *pdev)
 	if (!beeper)
 		return -ENOMEM;
 
-	beeper->pwm = pwm_request(pwm_id, "pwm beeper");
+	if (pdev->dev.platform_data)
+		beeper->pwm = pwm_request(pwm_id, "pwm beeper");
+	else
+		beeper->pwm = pwm_get(&pdev->dev, NULL);
 
 	if (IS_ERR(beeper->pwm)) {
 		error = PTR_ERR(beeper->pwm);
@@ -171,6 +174,11 @@  static SIMPLE_DEV_PM_OPS(pwm_beeper_pm_ops,
 #define PWM_BEEPER_PM_OPS NULL
 #endif
 
+static const struct of_device_id pwm_beeper_match[] = {
+	{ .compatible = "pwm-beeper", },
+	{ },
+};
+
 static struct platform_driver pwm_beeper_driver = {
 	.probe	= pwm_beeper_probe,
 	.remove = __devexit_p(pwm_beeper_remove),
@@ -178,6 +186,7 @@  static struct platform_driver pwm_beeper_driver = {
 		.name	= "pwm-beeper",
 		.owner	= THIS_MODULE,
 		.pm	= PWM_BEEPER_PM_OPS,
+		.of_match_table = pwm_beeper_match,
 	},
 };
 module_platform_driver(pwm_beeper_driver);