linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] i2c: tegra: Compile PM functions unconditionally
@ 2019-07-07 23:12 Dmitry Osipenko
  2019-07-09 10:12 ` Jon Hunter
  2019-08-01 12:45 ` Wolfram Sang
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Osipenko @ 2019-07-07 23:12 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Laxman Dewangan, Wolfram Sang
  Cc: linux-i2c, linux-tegra, linux-kernel

The I2C driver fails to probe if CONFIG_PM_SLEEP=n because runtime PM
doesn't depend on the PM sleep and in this case the runtime PM ops are
not included in the driver, resulting in I2C clock not being enabled.
It's much cleaner to simply allow compiler to remove the dead code
instead of messing with the #ifdefs.

This patch fixes such errors when CONFIG_PM_SLEEP=n:

  tegra-i2c 7000c400.i2c: timeout waiting for fifo flush
  tegra-i2c 7000c400.i2c: Failed to initialize i2c controller

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/i2c/busses/i2c-tegra.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 9fcb13beeb8f..18f0ceed9f1b 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -636,7 +636,7 @@ static void tegra_dvc_init(struct tegra_i2c_dev *i2c_dev)
 	dvc_writel(i2c_dev, val, DVC_CTRL_REG1);
 }
 
-static int tegra_i2c_runtime_resume(struct device *dev)
+static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev)
 {
 	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
 	int ret;
@@ -665,7 +665,7 @@ static int tegra_i2c_runtime_resume(struct device *dev)
 	return 0;
 }
 
-static int tegra_i2c_runtime_suspend(struct device *dev)
+static int __maybe_unused tegra_i2c_runtime_suspend(struct device *dev)
 {
 	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
 
@@ -1711,8 +1711,7 @@ static int tegra_i2c_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int tegra_i2c_suspend(struct device *dev)
+static int __maybe_unused tegra_i2c_suspend(struct device *dev)
 {
 	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
 
@@ -1721,7 +1720,7 @@ static int tegra_i2c_suspend(struct device *dev)
 	return 0;
 }
 
-static int tegra_i2c_resume(struct device *dev)
+static int __maybe_unused tegra_i2c_resume(struct device *dev)
 {
 	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
 	int err;
@@ -1741,18 +1740,13 @@ static const struct dev_pm_ops tegra_i2c_pm = {
 			   NULL)
 };
 
-#define TEGRA_I2C_PM	(&tegra_i2c_pm)
-#else
-#define TEGRA_I2C_PM	NULL
-#endif
-
 static struct platform_driver tegra_i2c_driver = {
 	.probe   = tegra_i2c_probe,
 	.remove  = tegra_i2c_remove,
 	.driver  = {
 		.name  = "tegra-i2c",
 		.of_match_table = tegra_i2c_of_match,
-		.pm    = TEGRA_I2C_PM,
+		.pm    = &tegra_i2c_pm,
 	},
 };
 
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] i2c: tegra: Compile PM functions unconditionally
  2019-07-07 23:12 [PATCH v1] i2c: tegra: Compile PM functions unconditionally Dmitry Osipenko
