Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1434390 > unrolled thread
| Started by | Venkat Reddy Talla <vreddytalla@nvidia.com> |
|---|---|
| First post | 2016-06-30 11:00 +0200 |
| Last post | 2016-07-02 07:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] extcon: adc-jack: add suspend/resume support Venkat Reddy Talla <vreddytalla@nvidia.com> - 2016-06-30 11:00 +0200
Re: [PATCH] extcon: adc-jack: add suspend/resume support Chanwoo Choi <cwchoi00@gmail.com> - 2016-07-02 07:50 +0200
| From | Venkat Reddy Talla <vreddytalla@nvidia.com> |
|---|---|
| Date | 2016-06-30 11:00 +0200 |
| Subject | [PATCH] extcon: adc-jack: add suspend/resume support |
| Message-ID | <rPFZf-7qc-5@gated-at.bofh.it> |
adding suspend and resume funtionality for extcon-adc-jack
driver to configure system wake up for extcon events,
also adding support to enable/disable system wakeup
through flag wakeup_source based on platform requirement.
Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
---
drivers/extcon/extcon-adc-jack.c | 34 ++++++++++++++++++++++++++++++++++
include/linux/extcon/extcon-adc-jack.h | 2 ++
2 files changed, 36 insertions(+)
diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
index 7fc0ae1..44e48aa 100644
--- a/drivers/extcon/extcon-adc-jack.c
+++ b/drivers/extcon/extcon-adc-jack.c
@@ -38,6 +38,7 @@
* @chan: iio channel being queried.
*/
struct adc_jack_data {
+ struct device *dev;
struct extcon_dev *edev;
const unsigned int **cable_names;
@@ -49,6 +50,7 @@ struct adc_jack_data {
struct delayed_work handler;
struct iio_channel *chan;
+ bool wakeup_source;
};
static void adc_jack_handler(struct work_struct *work)
@@ -105,6 +107,7 @@ static int adc_jack_probe(struct platform_device *pdev)
return -EINVAL;
}
+ data->dev = &pdev->dev;
data->edev = devm_extcon_dev_allocate(&pdev->dev, pdata->cable_names);
if (IS_ERR(data->edev)) {
dev_err(&pdev->dev, "failed to allocate extcon device\n");
@@ -128,6 +131,7 @@ static int adc_jack_probe(struct platform_device *pdev)
return PTR_ERR(data->chan);
data->handling_delay = msecs_to_jiffies(pdata->handling_delay_ms);
+ data->wakeup_source = pdata->wakeup_source;
INIT_DEFERRABLE_WORK(&data->handler, adc_jack_handler);
@@ -151,6 +155,9 @@ static int adc_jack_probe(struct platform_device *pdev)
return err;
}
+ if (data->wakeup_source)
+ device_init_wakeup(&pdev->dev, 1);
+
return 0;
}
@@ -165,11 +172,38 @@ static int adc_jack_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int adc_jack_suspend(struct device *dev)
+{
+ struct adc_jack_data *data = dev_get_drvdata(dev);
+
+ cancel_delayed_work_sync(&data->handler);
+ if (device_may_wakeup(data->dev))
+ enable_irq_wake(data->irq);
+
+ return 0;
+}
+
+static int adc_jack_resume(struct device *dev)
+{
+ struct adc_jack_data *data = dev_get_drvdata(dev);
+
+ if (device_may_wakeup(data->dev))
+ disable_irq_wake(data->irq);
+
+ return 0;
+}
+#endif /* CONFIG_PM_SLEEP */
+
+static SIMPLE_DEV_PM_OPS(adc_jack_pm_ops,
+ adc_jack_suspend, adc_jack_resume);
+
static struct platform_driver adc_jack_driver = {
.probe = adc_jack_probe,
.remove = adc_jack_remove,
.driver = {
.name = "adc-jack",
+ .pm = &adc_jack_pm_ops,
},
};
diff --git a/include/linux/extcon/extcon-adc-jack.h b/include/linux/extcon/extcon-adc-jack.h
index 53c6080..ac85f20 100644
--- a/include/linux/extcon/extcon-adc-jack.h
+++ b/include/linux/extcon/extcon-adc-jack.h
@@ -53,6 +53,7 @@ struct adc_jack_cond {
* milli-seconds after the interrupt occurs. You may
* describe such delays with @handling_delay_ms, which
* is rounded-off by jiffies.
+ * @wakeup_source: flag to wake up the system for extcon events.
*/
struct adc_jack_pdata {
const char *name;
@@ -65,6 +66,7 @@ struct adc_jack_pdata {
unsigned long irq_flags;
unsigned long handling_delay_ms; /* in ms */
+ bool wakeup_source;
};
#endif /* _EXTCON_ADC_JACK_H */
--
2.1.4
[toc] | [next] | [standalone]
| From | Chanwoo Choi <cwchoi00@gmail.com> |
|---|---|
| Date | 2016-07-02 07:50 +0200 |
| Message-ID | <rQlYt-842-7@gated-at.bofh.it> |
| In reply to | #1434390 |
Hi Venkat,
Applied it.
Thanks,
Chanwoo Choi
2016-06-30 17:54 GMT+09:00 Venkat Reddy Talla <vreddytalla@nvidia.com>:
> adding suspend and resume funtionality for extcon-adc-jack
> driver to configure system wake up for extcon events,
> also adding support to enable/disable system wakeup
> through flag wakeup_source based on platform requirement.
>
> Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
> ---
> drivers/extcon/extcon-adc-jack.c | 34 ++++++++++++++++++++++++++++++++++
> include/linux/extcon/extcon-adc-jack.h | 2 ++
> 2 files changed, 36 insertions(+)
>
> diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
> index 7fc0ae1..44e48aa 100644
> --- a/drivers/extcon/extcon-adc-jack.c
> +++ b/drivers/extcon/extcon-adc-jack.c
> @@ -38,6 +38,7 @@
> * @chan: iio channel being queried.
> */
> struct adc_jack_data {
> + struct device *dev;
> struct extcon_dev *edev;
>
> const unsigned int **cable_names;
> @@ -49,6 +50,7 @@ struct adc_jack_data {
> struct delayed_work handler;
>
> struct iio_channel *chan;
> + bool wakeup_source;
> };
>
> static void adc_jack_handler(struct work_struct *work)
> @@ -105,6 +107,7 @@ static int adc_jack_probe(struct platform_device *pdev)
> return -EINVAL;
> }
>
> + data->dev = &pdev->dev;
> data->edev = devm_extcon_dev_allocate(&pdev->dev, pdata->cable_names);
> if (IS_ERR(data->edev)) {
> dev_err(&pdev->dev, "failed to allocate extcon device\n");
> @@ -128,6 +131,7 @@ static int adc_jack_probe(struct platform_device *pdev)
> return PTR_ERR(data->chan);
>
> data->handling_delay = msecs_to_jiffies(pdata->handling_delay_ms);
> + data->wakeup_source = pdata->wakeup_source;
>
> INIT_DEFERRABLE_WORK(&data->handler, adc_jack_handler);
>
> @@ -151,6 +155,9 @@ static int adc_jack_probe(struct platform_device *pdev)
> return err;
> }
>
> + if (data->wakeup_source)
> + device_init_wakeup(&pdev->dev, 1);
> +
> return 0;
> }
>
> @@ -165,11 +172,38 @@ static int adc_jack_remove(struct platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_PM_SLEEP
> +static int adc_jack_suspend(struct device *dev)
> +{
> + struct adc_jack_data *data = dev_get_drvdata(dev);
> +
> + cancel_delayed_work_sync(&data->handler);
> + if (device_may_wakeup(data->dev))
> + enable_irq_wake(data->irq);
> +
> + return 0;
> +}
> +
> +static int adc_jack_resume(struct device *dev)
> +{
> + struct adc_jack_data *data = dev_get_drvdata(dev);
> +
> + if (device_may_wakeup(data->dev))
> + disable_irq_wake(data->irq);
> +
> + return 0;
> +}
> +#endif /* CONFIG_PM_SLEEP */
> +
> +static SIMPLE_DEV_PM_OPS(adc_jack_pm_ops,
> + adc_jack_suspend, adc_jack_resume);
> +
> static struct platform_driver adc_jack_driver = {
> .probe = adc_jack_probe,
> .remove = adc_jack_remove,
> .driver = {
> .name = "adc-jack",
> + .pm = &adc_jack_pm_ops,
> },
> };
>
> diff --git a/include/linux/extcon/extcon-adc-jack.h b/include/linux/extcon/extcon-adc-jack.h
> index 53c6080..ac85f20 100644
> --- a/include/linux/extcon/extcon-adc-jack.h
> +++ b/include/linux/extcon/extcon-adc-jack.h
> @@ -53,6 +53,7 @@ struct adc_jack_cond {
> * milli-seconds after the interrupt occurs. You may
> * describe such delays with @handling_delay_ms, which
> * is rounded-off by jiffies.
> + * @wakeup_source: flag to wake up the system for extcon events.
> */
> struct adc_jack_pdata {
> const char *name;
> @@ -65,6 +66,7 @@ struct adc_jack_pdata {
>
> unsigned long irq_flags;
> unsigned long handling_delay_ms; /* in ms */
> + bool wakeup_source;
> };
>
> #endif /* _EXTCON_ADC_JACK_H */
> --
> 2.1.4
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web