diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2010-08-05 11:50:00 +0530 |
---|---|---|
committer | Gary King <gking@nvidia.com> | 2010-08-13 17:33:13 -0700 |
commit | b16a29319c1f1d1ae54774f7f574dfc5622f6ab2 (patch) | |
tree | f0c4564605f85c0234817461ef91c9e2e6b60325 | |
parent | 2cbe7eb3ee06d2b6336f92f9fd5b8afe95b1b091 (diff) |
[driver/mm_ak8975]: Adding suspend/resume functions.
For the power managementi functionality for the device magnetometer ak8975,
added the power suspend and resume functions.
Change-Id: I40bc799d77dcbcc419200d9a6b6622415b520246
Reviewed-on: http://git-master/r/4790
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Tested-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Gary King <gking@nvidia.com>
-rw-r--r-- | drivers/hwmon/mm_ak8975.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/hwmon/mm_ak8975.c b/drivers/hwmon/mm_ak8975.c index 79bc497a30ca..601033716bd7 100644 --- a/drivers/hwmon/mm_ak8975.c +++ b/drivers/hwmon/mm_ak8975.c @@ -92,6 +92,8 @@ struct mm_ak8975_data { static int mm_ak8975_probe(struct i2c_client *client, const struct i2c_device_id *id); static int mm_ak8975_remove(struct i2c_client *client); +static int mm_ak8975_suspend(struct i2c_client *client, pm_message_t mesg); +static int mm_ak8975_resume(struct i2c_client *client); static const struct i2c_device_id mm_ak8975_id[] = { {"mm_ak8975", 0}, @@ -107,6 +109,8 @@ static struct i2c_driver mm_ak8975_driver = { }, .probe = mm_ak8975_probe, .remove = mm_ak8975_remove, + .resume = mm_ak8975_resume, + .suspend = mm_ak8975_suspend, .id_table = mm_ak8975_id, }; @@ -462,6 +466,45 @@ static int mm_ak8975_remove(struct i2c_client *client) return 0; } +static int mm_ak8975_suspend(struct i2c_client *client, pm_message_t mesg) +{ + struct mm_ak8975_data *data = i2c_get_clientdata(client); + bool status; + + dev_dbg(&client->dev, "%s()\n", __func__); + + mutex_lock(&data->lock); + status = ak8975_write_data(client, AK_8975_REG_ADD_CNTL, + 0x0, REG_CNTL_MODE_MASK, + REG_CNTL_MODE_SHIFT); + if (!status) { + dev_err(&client->dev, "Error in setting fuse access mode\n"); + mutex_unlock(&data->lock); + return -EBUSY; + } + mutex_unlock(&data->lock); + return 0; +} +static int mm_ak8975_resume(struct i2c_client *client) +{ + struct mm_ak8975_data *data = i2c_get_clientdata(client); + bool status; + + dev_dbg(&client->dev, "%s()\n", __func__); + + mutex_lock(&data->lock); + status = ak8975_write_data(client, AK_8975_REG_ADD_CNTL, + data->mode, REG_CNTL_MODE_MASK, + REG_CNTL_MODE_SHIFT); + if (!status) { + dev_err(&client->dev, "Error in setting fuse access mode\n"); + mutex_unlock(&data->lock); + return -EBUSY; + } + mutex_unlock(&data->lock); + return 0; +} + static int __init mm_ak8975_init(void) { pr_info("%s()\n", __func__); |