Hi

I'm using this patch in android. It is not for submission of course

Mark Brown wrote:
On Thu, Mar 19, 2009 at 05:50:35PM -0600, Misael Lopez wrote:
2009/3/19 Greg KH <[email protected]>:

Also, why a special class? ?Why not use the input layer for stuff like
this?

In the particular case of headset detection, I originally considered
using ALSA Jack mechanism (and Soc Jack wrapper), which uses input
layer. You probably know about that already.

What made you decide not to use either the generic ALSA stuff or ASoC?
If there's something preventing you using them then it'd be good to fix
it.
Yes this is the right thing todo, I don't see all the code but what happen if the headset is removed
during suspend? Where the worker is forced to be rescheduled in soc-jack?

Michael


--~--~---------~--~----~------------~-------~--~----~
unsubscribe: [email protected]
website: http://groups.google.com/group/android-kernel
-~----------~----~----~----~------~----~------~--~---



-- 
unsubscribe: [email protected]
website: http://groups.google.com/group/android-kernel
commit e967d86b216cf070620a3dc29afc40b3a5565d51
Author: Michael Trimarchi <[email protected]>
Date:   Wed Aug 25 18:31:05 2010 +0200

    Add the irq_flags to the android switch driver and the pm_ops. The pm_ops
    are used after suspend/resume if the headset is removed.
    
    Signed-off-by: Michael Trimarchi <[email protected]>

diff --git a/drivers/switch/switch_gpio.c b/drivers/switch/switch_gpio.c
index 7e9faa2..f4c0d93 100644
--- a/drivers/switch/switch_gpio.c
+++ b/drivers/switch/switch_gpio.c
@@ -79,6 +79,9 @@ static int gpio_switch_probe(struct platform_device *pdev)
 	if (!pdata)
 		return -EBUSY;
 
+	if (!pdata->irq_flags)
+		return -EINVAL;
+
 	switch_data = kzalloc(sizeof(struct gpio_switch_data), GFP_KERNEL);
 	if (!switch_data)
 		return -ENOMEM;
@@ -91,7 +94,7 @@ static int gpio_switch_probe(struct platform_device *pdev)
 	switch_data->state_off = pdata->state_off;
 	switch_data->sdev.print_state = switch_gpio_print_state;
 
-    ret = switch_dev_register(&switch_data->sdev);
+	ret = switch_dev_register(&switch_data->sdev);
 	if (ret < 0)
 		goto err_switch_dev_register;
 
@@ -112,10 +115,12 @@ static int gpio_switch_probe(struct platform_device *pdev)
 	}
 
 	ret = request_irq(switch_data->irq, gpio_irq_handler,
-			  IRQF_TRIGGER_LOW, pdev->name, switch_data);
+			  pdata->irq_flags, pdev->name, switch_data);
 	if (ret < 0)
 		goto err_request_irq;
 
+	platform_set_drvdata(pdev, switch_data);
+
 	/* Perform initial detection */
 	gpio_switch_work(&switch_data->work);
 
@@ -139,18 +144,42 @@ static int __devexit gpio_switch_remove(struct platform_device *pdev)
 
 	cancel_work_sync(&switch_data->work);
 	gpio_free(switch_data->gpio);
-    switch_dev_unregister(&switch_data->sdev);
+	switch_dev_unregister(&switch_data->sdev);
 	kfree(switch_data);
 
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static int switch_gpio_suspend(struct device *dev)
+{
+	struct gpio_switch_data *switch_data = dev_get_drvdata(dev);
+	cancel_work_sync(&switch_data->work);
+	return 0;
+}
+
+static int switch_gpio_resume(struct device *dev)
+{
+	struct gpio_switch_data *switch_data = dev_get_drvdata(dev);
+	schedule_work(&switch_data->work);
+	return 0;
+}
+
+static const struct dev_pm_ops switch_gpio_pm_ops = {
+	.suspend	= switch_gpio_suspend,
+	.resume		= switch_gpio_resume,
+};
+#endif
+
 static struct platform_driver gpio_switch_driver = {
 	.probe		= gpio_switch_probe,
 	.remove		= __devexit_p(gpio_switch_remove),
 	.driver		= {
 		.name	= "switch-gpio",
 		.owner	= THIS_MODULE,
+#ifdef CONFIG_PM
+		.pm	= &switch_gpio_pm_ops,
+#endif
 	},
 };
 
diff --git a/include/linux/switch.h b/include/linux/switch.h
index 3e4c748..966cbd0 100644
--- a/include/linux/switch.h
+++ b/include/linux/switch.h
@@ -31,6 +31,7 @@ struct switch_dev {
 struct gpio_switch_platform_data {
 	const char *name;
 	unsigned 	gpio;
+	unsigned long	irq_flags;
 
 	/* if NULL, switch_dev.name will be printed */
 	const char *name_on;

Reply via email to