i2c: tegra: Compile PM functions unconditionally
Dmitry Osipenko
reviewerPATCH 1/1 i2c: tegra: Compile PM functions unconditionally
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
--- drivers/i2c/busses/i2c-tegra.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/i2c/busses/i2c-tegra.c +5 -11
@@ -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, }, };
Signature · 1 line
2.22.0
Quoted 67 lines · Dmitry Osipenko
The I2C driver fails to probe if
CONFIG_PM_SLEEP=nbecause 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 <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)drivers/i2c/busses/i2c-tegra.c +4
-10@@ -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 = {
drivers/i2c/busses/i2c-tegra.c static const struct dev_pm_ops tegra_i2c_pm = { · line 1752
Quoted 10 lines
drivers/i2c/busses/i2c-tegra.c +1
-1.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.
Cheers
Jon
Signature · 1 line
nvpublic
Dmitry Osipenko
reviewer09.07.2019 13:12, Jon Hunter пишет:
Quoted 82 lines · Dmitry Osipenko
Quoted 67 lines
The I2C driver fails to probe if
CONFIG_PM_SLEEP=nbecause 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 <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)drivers/i2c/busses/i2c-tegra.c +4
-10@@ -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 = {drivers/i2c/busses/i2c-tegra.c static const struct dev_pm_ops tegra_i2c_pm = { · line 1752
Quoted 10 lines
drivers/i2c/busses/i2c-tegra.c +1
-1.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.
Quoted 1 line
Acked-by Jon Hunter <[email protected]>
Thanks!
Wolfram Sang
AppliedQuoted 6 lines · Dmitry Osipenko
The I2C driver fails to probe if
CONFIG_PM_SLEEP=nbecause 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.
Quoted 6 lines
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 <[email protected]>
Applied to for-next, thanks!