Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753156AbbBSANU (ORCPT ); Wed, 18 Feb 2015 19:13:20 -0500 Received: from smtp105.biz.mail.bf1.yahoo.com ([98.139.221.43]:39680 "EHLO smtp105.biz.mail.bf1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752323AbbBSANT (ORCPT ); Wed, 18 Feb 2015 19:13:19 -0500 X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: c5hyyFwVM1ncWSOgabJIIiqEI6nnKWu19sfMg7Smfw9vdsC TJU75YJa6OYG4BP1Tc4MwNqpPOZCdt.CMHPiNifYO3rJvWWN2kZ1OtfNXF5V hqKdMBRR.DxZh_mEDg6XCQ11Rrydu5niu0Dn0Wt5VjVAS_TF_SZNOOzVHY1B YlYOgRDBTKg6FP1r9kMu.uWem3aaHiUAGAX8LGicZ9Kt_o7u5x7GCafP4waT yOlheq2V_wF4cURMpXc_om4nTl4BrFJgMNKffy_ElHza.LW_qEGYqwmHwsly SzbLoAxfdhsA35lLIGBaPF.gJZKBV71HDPyYY1LbYtqwvkcUPf8hhr.H39aA mvPKFmDNuR7R8NKqV5eDc8hA5wNfV_IVuA9NbzgHq2ewxLGOkP8_56AMKCwM 7f7OAtBQXoyRE3OSvyDrJVROgB.eRfyPUb8G3UIgzikK3wGGaz11nuWYq.e3 5RpFuYOnLA_bsCX9hQCeLVAh42GlbX8jCHu4xetMvxI1a_1u8lfn5crPgLhu QxIM6OMzP7VERcdMAYb1ZxFY7rueOR2Sjgip5CKYFN7TF_wbmR8hxRRA- X-Yahoo-SMTP: oqiDtsaswBDv2aVUlxVTYPpATqA- From: Kevin Tsai To: Kevin Tsai , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V1 1/1] iio: light: Added PM support for Capella CM3232 ambient light sensor driver. Date: Wed, 18 Feb 2015 16:13:28 -0800 Message-Id: <1424304808-14666-1-git-send-email-ktsai@capellamicro.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2042 Lines: 73 Added Power Management Support. Signed-off-by: Kevin Tsai --- v1: Added Power Management support. drivers/iio/light/cm3232.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c index 90e3519..9e54ea7 100644 --- a/drivers/iio/light/cm3232.c +++ b/drivers/iio/light/cm3232.c @@ -378,6 +378,34 @@ static const struct i2c_device_id cm3232_id[] = { {} }; +static int cm3232_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct cm3232_chip *chip = iio_priv(indio_dev); + struct i2c_client *client = chip->client; + int ret; + + chip->regs_cmd |= CM3232_CMD_ALS_DISABLE; + ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD, + chip->regs_cmd); + + return ret; +} + +static int cm3232_resume(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct cm3232_chip *chip = iio_priv(indio_dev); + struct i2c_client *client = chip->client; + int ret; + + chip->regs_cmd &= ~CM3232_CMD_ALS_DISABLE; + ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD, + chip->regs_cmd | CM3232_CMD_ALS_RESET); + + return ret; +} + MODULE_DEVICE_TABLE(i2c, cm3232_id); static const struct of_device_id cm3232_of_match[] = { @@ -385,11 +413,15 @@ static const struct of_device_id cm3232_of_match[] = { {} }; +static const struct dev_pm_ops cm3232_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(cm3232_suspend, cm3232_resume)}; + static struct i2c_driver cm3232_driver = { .driver = { .name = "cm3232", .owner = THIS_MODULE, .of_match_table = of_match_ptr(cm3232_of_match), + .pm = &cm3232_pm_ops, }, .id_table = cm3232_id, .probe = cm3232_probe, -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/