[{"id":1760496,"web_url":"http://patchwork.ozlabs.org/comment/1760496/","msgid":"<20170830211938.3m4xdwlfq5yozymq@valkosipuli.retiisi.org.uk>","list_archive_url":null,"date":"2017-08-30T21:19:38","subject":"Re: [PATCH v4 3/3] eeprom: at24: enable runtime pm support","submitter":{"id":1593,"url":"http://patchwork.ozlabs.org/api/people/1593/","name":"Sakari Ailus","email":"sakari.ailus@iki.fi"},"content":"Hi Divagar,\n\nThanks for the update.\n\nOn Wed, Aug 30, 2017 at 10:35:40PM +0530, Divagar Mohandass wrote:\n> Currently the device is kept in D0, there is an opportunity\n> to save power by enabling runtime pm.\n> \n> Device can be daisy chained from PMIC and we can't rely on I2C core\n> for auto resume/suspend. Driver will decide when to resume/suspend.\n> \n> Signed-off-by: Divagar Mohandass <divagar.mohandass@intel.com>\n> ---\n>  drivers/misc/eeprom/at24.c | 40 ++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 40 insertions(+)\n> \n> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c\n> index 2199c42..65a7d83 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,6 +770,14 @@ 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> +\terr = pm_runtime_set_active(&client->dev);\n> +\tif (err < 0)\n> +\t\tgoto err_clients;\n\nBtw. I don't think pm_runtime_set_active() can fail here. In other words\nit'd be fine to ignore the return value.\n\n> +\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> @@ -753,6 +788,8 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)\n>  \t\tgoto err_clients;\n\nI suppose the runtime PM state is re-initialised for a device when a driver\nis probed, but it'd still be nice to decrement the use count if this fails.\nYou should also disable PM runtime if probe fails and set the device\nsuspended again.\n\nSame for other error cases. I think you'll need a new label.\n\n>  \t}\n>  \n> +\tpm_runtime_put(&client->dev);\n> +\n>  \tat24->nvmem_config.name = dev_name(&client->dev);\n>  \tat24->nvmem_config.dev = &client->dev;\n>  \tat24->nvmem_config.read_only = !writable;\n> @@ -810,6 +847,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>","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 3xjJL85yrzz9sNw\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 07:19:44 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1750980AbdH3VTn (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tWed, 30 Aug 2017 17:19:43 -0400","from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:41750 \"EHLO\n\thillosipuli.retiisi.org.uk\" rhost-flags-OK-OK-OK-FAIL)\n\tby vger.kernel.org with ESMTP id S1750761AbdH3VTm (ORCPT\n\t<rfc822; linux-i2c@vger.kernel.org>); Wed, 30 Aug 2017 17:19:42 -0400","from valkosipuli.localdomain (valkosipuli.retiisi.org.uk\n\t[IPv6:2001:1bc8:1a6:d3d5::80:2])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby hillosipuli.retiisi.org.uk (Postfix) with ESMTPS id BB9C0600C8;\n\tThu, 31 Aug 2017 00:19:39 +0300 (EEST)","from sakke by valkosipuli.localdomain with local (Exim 4.89)\n\t(envelope-from <sakke@valkosipuli.retiisi.org.uk>)\n\tid 1dnAOh-0001XU-0s; Thu, 31 Aug 2017 00:19:39 +0300"],"Date":"Thu, 31 Aug 2017 00:19:38 +0300","From":"Sakari Ailus <sakari.ailus@iki.fi>","To":"Divagar Mohandass <divagar.mohandass@intel.com>","Cc":"robh+dt@kernel.org, mark.rutland@arm.com, wsa@the-dreams.de,\n\tdevicetree@vger.kernel.org, linux-i2c@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org, rajmohan.mani@intel.com","Subject":"Re: [PATCH v4 3/3] eeprom: at24: enable runtime pm support","Message-ID":"<20170830211938.3m4xdwlfq5yozymq@valkosipuli.retiisi.org.uk>","References":"<1504112740-14072-1-git-send-email-divagar.mohandass@intel.com>\n\t<1504112740-14072-4-git-send-email-divagar.mohandass@intel.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<1504112740-14072-4-git-send-email-divagar.mohandass@intel.com>","User-Agent":"NeoMutt/20170113 (1.7.2)","Sender":"linux-i2c-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-i2c.vger.kernel.org>","X-Mailing-List":"linux-i2c@vger.kernel.org"}},{"id":1760840,"web_url":"http://patchwork.ozlabs.org/comment/1760840/","msgid":"<7B8CE47BD58441468D2BB13285B50E6031DE6BFC@BGSMSX107.gar.corp.intel.com>","list_archive_url":null,"date":"2017-08-31T11:24:38","subject":"RE: [PATCH v4 3/3] eeprom: at24: enable runtime pm support","submitter":{"id":72054,"url":"http://patchwork.ozlabs.org/api/people/72054/","name":"Divagar Mohandass","email":"divagar.mohandass@intel.com"},"content":"Hi Sakari,\n\nThanks for the review.\nMy comments below.\n\n---\n^Divagar\n\n>-----Original Message-----\n>From: Sakari Ailus [mailto:sakari.ailus@iki.fi]\n>Sent: Thursday, August 31, 2017 2:50 AM\n>To: Mohandass, Divagar <divagar.mohandass@intel.com>\n>Cc: robh+dt@kernel.org; mark.rutland@arm.com; wsa@the-dreams.de;\n>devicetree@vger.kernel.org; linux-i2c@vger.kernel.org; linux-\n>kernel@vger.kernel.org; Mani, Rajmohan <rajmohan.mani@intel.com>\n>Subject: Re: [PATCH v4 3/3] eeprom: at24: enable runtime pm support\n>\n>Hi Divagar,\n>\n>Thanks for the update.\n>\n>On Wed, Aug 30, 2017 at 10:35:40PM +0530, Divagar Mohandass wrote:\n>> Currently the device is kept in D0, there is an opportunity to save\n>> power by enabling runtime pm.\n>>\n>> Device can be daisy chained from PMIC and we can't rely on I2C core\n>> for auto resume/suspend. Driver will decide when to resume/suspend.\n>>\n>> Signed-off-by: Divagar Mohandass <divagar.mohandass@intel.com>\n>> ---\n>>  drivers/misc/eeprom/at24.c | 40\n>> ++++++++++++++++++++++++++++++++++++++++\n>>  1 file changed, 40 insertions(+)\n>>\n>> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c\n>> index 2199c42..65a7d83 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\n>interchangeable.\n>> @@ -501,11 +502,21 @@ static ssize_t at24_eeprom_write_i2c(struct\n>> at24_data *at24, const char *buf,  static int at24_read(void *priv,\n>> unsigned int off, void *val, size_t count)  {\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,\n>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\n>> 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\n>> count)  {\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,\n>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\n>> 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,6 +770,14 @@ static int at24_probe(struct i2c_client *client,\n>> 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>> +\terr = pm_runtime_set_active(&client->dev);\n>> +\tif (err < 0)\n>> +\t\tgoto err_clients;\n>\n>Btw. I don't think pm_runtime_set_active() can fail here. In other words it'd be\n>fine to ignore the return value.\n>\n\nAck\n\n\n>> +\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>> @@ -753,6 +788,8 @@ static int at24_probe(struct i2c_client *client, const\n>struct i2c_device_id *id)\n>>  \t\tgoto err_clients;\n>\n>I suppose the runtime PM state is re-initialised for a device when a driver is\n>probed, but it'd still be nice to decrement the use count if this fails.\n\nAck\n\n>You should also disable PM runtime if probe fails and set the device\n>suspended again.\n>\n>Same for other error cases. I think you'll need a new label.\n>\n\nCan I disable PM runtime and set suspend in the 'err_clients' label itself ?\n\n>>  \t}\n>>\n>> +\tpm_runtime_put(&client->dev);\n>> +\n>>  \tat24->nvmem_config.name = dev_name(&client->dev);\n>>  \tat24->nvmem_config.dev = &client->dev;\n>>  \tat24->nvmem_config.read_only = !writable; @@ -810,6 +847,9 @@\n>static\n>> 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>\n>--\n>Regards,\n>\n>Sakari Ailus\n>e-mail: sakari.ailus@iki.fi","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 3xjg5C3nFrz9t1t\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 21:24:47 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1750928AbdHaLYp convert rfc822-to-8bit (ORCPT\n\t<rfc822;incoming@patchwork.ozlabs.org>);\n\tThu, 31 Aug 2017 07:24:45 -0400","from mga09.intel.com ([134.134.136.24]:17786 \"EHLO mga09.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1750828AbdHaLYo (ORCPT <rfc822;linux-i2c@vger.kernel.org>);\n\tThu, 31 Aug 2017 07:24:44 -0400","from orsmga002.jf.intel.com ([10.7.209.21])\n\tby orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t31 Aug 2017 04:24:43 -0700","from fmsmsx104.amr.corp.intel.com ([10.18.124.202])\n\tby orsmga002.jf.intel.com with ESMTP; 31 Aug 2017 04:24:42 -0700","from bgsmsx154.gar.corp.intel.com (10.224.48.47) by\n\tfmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP\n\tServer (TLS) id 14.3.319.2; Thu, 31 Aug 2017 04:24:42 -0700","from BGSMSX107.gar.corp.intel.com ([169.254.9.43]) by\n\tBGSMSX154.gar.corp.intel.com ([169.254.7.114]) with mapi id\n\t14.03.0319.002; Thu, 31 Aug 2017 16:54:39 +0530"],"X-ExtLoop1":"1","X-IronPort-AV":"E=Sophos;i=\"5.41,453,1498546800\"; d=\"scan'208\";a=\"130288452\"","From":"\"Mohandass, Divagar\" <divagar.mohandass@intel.com>","To":"Sakari Ailus <sakari.ailus@iki.fi>","CC":"\"robh+dt@kernel.org\" <robh+dt@kernel.org>,\n\t\"mark.rutland@arm.com\" <mark.rutland@arm.com>,\n\t\"wsa@the-dreams.de\" <wsa@the-dreams.de>,\n\t\"devicetree@vger.kernel.org\" <devicetree@vger.kernel.org>,\n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\t\"linux-kernel@vger.kernel.org\" <linux-kernel@vger.kernel.org>,\n\t\"Mani, Rajmohan\" <rajmohan.mani@intel.com>","Subject":"RE: [PATCH v4 3/3] eeprom: at24: enable runtime pm support","Thread-Topic":"[PATCH v4 3/3] eeprom: at24: enable runtime pm support","Thread-Index":"AQHTIbJFKrbse1a78EGs9xy2tFII6qKdC8cAgAFEx2A=","Date":"Thu, 31 Aug 2017 11:24:38 +0000","Message-ID":"<7B8CE47BD58441468D2BB13285B50E6031DE6BFC@BGSMSX107.gar.corp.intel.com>","References":"<1504112740-14072-1-git-send-email-divagar.mohandass@intel.com>\n\t<1504112740-14072-4-git-send-email-divagar.mohandass@intel.com>\n\t<20170830211938.3m4xdwlfq5yozymq@valkosipuli.retiisi.org.uk>","In-Reply-To":"<20170830211938.3m4xdwlfq5yozymq@valkosipuli.retiisi.org.uk>","Accept-Language":"en-US","Content-Language":"en-US","X-MS-Has-Attach":"","X-MS-TNEF-Correlator":"","dlp-product":"dlpe-windows","dlp-version":"11.0.0.116","dlp-reaction":"no-action","x-originating-ip":"[10.223.10.10]","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"8BIT","MIME-Version":"1.0","Sender":"linux-i2c-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-i2c.vger.kernel.org>","X-Mailing-List":"linux-i2c@vger.kernel.org"}},{"id":1761127,"web_url":"http://patchwork.ozlabs.org/comment/1761127/","msgid":"<20170831153702.eeilqwdxsoy4e3vt@valkosipuli.retiisi.org.uk>","list_archive_url":null,"date":"2017-08-31T15:37:02","subject":"Re: [PATCH v4 3/3] eeprom: at24: enable runtime pm support","submitter":{"id":1593,"url":"http://patchwork.ozlabs.org/api/people/1593/","name":"Sakari Ailus","email":"sakari.ailus@iki.fi"},"content":"On Thu, Aug 31, 2017 at 11:24:38AM +0000, Mohandass, Divagar wrote:\n> >> @@ -743,6 +770,14 @@ static int at24_probe(struct i2c_client *client,\n> >> 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> >> +\terr = pm_runtime_set_active(&client->dev);\n> >> +\tif (err < 0)\n> >> +\t\tgoto err_clients;\n> >\n> >Btw. I don't think pm_runtime_set_active() can fail here. In other words it'd be\n> >fine to ignore the return value.\n> >\n> \n> Ack\n> \n> \n> >> +\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> >> @@ -753,6 +788,8 @@ static int at24_probe(struct i2c_client *client, const\n> >struct i2c_device_id *id)\n> >>  \t\tgoto err_clients;\n> >\n> >I suppose the runtime PM state is re-initialised for a device when a driver is\n> >probed, but it'd still be nice to decrement the use count if this fails.\n> \n> Ack\n> \n> >You should also disable PM runtime if probe fails and set the device\n> >suspended again.\n> >\n> >Same for other error cases. I think you'll need a new label.\n> >\n> \n> Can I disable PM runtime and set suspend in the 'err_clients' label itself ?\n\nDisable, yes, but the get and put calls need to be balanced.","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 3xjmhQ1ZtJz9sD9\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 01:37:10 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751760AbdHaPhH (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tThu, 31 Aug 2017 11:37:07 -0400","from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:50920 \"EHLO\n\thillosipuli.retiisi.org.uk\" rhost-flags-OK-OK-OK-FAIL)\n\tby vger.kernel.org with ESMTP id S1751742AbdHaPhG (ORCPT\n\t<rfc822; linux-i2c@vger.kernel.org>); Thu, 31 Aug 2017 11:37:06 -0400","from valkosipuli.localdomain (valkosipuli.retiisi.org.uk\n\t[IPv6:2001:1bc8:1a6:d3d5::80:2])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby hillosipuli.retiisi.org.uk (Postfix) with ESMTPS id D4E7C600D8;\n\tThu, 31 Aug 2017 18:37:03 +0300 (EEST)","from sakke by valkosipuli.localdomain with local (Exim 4.89)\n\t(envelope-from <sakke@valkosipuli.retiisi.org.uk>)\n\tid 1dnRWh-0001gE-46; Thu, 31 Aug 2017 18:37:03 +0300"],"Date":"Thu, 31 Aug 2017 18:37:02 +0300","From":"Sakari Ailus <sakari.ailus@iki.fi>","To":"\"Mohandass, Divagar\" <divagar.mohandass@intel.com>","Cc":"\"robh+dt@kernel.org\" <robh+dt@kernel.org>,\n\t\"mark.rutland@arm.com\" <mark.rutland@arm.com>,\n\t\"wsa@the-dreams.de\" <wsa@the-dreams.de>,\n\t\"devicetree@vger.kernel.org\" <devicetree@vger.kernel.org>,\n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\t\"linux-kernel@vger.kernel.org\" <linux-kernel@vger.kernel.org>,\n\t\"Mani, Rajmohan\" <rajmohan.mani@intel.com>","Subject":"Re: [PATCH v4 3/3] eeprom: at24: enable runtime pm support","Message-ID":"<20170831153702.eeilqwdxsoy4e3vt@valkosipuli.retiisi.org.uk>","References":"<1504112740-14072-1-git-send-email-divagar.mohandass@intel.com>\n\t<1504112740-14072-4-git-send-email-divagar.mohandass@intel.com>\n\t<20170830211938.3m4xdwlfq5yozymq@valkosipuli.retiisi.org.uk>\n\t<7B8CE47BD58441468D2BB13285B50E6031DE6BFC@BGSMSX107.gar.corp.intel.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<7B8CE47BD58441468D2BB13285B50E6031DE6BFC@BGSMSX107.gar.corp.intel.com>","User-Agent":"NeoMutt/20170113 (1.7.2)","Sender":"linux-i2c-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-i2c.vger.kernel.org>","X-Mailing-List":"linux-i2c@vger.kernel.org"}},{"id":1761900,"web_url":"http://patchwork.ozlabs.org/comment/1761900/","msgid":"<7B8CE47BD58441468D2BB13285B50E6031DE74AB@BGSMSX107.gar.corp.intel.com>","list_archive_url":null,"date":"2017-09-01T18:26:47","subject":"RE: [PATCH v4 3/3] eeprom: at24: enable runtime pm support","submitter":{"id":72054,"url":"http://patchwork.ozlabs.org/api/people/72054/","name":"Divagar Mohandass","email":"divagar.mohandass@intel.com"},"content":"Hi Sakari,\n\nThanks for the review.\nMy comments below.\n\n---\n^Divagar\n\n>-----Original Message-----\n>From: Sakari Ailus [mailto:sakari.ailus@iki.fi]\n>Sent: Thursday, August 31, 2017 9:07 PM\n>To: Mohandass, Divagar <divagar.mohandass@intel.com>\n>Cc: robh+dt@kernel.org; mark.rutland@arm.com; wsa@the-dreams.de;\n>devicetree@vger.kernel.org; linux-i2c@vger.kernel.org; linux-\n>kernel@vger.kernel.org; Mani, Rajmohan <rajmohan.mani@intel.com>\n>Subject: Re: [PATCH v4 3/3] eeprom: at24: enable runtime pm support\n>\n>On Thu, Aug 31, 2017 at 11:24:38AM +0000, Mohandass, Divagar wrote:\n>> >> @@ -743,6 +770,14 @@ static int at24_probe(struct i2c_client\n>> >> *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>> >> +\terr = pm_runtime_set_active(&client->dev);\n>> >> +\tif (err < 0)\n>> >> +\t\tgoto err_clients;\n>> >\n>> >Btw. I don't think pm_runtime_set_active() can fail here. In other\n>> >words it'd be fine to ignore the return value.\n>> >\n>>\n>> Ack\n>>\n>>\n>> >> +\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>> >> @@ -753,6 +788,8 @@ static int at24_probe(struct i2c_client\n>> >> *client, const\n>> >struct i2c_device_id *id)\n>> >>  \t\tgoto err_clients;\n>> >\n>> >I suppose the runtime PM state is re-initialised for a device when a\n>> >driver is probed, but it'd still be nice to decrement the use count if this\n>fails.\n>>\n>> Ack\n>>\n>> >You should also disable PM runtime if probe fails and set the device\n>> >suspended again.\n>> >\n>> >Same for other error cases. I think you'll need a new label.\n>> >\n>>\n>> Can I disable PM runtime and set suspend in the 'err_clients' label itself ?\n>\n>Disable, yes, but the get and put calls need to be balanced.\n\nWe are performing pm_runtime_put after the first read check and in the error condition, so PM runtime disable alone should be sufficient in the 'err_clients' label.\nI think it is balanced, your comments ?\n\n>\n>--\n>Sakari Ailus\n>e-mail: sakari.ailus@iki.fi","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 3xkSQ42lnGz9sPk\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  2 Sep 2017 04:27:08 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752148AbdIAS0x convert rfc822-to-8bit (ORCPT\n\t<rfc822;incoming@patchwork.ozlabs.org>);\n\tFri, 1 Sep 2017 14:26:53 -0400","from mga05.intel.com ([192.55.52.43]:14939 \"EHLO mga05.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1750955AbdIAS0w (ORCPT <rfc822;linux-i2c@vger.kernel.org>);\n\tFri, 1 Sep 2017 14:26:52 -0400","from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga105.fm.intel.com with ESMTP; 01 Sep 2017 11:26:52 -0700","from fmsmsx107.amr.corp.intel.com ([10.18.124.205])\n\tby fmsmga002.fm.intel.com with ESMTP; 01 Sep 2017 11:26:52 -0700","from fmsmsx101.amr.corp.intel.com (10.18.124.199) by\n\tfmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP\n\tServer (TLS) id 14.3.319.2; Fri, 1 Sep 2017 11:26:51 -0700","from bgsmsx154.gar.corp.intel.com (10.224.48.47) by\n\tfmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP\n\tServer (TLS) id 14.3.319.2; Fri, 1 Sep 2017 11:26:51 -0700","from BGSMSX107.gar.corp.intel.com ([169.254.9.43]) by\n\tBGSMSX154.gar.corp.intel.com ([169.254.7.114]) with mapi id\n\t14.03.0319.002; Fri, 1 Sep 2017 23:56:47 +0530"],"X-ExtLoop1":"1","X-IronPort-AV":"E=Sophos;i=\"5.41,459,1498546800\"; d=\"scan'208\";a=\"1213572470\"","From":"\"Mohandass, Divagar\" <divagar.mohandass@intel.com>","To":"Sakari Ailus <sakari.ailus@iki.fi>","CC":"\"robh+dt@kernel.org\" <robh+dt@kernel.org>,\n\t\"mark.rutland@arm.com\" <mark.rutland@arm.com>,\n\t\"wsa@the-dreams.de\" <wsa@the-dreams.de>,\n\t\"devicetree@vger.kernel.org\" <devicetree@vger.kernel.org>,\n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\t\"linux-kernel@vger.kernel.org\" <linux-kernel@vger.kernel.org>,\n\t\"Mani, Rajmohan\" <rajmohan.mani@intel.com>","Subject":"RE: [PATCH v4 3/3] eeprom: at24: enable runtime pm support","Thread-Topic":"[PATCH v4 3/3] eeprom: at24: enable runtime pm support","Thread-Index":"AQHTIbJFKrbse1a78EGs9xy2tFII6qKdC8cAgAFEx2D//+3VAIABsqDw","Date":"Fri, 1 Sep 2017 18:26:47 +0000","Message-ID":"<7B8CE47BD58441468D2BB13285B50E6031DE74AB@BGSMSX107.gar.corp.intel.com>","References":"<1504112740-14072-1-git-send-email-divagar.mohandass@intel.com>\n\t<1504112740-14072-4-git-send-email-divagar.mohandass@intel.com>\n\t<20170830211938.3m4xdwlfq5yozymq@valkosipuli.retiisi.org.uk>\n\t<7B8CE47BD58441468D2BB13285B50E6031DE6BFC@BGSMSX107.gar.corp.intel.com>\n\t<20170831153702.eeilqwdxsoy4e3vt@valkosipuli.retiisi.org.uk>","In-Reply-To":"<20170831153702.eeilqwdxsoy4e3vt@valkosipuli.retiisi.org.uk>","Accept-Language":"en-US","Content-Language":"en-US","X-MS-Has-Attach":"","X-MS-TNEF-Correlator":"","dlp-product":"dlpe-windows","dlp-version":"11.0.0.116","dlp-reaction":"no-action","x-originating-ip":"[10.223.10.10]","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"8BIT","MIME-Version":"1.0","Sender":"linux-i2c-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-i2c.vger.kernel.org>","X-Mailing-List":"linux-i2c@vger.kernel.org"}}]