@ 2019-07-09 10:12 ` Jon Hunter
  2019-07-09 21:03   ` Dmitry Osipenko
  2019-08-01 12:45 ` Wolfram Sang
  1 sibling, 1 reply; 4+ messages in thread
From: Jon Hunter @ 2019-07-09 10:12 UTC (permalink / raw)
  To: Dmitry Osipenko, Thierry Reding, Laxman Dewangan, Wolfram Sang
  Cc: linux-i2c, linux-tegra, linux-kernel


On 08/07/2019 00:12, Dmitry Osipenko wrote:
> The I2C driver fails to probe if CONFIG_PM_SLEEP=n because runtime PM
> doesn't depend on the PM sleep and in this case the runtime PM ops are
> not included in the driver, resulting in I2C clock not being enabled.
> It's much cleaner to simply allow compiler to remove the dead code
> instead of messing with the #ifdefs.
> 
> This patch fixes such errors when CONFIG_PM_SLEEP=n:
> 
>   tegra-i2c 7000c400.i2c: timeout waiting for fifo flush
>   tegra-i2c 7000c400.i2c: Failed to initialize i2c controller
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/i2c/busses/i2c-tegra.c | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
> index 9fcb13beeb8f..18f0ceed9f1b 100644
> --- a/drivers/i2c/busses/i2c-tegra.c
> +++ b/drivers/i2c/busses/i2c-tegra.c
> @@ -636,7 +636,7 @@ static void tegra_dvc_init(struct tegra_i2c_dev *i2c_dev)
>  	dvc_writel(i2c_dev, val, DVC_CTRL_REG1);
>  }
>  
> -static int tegra_i2c_runtime_resume(struct device *dev)
> +static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev)
>  {
>  	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
>  	int ret;
> @@ -665,7 +665,7 @@ static int tegra_i2c_runtime_resume(struct device *dev)
>  	return 0;
>  }
>  
> -static int tegra_i2c_runtime_suspend(struct device *dev)
> +static int __maybe_unused tegra_i2c_runtime_suspend(struct device *dev)
>  {
>  	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
>  
> @@ -1711,8 +1711,7 @@ static int tegra_i2c_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_PM_SLEEP
> -static int tegra_i2c_suspend(struct device *dev)
> +static int __maybe_unused tegra_i2c_suspend(struct device *dev)
>  {
>  	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
>  
> @@ -1721,7 +1720,7 @@ static int tegra_i2c_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int tegra_i2c_resume(struct device *dev)
> +static int __maybe_unused tegra_i2c_resume(struct device *dev)
>  {
>  	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
>  	int err;
> @@ -1741,18 +1740,13 @@ static const struct dev_pm_ops tegra_i2c_pm = {
>  			   NULL)
>  };
>  
> -#define TEGRA_I2C_PM	(&tegra_i2c_pm)
> -#else
> -#define TEGRA_I2C_PM	NULL
> -#endif
> -
>  static struct platform_driver tegra_i2c_driver = {
>  	.probe   = tegra_i2c_probe,
>  	.remove  = tegra_i2c_remove,
>  	.driver  = {
>  		.name  = "tegra-i2c",
>  		.of_match_table = tegra_i2c_of_match,
> -		.pm    = TEGRA_I2C_PM,
> +		.pm    = &tegra_i2c_pm,
>  	},
>  };
>  

Looks good to me.

Acked-by: Jon Hunter <jonathanh@nvidia.com>

Cheers
Jon

-- 
nvpublic

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] i2c: tegra: Compile PM functions unconditionally
  2019-07-09 10:12 ` Jon Hunter
