From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Javier Martinez Canillas <martinez.javier@gmail.com>
Cc: Henrik Rydberg <rydberg@euromail.se>,
Mohan Pallaka <mpallaka@codeaurora.org>,
Kevin McNeely <kev@cypress.com>,
Shubhrajyoti Datta <omaplinuxkernel@gmail.com>,
linux-input@vger.kernel.org
Subject: [PATCH 7/7] Input: cyttsp - consolidate PM methods
Date: Mon, 14 Nov 2011 00:16:17 -0800 [thread overview]
Message-ID: <20111114081617.10141.41781.stgit@hammer.corenet.prv> (raw)
In-Reply-To: <20111114080939.10141.46174.stgit@hammer.corenet.prv>
The PM methods are basically the same for SPI and I2C busses, so let's
use the same dev_pm_ops for both of them.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/touchscreen/cyttsp_core.c | 22 ++++++++++------------
drivers/input/touchscreen/cyttsp_core.h | 6 ++----
drivers/input/touchscreen/cyttsp_i2c.c | 22 +---------------------
drivers/input/touchscreen/cyttsp_spi.c | 20 +-------------------
4 files changed, 14 insertions(+), 56 deletions(-)
diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index ccdfa10..cd0fe40 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -504,16 +504,13 @@ bypass:
}
#ifdef CONFIG_PM_SLEEP
-int cyttsp_resume(struct cyttsp *ts)
+static int cyttsp_resume(struct device *dev)
{
+ struct cyttsp *ts = dev_get_drvdata(dev);
int retval = 0;
struct cyttsp_xydata xydata;
- if (!ts)
- return retval;
-
- if (ts->pdata->use_sleep && (ts->power_state !=
- CY_ACTIVE_STATE)) {
+ if (ts->pdata->use_sleep && ts->power_state != CY_ACTIVE_STATE) {
if (ts->pdata->wakeup)
retval = ts->pdata->wakeup();
@@ -532,16 +529,15 @@ int cyttsp_resume(struct cyttsp *ts)
return retval;
}
-EXPORT_SYMBOL_GPL(cyttsp_resume);
-int cyttsp_suspend(struct cyttsp *ts)
+static int cyttsp_suspend(struct device *dev)
{
+ struct cyttsp *ts = dev_get_drvdata(dev);
u8 sleep_mode = 0;
int retval = 0;
- if (ts->pdata->use_sleep &&
- (ts->power_state == CY_ACTIVE_STATE)) {
- sleep_mode = ts->pdata->use_sleep;
+ if (ts->pdata->use_sleep && ts->power_state == CY_ACTIVE_STATE) {
+ sleep_mode = ts->platform_data->use_sleep;
retval = ttsp_write_block_data(ts,
CY_REG_BASE, sizeof(sleep_mode), &sleep_mode);
if (retval >= 0)
@@ -550,9 +546,11 @@ int cyttsp_suspend(struct cyttsp *ts)
return retval;
}
-EXPORT_SYMBOL_GPL(cyttsp_suspend);
#endif
+SIMPLE_DEV_PM_OPS(cyttsp_pm_ops, cyttsp_suspend, cyttsp_resume);
+EXPORT_SYMBOL_GPL(cyttsp_pm_ops);
+
static int cyttsp_open(struct input_dev *dev)
{
struct cyttsp *ts = input_get_drvdata(dev);
diff --git a/drivers/input/touchscreen/cyttsp_core.h b/drivers/input/touchscreen/cyttsp_core.h
index 1d9f185..5087b2b 100644
--- a/drivers/input/touchscreen/cyttsp_core.h
+++ b/drivers/input/touchscreen/cyttsp_core.h
@@ -134,9 +134,7 @@ struct cyttsp {
struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
struct device *dev, int irq, size_t xfer_buf_size);
void cyttsp_remove(struct cyttsp *ts);
-#ifdef CONFIG_PM_SLEEP
-int cyttsp_resume(struct cyttsp *ts);
-int cyttsp_suspend(struct cyttsp *ts);
-#endif
+
+extern const struct dev_pm_ops cyttsp_pm_ops;
#endif /* __CYTTSP_CORE_H__ */
diff --git a/drivers/input/touchscreen/cyttsp_i2c.c b/drivers/input/touchscreen/cyttsp_i2c.c
index b476441..2b6acf4 100644
--- a/drivers/input/touchscreen/cyttsp_i2c.c
+++ b/drivers/input/touchscreen/cyttsp_i2c.c
@@ -107,26 +107,6 @@ static int __devexit cyttsp_i2c_remove(struct i2c_client *client)
return 0;
}
-#ifdef CONFIG_PM_SLEEP
-static int cyttsp_i2c_suspend(struct device *dev)
-{
- struct i2c_client *client = to_i2c_client(dev);
- struct cyttsp *ts = i2c_get_clientdata(client);
-
- return cyttsp_suspend(ts);
-}
-
-static int cyttsp_i2c_resume(struct device *dev)
-{
- struct i2c_client *client = to_i2c_client(dev);
- struct cyttsp *ts = i2c_get_clientdata(client);
-
- return cyttsp_resume(ts);
-}
-#endif
-
-static SIMPLE_DEV_PM_OPS(cyttsp_i2c_pm, cyttsp_i2c_suspend, cyttsp_i2c_resume);
-
static const struct i2c_device_id cyttsp_i2c_id[] = {
{ CY_I2C_NAME, 0 },
{ }
@@ -137,7 +117,7 @@ static struct i2c_driver cyttsp_i2c_driver = {
.driver = {
.name = CY_I2C_NAME,
.owner = THIS_MODULE,
- .pm = &cyttsp_i2c_pm,
+ .pm = &cyttsp_pm_ops,
},
.probe = cyttsp_i2c_probe,
.remove = __devexit_p(cyttsp_i2c_remove),
diff --git a/drivers/input/touchscreen/cyttsp_spi.c b/drivers/input/touchscreen/cyttsp_spi.c
index eafa357..61a2e6c 100644
--- a/drivers/input/touchscreen/cyttsp_spi.c
+++ b/drivers/input/touchscreen/cyttsp_spi.c
@@ -215,29 +215,11 @@ static int __devexit cyttsp_spi_remove(struct spi_device *spi)
return 0;
}
-#ifdef CONFIG_PM_SLEEP
-static int cyttsp_spi_suspend(struct device *dev)
-{
- struct cyttsp *ts = dev_get_drvdata(dev);
-
- return cyttsp_suspend(ts);
-}
-
-static int cyttsp_spi_resume(struct device *dev)
-{
- struct cyttsp *ts = dev_get_drvdata(dev);
-
- return cyttsp_resume(ts);
-}
-#endif
-
-static SIMPLE_DEV_PM_OPS(cyttsp_spi_pm, cyttsp_spi_suspend, cyttsp_spi_resume);
-
static struct spi_driver cyttsp_spi_driver = {
.driver = {
.name = CY_SPI_NAME,
.owner = THIS_MODULE,
- .pm = &cyttsp_spi_pm,
+ .pm = &cyttsp_pm_ops,
},
.probe = cyttsp_spi_probe,
.remove = __devexit_p(cyttsp_spi_remove),
next prev parent reply other threads:[~2011-11-14 8:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-14 8:15 [PATCH 0/7] A few patches to cyttsp Dmitry Torokhov
2011-11-14 8:15 ` [PATCH 1/7] Input: cyttsp - move up into main touchscreen directory Dmitry Torokhov
2011-11-14 8:15 ` [PATCH 2/7] Input: cyttsp - rework Kconfig entries Dmitry Torokhov
2011-11-14 8:15 ` [PATCH 3/7] Input: cyttsp - guard PM methods with CONFIG_PM_SLEEP Dmitry Torokhov
2011-11-14 8:16 ` [PATCH 4/7] Input: cyttsp - device does not belong in bus structure Dmitry Torokhov
2011-11-14 8:16 ` [PATCH 5/7] Input: cyttsp - set up bus type in input device Dmitry Torokhov
2011-11-14 8:16 ` [PATCH 6/7] Input: cyttsp - use unified structure for ts object Dmitry Torokhov
2011-11-14 8:16 ` Dmitry Torokhov [this message]
2011-11-16 19:17 ` [PATCH 0/7] A few patches to cyttsp Javier Martinez Canillas
2011-11-16 19:38 ` Dmitry Torokhov
2011-11-16 20:17 ` Javier Martinez Canillas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111114081617.10141.41781.stgit@hammer.corenet.prv \
--to=dmitry.torokhov@gmail.com \
--cc=kev@cypress.com \
--cc=linux-input@vger.kernel.org \
--cc=martinez.javier@gmail.com \
--cc=mpallaka@codeaurora.org \
--cc=omaplinuxkernel@gmail.com \
--cc=rydberg@euromail.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).