Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756129AbbEVAcM (ORCPT ); Thu, 21 May 2015 20:32:12 -0400 Received: from smtp107.biz.mail.bf1.yahoo.com ([98.139.244.55]:33474 "EHLO smtp107.biz.mail.bf1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755670AbbEVAcB (ORCPT ); Thu, 21 May 2015 20:32:01 -0400 X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 6dnFgWUVM1mh4qYKxCTNGH2_Idn8hPiKxP6WvHZReXp6lBr lRFtC1KGC31cxLKUNDODvK4eXngHsRWEs6GZUdAQp6sCa62SvTbbaNpkq0ei qE_w3w3dcqxvPYd9B8MtJdz2mMHig.M4EMNLAcIgiMvhPwOzdXgmbj3BGK_f IXkrzSzBE88FOebw3rAUVGd4nlpse9sg5rNhC51Fzb_ts2vWjJbO1DByzd6M eYvCxzZ88jx_PhiRLFvrqJLxGbThUunnnYgRJpM3A_ZMK9stlUUtey5S5d6w 4f16k4I6Zkoy95poTbEvHnHoL1YRJ20ANTFM7pKtb8sm22AMa8HBAk7_Mqij SzKHV0puZJzr4ONrNeCFWTaDCs6mB7ALacnSTNfSZ8fJylTfTF002eEAig.N 10ImsVsN3RgxxCXSxzu3Uzxnc38do.RK_LExEZ5WlY7oUoxLvQx1Un6crq38 vos7oraGsnxW5TWsDbrS0IeRoPZPhHKTsxJJgvxNzgm2FnbvgP2VEC2hDfSz rEfckby4Z.qG0ntNaO9IV X-Yahoo-SMTP: oqiDtsaswBDv2aVUlxVTYPpATqA- From: Kevin Tsai To: Kevin Tsai , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , Andrew Morton , Greg KH , "David S. Miller" , Mauro Carvalho Chehab , Arnd Bergmann , Joe Perches , Jingoo Han , Daniel Baluta , Roberta Dobrescu , Kuppuswamy Sathyanarayanan Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Subject: [PATCH 3/6] iio: light: Updated Vishay Capella cm32181 ambient light sensor driver. - Added Power Management support. - Added driver remove routine. Date: Thu, 21 May 2015 17:30:42 -0700 Message-Id: <1432254645-5349-3-git-send-email-ktsai@capellamicro.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1432254645-5349-1-git-send-email-ktsai@capellamicro.com> References: <1432254645-5349-1-git-send-email-ktsai@capellamicro.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2362 Lines: 86 Signed-off-by: Kevin Tsai --- Added Power Management support. Added remove routine. 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/