@ 2019-07-09 21:03   ` Dmitry Osipenko
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Osipenko @ 2019-07-09 21:03 UTC (permalink / raw)
  To: Jon Hunter, Thierry Reding, Laxman Dewangan, Wolfram Sang
  Cc: linux-i2c, linux-tegra, linux-kernel

09.07.2019 13:12, Jon Hunter пишет:
> 
> On 08/07/2019 00:12, Dmitry Osipenko wrote:
>> The I2C driver fails to probe if CONFIG_PM_SLEEP=n because runtime PM
>> doesn't depend on the PM sleep and in this case the runtime PM ops are
>> not included in the driver, resulting in I2C clock not being enabled.
>> It's much cleaner to simply allow compiler to remove the dead code
>> instead of messing with the #ifdefs.
>>
>> This patch fixes such errors when CONFIG_PM_SLEEP=n:
>>
>>   tegra-i2c 7000c400.i2c: timeout waiting for fifo flush
>>   tegra-i2c 7000c400.i2c: Failed to initialize i2c controller
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/i2c/busses/i2c-tegra.c | 16 +++++-----------
>>  1 file changed, 5 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
>> index 9fcb13beeb8f..18f0ceed9f1b 100644
>> --- a/drivers/i2c/busses/i2c-tegra.c
>> +++ b/drivers/i2c/busses/i2c-tegra.c
>> @@ -636,7 +636,7 @@ static void tegra_dvc_init(struct tegra_i2c_dev *i2c_dev)
>>  	dvc_writel(i2c_dev, val, DVC_CTRL_REG1);
>>  }
>>  
>> -static int tegra_i2c_runtime_resume(struct device *dev)
>> +static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev)
>>  {
>>  	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
>>  	int ret;
>> @@ -665,7 +665,7 @@ static int tegra_i2c_runtime_resume(struct device *dev)
>>  	return 0;
>>  }
>>  
>> -static int tegra_i2c_runtime_suspend(struct device *dev)
>> +static int __maybe_unused tegra_i2c_runtime_suspend(struct device *dev)
>>  {
>>  	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
>>  
>> @@ -1711,8 +1711,7 @@ static int tegra_i2c_remove(struct platform_device *pdev)
>>  	return 0;
>>  }
>>  
>> -#ifdef CONFIG_PM_SLEEP
>> -static int tegra_i2c_suspend(struct device *dev)
>> +static int __maybe_unused tegra_i2c_suspend(struct device *dev)
>>  {
>>  	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
>>  
>> @@ -1721,7 +1720,7 @@ static int tegra_i2c_suspend(struct device *dev)
>>  	return 0;
>>  }
>>  
>> -static int tegra_i2c_resume(struct device *dev)
>> +static int __maybe_unused tegra_i2c_resume(struct device *dev)
>>  {
>>  	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
>>  	int err;
>> @@ -1741,18 +1740,13 @@ static const struct dev_pm_ops tegra_i2c_pm = {
>>  			   NULL)
>>  };
>>  
>> -#define TEGRA_I2C_PM	(&tegra_i2c_pm)
>> -#else
>> -#define TEGRA_I2C_PM	NULL
>> -#endif
>> -
>>  static struct platform_driver tegra_i2c_driver = {
>>  	.probe   = tegra_i2c_probe,
>>  	.remove  = tegra_i2c_remove,
>>  	.driver  = {
>>  		.name  = "tegra-i2c",
>>  		.of_match_table = tegra_i2c_of_match,
>> -		.pm    = TEGRA_I2C_PM,
>> +		.pm    = &tegra_i2c_pm,
>>  	},
>>  };
>>  
> 
> Looks good to me.
> 
> Acked-by: Jon Hunter <jonathanh@nvidia.com>

Thanks!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] i2c: tegra: Compile PM functions unconditionally
  2019-07-07 23:12 [PATCH v1] i2c: tegra: Compile PM functions unconditionally Dmitry Osipenko
  2019-07-09 10:12 ` Jon Hunter
@ 2019-08-01 12:45 ` Wolfram Sang
  1 sibling, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2019-08-01 12:45 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Thierry Reding, Jonathan Hunter, Laxman Dewangan, linux-i2c,
	linux-tegra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 676 bytes --]

On Mon, Jul 08, 2019 at 02:12:34AM +0300, Dmitry Osipenko wrote:
> The I2C driver fails to probe if CONFIG_PM_SLEEP=n because runtime PM
> doesn't depend on the PM sleep and in this case the runtime PM ops are
> not included in the driver, resulting in I2C clock not being enabled.
> It's much cleaner to simply allow compiler to remove the dead code
> instead of messing with the #ifdefs.
> 
> This patch fixes such errors when CONFIG_PM_SLEEP=n:
> 
>   tegra-i2c 7000c400.i2c: timeout waiting for fifo flush
>   tegra-i2c 7000c400.i2c: Failed to initialize i2c controller
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-01 12:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-07 23:12 [PATCH v1] i2c: tegra: Compile PM functions unconditionally Dmitry Osipenko
2019-07-09 10:12 ` Jon Hunter
2019-07-09 21:03   ` Dmitry Osipenko
2019-08-01 12:45 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).