[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1432268380-7302-3-git-send-email-ktsai@capellamicro.com>
Date: Thu, 21 May 2015 21:19:37 -0700
From: Kevin Tsai <ktsai@...ellamicro.com>
To: Kevin Tsai <ktsai@...ellamicro.com>,
Rob Herring <robh+dt@...nel.org>,
Pawel Moll <pawel.moll@....com>,
Mark Rutland <mark.rutland@....com>,
Ian Campbell <ijc+devicetree@...lion.org.uk>,
Kumar Gala <galak@...eaurora.org>,
Jonathan Cameron <jic23@...nel.org>,
Hartmut Knaack <knaack.h@....de>,
Lars-Peter Clausen <lars@...afoo.de>,
Peter Meerwald <pmeerw@...erw.net>,
Andrew Morton <akpm@...ux-foundation.org>,
Greg KH <gregkh@...uxfoundation.org>,
"David S. Miller" <davem@...emloft.net>,
Mauro Carvalho Chehab <mchehab@....samsung.com>,
Arnd Bergmann <arnd@...db.de>, Joe Perches <joe@...ches.com>,
Jingoo Han <jingoohan1@...il.com>,
Daniel Baluta <daniel.baluta@...el.com>,
Roberta Dobrescu <roberta.dobrescu@...il.com>,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@...ux.intel.com>
Cc: devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-iio@...r.kernel.org
Subject: [PATCH 3/6] iio: light: Updated Vishay Capella cm32181 ambient light sensor driver.
- Added Power Management support.
- Added driver remove routine.
Signed-off-by: Kevin Tsai <ktsai@...ellamicro.com>
---
drivers/iio/light/cm32181.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
index 6b11145..9bc3e1f 100644
--- a/drivers/iio/light/cm32181.c
+++ b/drivers/iio/light/cm32181.c
@@ -370,11 +370,51 @@ static int cm32181_probe(struct i2c_client *client,
return 0;
}
+static int cm32181_remove(struct i2c_client *client)
+{
+ i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD,
+ CM32181_CMD_ALS_DISABLE);
+
+ return 0;
+}
+
static const struct i2c_device_id cm32181_id[] = {
{ "cm32181", 0 },
{ }
};
+#ifdef CONFIG_PM_SLEEP
+static int cm32181_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct cm32181_chip *chip = iio_priv(indio_dev);
+ struct i2c_client *client = chip->client;
+ int ret;
+
+ ret = i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD,
+ CM32181_CMD_ALS_DISABLE);
+
+ return ret;
+}
+
+static int cm32181_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct cm32181_chip *chip = iio_priv(indio_dev);
+ struct i2c_client *client = chip->client;
+ int ret;
+
+ chip->conf_regs[CM32181_REG_ADDR_CMD] &= ~CM32181_CMD_ALS_DISABLE;
+ ret = i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD,
+ chip->conf_regs[CM32181_REG_ADDR_CMD]);
+
+ return ret;
+}
+
+static const struct dev_pm_ops cm32181_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(cm32181_suspend, cm32181_resume)};
+#endif
+
MODULE_DEVICE_TABLE(i2c, cm32181_id);
static const struct of_device_id cm32181_of_match[] = {
@@ -387,9 +427,13 @@ static struct i2c_driver cm32181_driver = {
.name = "cm32181",
.of_match_table = of_match_ptr(cm32181_of_match),
.owner = THIS_MODULE,
+#ifdef CONFIG_PM_SLEEP
+ .pm = &cm32181_pm_ops,
+#endif
},
.id_table = cm32181_id,
.probe = cm32181_probe,
+ .remove = cm32181_remove,
};
module_i2c_driver(cm32181_driver);
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists