Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/809591/?format=api
{ "id": 809591, "url": "http://patchwork.ozlabs.org/api/patches/809591/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/patch/1504520928-5191-4-git-send-email-divagar.mohandass@intel.com/", "project": { "id": 35, "url": "http://patchwork.ozlabs.org/api/projects/35/?format=api", "name": "Linux I2C development", "link_name": "linux-i2c", "list_id": "linux-i2c.vger.kernel.org", "list_email": "linux-i2c@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1504520928-5191-4-git-send-email-divagar.mohandass@intel.com>", "list_archive_url": null, "date": "2017-09-04T10:28:48", "name": "[v6,3/3] eeprom: at24: enable runtime pm support", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "9f8c3730333485512e946e9519bb870074b9ed8e", "submitter": { "id": 72054, "url": "http://patchwork.ozlabs.org/api/people/72054/?format=api", "name": "Divagar Mohandass", "email": "divagar.mohandass@intel.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-i2c/patch/1504520928-5191-4-git-send-email-divagar.mohandass@intel.com/mbox/", "series": [ { "id": 1350, "url": "http://patchwork.ozlabs.org/api/series/1350/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/list/?series=1350", "date": "2017-09-04T10:28:45", "name": "enable eeprom \"size\" property and runtime pm", "version": 6, "mbox": "http://patchwork.ozlabs.org/series/1350/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/809591/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/809591/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-i2c-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-i2c-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xm5fb3YSJz9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 4 Sep 2017 20:28:39 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753454AbdIDK2L (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tMon, 4 Sep 2017 06:28:11 -0400", "from mga06.intel.com ([134.134.136.31]:54653 \"EHLO mga06.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1753344AbdIDK2J (ORCPT <rfc822;linux-i2c@vger.kernel.org>);\n\tMon, 4 Sep 2017 06:28:09 -0400", "from orsmga005.jf.intel.com ([10.7.209.41])\n\tby orsmga104.jf.intel.com with ESMTP; 04 Sep 2017 03:28:09 -0700", "from div-optiplex-9010.iind.intel.com ([10.223.163.114])\n\tby orsmga005.jf.intel.com with ESMTP; 04 Sep 2017 03:28:06 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.41,474,1498546800\"; d=\"scan'208\";a=\"145246797\"", "From": "Divagar Mohandass <divagar.mohandass@intel.com>", "To": "robh+dt@kernel.org, mark.rutland@arm.com, wsa@the-dreams.de,\n\tsakari.ailus@iki.fi", "Cc": "devicetree@vger.kernel.org, linux-i2c@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org, rajmohan.mani@intel.com,\n\tDivagar Mohandass <divagar.mohandass@intel.com>", "Subject": "[PATCH v6 3/3] eeprom: at24: enable runtime pm support", "Date": "Mon, 4 Sep 2017 15:58:48 +0530", "Message-Id": "<1504520928-5191-4-git-send-email-divagar.mohandass@intel.com>", "X-Mailer": "git-send-email 1.9.1", "In-Reply-To": "<1504520928-5191-1-git-send-email-divagar.mohandass@intel.com>", "References": "<1504520928-5191-1-git-send-email-divagar.mohandass@intel.com>", "Sender": "linux-i2c-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-i2c.vger.kernel.org>", "X-Mailing-List": "linux-i2c@vger.kernel.org" }, "content": "Currently the device is kept in D0, there is an opportunity\nto save power by enabling runtime pm.\n\nDevice can be daisy chained from PMIC and we can't rely on I2C core\nfor auto resume/suspend. Driver will decide when to resume/suspend.\n\nSigned-off-by: Divagar Mohandass <divagar.mohandass@intel.com>\n---\n drivers/misc/eeprom/at24.c | 38 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 38 insertions(+)", "diff": "diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c\nindex 2199c42..d718a7a 100644\n--- a/drivers/misc/eeprom/at24.c\n+++ b/drivers/misc/eeprom/at24.c\n@@ -24,6 +24,7 @@\n #include <linux/i2c.h>\n #include <linux/nvmem-provider.h>\n #include <linux/platform_data/at24.h>\n+#include <linux/pm_runtime.h>\n \n /*\n * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable.\n@@ -501,11 +502,21 @@ static ssize_t at24_eeprom_write_i2c(struct at24_data *at24, const char *buf,\n static int at24_read(void *priv, unsigned int off, void *val, size_t count)\n {\n \tstruct at24_data *at24 = priv;\n+\tstruct i2c_client *client;\n \tchar *buf = val;\n+\tint ret;\n \n \tif (unlikely(!count))\n \t\treturn count;\n \n+\tclient = at24_translate_offset(at24, &off);\n+\n+\tret = pm_runtime_get_sync(&client->dev);\n+\tif (ret < 0) {\n+\t\tpm_runtime_put_noidle(&client->dev);\n+\t\treturn ret;\n+\t}\n+\n \t/*\n \t * Read data from chip, protecting against concurrent updates\n \t * from this host, but not from other I2C masters.\n@@ -518,6 +529,7 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)\n \t\tstatus = at24->read_func(at24, buf, off, count);\n \t\tif (status < 0) {\n \t\t\tmutex_unlock(&at24->lock);\n+\t\t\tpm_runtime_put(&client->dev);\n \t\t\treturn status;\n \t\t}\n \t\tbuf += status;\n@@ -527,17 +539,29 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)\n \n \tmutex_unlock(&at24->lock);\n \n+\tpm_runtime_put(&client->dev);\n+\n \treturn 0;\n }\n \n static int at24_write(void *priv, unsigned int off, void *val, size_t count)\n {\n \tstruct at24_data *at24 = priv;\n+\tstruct i2c_client *client;\n \tchar *buf = val;\n+\tint ret;\n \n \tif (unlikely(!count))\n \t\treturn -EINVAL;\n \n+\tclient = at24_translate_offset(at24, &off);\n+\n+\tret = pm_runtime_get_sync(&client->dev);\n+\tif (ret < 0) {\n+\t\tpm_runtime_put_noidle(&client->dev);\n+\t\treturn ret;\n+\t}\n+\n \t/*\n \t * Write data to chip, protecting against concurrent updates\n \t * from this host, but not from other I2C masters.\n@@ -550,6 +574,7 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)\n \t\tstatus = at24->write_func(at24, buf, off, count);\n \t\tif (status < 0) {\n \t\t\tmutex_unlock(&at24->lock);\n+\t\t\tpm_runtime_put(&client->dev);\n \t\t\treturn status;\n \t\t}\n \t\tbuf += status;\n@@ -559,6 +584,8 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)\n \n \tmutex_unlock(&at24->lock);\n \n+\tpm_runtime_put(&client->dev);\n+\n \treturn 0;\n }\n \n@@ -743,11 +770,17 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)\n \n \ti2c_set_clientdata(client, at24);\n \n+\t/* enable runtime pm */\n+\tpm_runtime_get_noresume(&client->dev);\n+\tpm_runtime_set_active(&client->dev);\n+\tpm_runtime_enable(&client->dev);\n+\n \t/*\n \t * Perform a one-byte test read to verify that the\n \t * chip is functional.\n \t */\n \terr = at24_read(at24, 0, &test_byte, 1);\n+\tpm_runtime_put(&client->dev);\n \tif (err) {\n \t\terr = -ENODEV;\n \t\tgoto err_clients;\n@@ -795,6 +828,8 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)\n \t\tif (at24->client[i])\n \t\t\ti2c_unregister_device(at24->client[i]);\n \n+\tpm_runtime_disable(&client->dev);\n+\n \treturn err;\n }\n \n@@ -810,6 +845,9 @@ static int at24_remove(struct i2c_client *client)\n \tfor (i = 1; i < at24->num_addresses; i++)\n \t\ti2c_unregister_device(at24->client[i]);\n \n+\tpm_runtime_disable(&client->dev);\n+\tpm_runtime_set_suspended(&client->dev);\n+\n \treturn 0;\n }\n \n", "prefixes": [ "v6", "3/3" ] }