i2c: use dev_get_drvdata() to get private data in suspend/resume hooks

Several drivers call to_platform_device() to get platform_device
and pass it to platform_get_drvdata().  In platform_get_drvdata(),
the platform_device is converted back to struct device again.

Use dev_get_drvdata() to avoid platform_device/device dance.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> (for DesignWare only)
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit is contained in:
Masahiro Yamada 2017-07-28 01:16:24 +09:00 коммит произвёл Wolfram Sang
Родитель f2326401b8
Коммит 9242e72aae
13 изменённых файлов: 24 добавлений и 48 удалений

Просмотреть файл

@ -510,8 +510,7 @@ static int bcm_iproc_i2c_remove(struct platform_device *pdev)
static int bcm_iproc_i2c_suspend(struct device *dev) static int bcm_iproc_i2c_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct bcm_iproc_i2c_dev *iproc_i2c = dev_get_drvdata(dev);
struct bcm_iproc_i2c_dev *iproc_i2c = platform_get_drvdata(pdev);
/* make sure there's no pending interrupt when we go into suspend */ /* make sure there's no pending interrupt when we go into suspend */
writel(0, iproc_i2c->base + IE_OFFSET); writel(0, iproc_i2c->base + IE_OFFSET);
@ -526,8 +525,7 @@ static int bcm_iproc_i2c_suspend(struct device *dev)
static int bcm_iproc_i2c_resume(struct device *dev) static int bcm_iproc_i2c_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct bcm_iproc_i2c_dev *iproc_i2c = dev_get_drvdata(dev);
struct bcm_iproc_i2c_dev *iproc_i2c = platform_get_drvdata(pdev);
int ret; int ret;
u32 val; u32 val;

Просмотреть файл

@ -826,8 +826,7 @@ static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long
*/ */
static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev) static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct cdns_i2c *xi2c = dev_get_drvdata(dev);
struct cdns_i2c *xi2c = platform_get_drvdata(pdev);
clk_disable(xi2c->clk); clk_disable(xi2c->clk);
@ -844,8 +843,7 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
*/ */
static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev) static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct cdns_i2c *xi2c = dev_get_drvdata(dev);
struct cdns_i2c *xi2c = platform_get_drvdata(pdev);
int ret; int ret;
ret = clk_enable(xi2c->clk); ret = clk_enable(xi2c->clk);

Просмотреть файл

@ -876,8 +876,7 @@ static int davinci_i2c_remove(struct platform_device *pdev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int davinci_i2c_suspend(struct device *dev) static int davinci_i2c_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct davinci_i2c_dev *i2c_dev = dev_get_drvdata(dev);
struct davinci_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
/* put I2C into reset */ /* put I2C into reset */
davinci_i2c_reset_ctrl(i2c_dev, 0); davinci_i2c_reset_ctrl(i2c_dev, 0);
@ -888,8 +887,7 @@ static int davinci_i2c_suspend(struct device *dev)
static int davinci_i2c_resume(struct device *dev) static int davinci_i2c_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct davinci_i2c_dev *i2c_dev = dev_get_drvdata(dev);
struct davinci_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
clk_prepare_enable(i2c_dev->clk); clk_prepare_enable(i2c_dev->clk);
/* take I2C out of reset */ /* take I2C out of reset */

Просмотреть файл

@ -428,8 +428,7 @@ static void dw_i2c_plat_complete(struct device *dev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int dw_i2c_plat_suspend(struct device *dev) static int dw_i2c_plat_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
i_dev->disable(i_dev); i_dev->disable(i_dev);
i2c_dw_plat_prepare_clk(i_dev, false); i2c_dw_plat_prepare_clk(i_dev, false);
@ -439,8 +438,7 @@ static int dw_i2c_plat_suspend(struct device *dev)
static int dw_i2c_plat_resume(struct device *dev) static int dw_i2c_plat_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
i2c_dw_plat_prepare_clk(i_dev, true); i2c_dw_plat_prepare_clk(i_dev, true);
i_dev->init(i_dev); i_dev->init(i_dev);

Просмотреть файл

@ -803,8 +803,7 @@ static int exynos5_i2c_remove(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int exynos5_i2c_suspend_noirq(struct device *dev) static int exynos5_i2c_suspend_noirq(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct exynos5_i2c *i2c = dev_get_drvdata(dev);
struct exynos5_i2c *i2c = platform_get_drvdata(pdev);
i2c->suspended = 1; i2c->suspended = 1;
@ -815,8 +814,7 @@ static int exynos5_i2c_suspend_noirq(struct device *dev)
static int exynos5_i2c_resume_noirq(struct device *dev) static int exynos5_i2c_resume_noirq(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct exynos5_i2c *i2c = dev_get_drvdata(dev);
struct exynos5_i2c *i2c = platform_get_drvdata(pdev);
int ret = 0; int ret = 0;
ret = clk_prepare_enable(i2c->clk); ret = clk_prepare_enable(i2c->clk);

Просмотреть файл

@ -505,8 +505,7 @@ static int hix5hd2_i2c_remove(struct platform_device *pdev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int hix5hd2_i2c_runtime_suspend(struct device *dev) static int hix5hd2_i2c_runtime_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct hix5hd2_i2c_priv *priv = dev_get_drvdata(dev);
struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev);
clk_disable_unprepare(priv->clk); clk_disable_unprepare(priv->clk);
@ -515,8 +514,7 @@ static int hix5hd2_i2c_runtime_suspend(struct device *dev)
static int hix5hd2_i2c_runtime_resume(struct device *dev) static int hix5hd2_i2c_runtime_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct hix5hd2_i2c_priv *priv = dev_get_drvdata(dev);
struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev);
clk_prepare_enable(priv->clk); clk_prepare_enable(priv->clk);
hix5hd2_i2c_init(priv); hix5hd2_i2c_init(priv);

Просмотреть файл

@ -457,8 +457,7 @@ static int i2c_lpc2k_remove(struct platform_device *dev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int i2c_lpc2k_suspend(struct device *dev) static int i2c_lpc2k_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct lpc2k_i2c *i2c = dev_get_drvdata(dev);
struct lpc2k_i2c *i2c = platform_get_drvdata(pdev);
clk_disable(i2c->clk); clk_disable(i2c->clk);
@ -467,8 +466,7 @@ static int i2c_lpc2k_suspend(struct device *dev)
static int i2c_lpc2k_resume(struct device *dev) static int i2c_lpc2k_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct lpc2k_i2c *i2c = dev_get_drvdata(dev);
struct lpc2k_i2c *i2c = platform_get_drvdata(pdev);
clk_enable(i2c->clk); clk_enable(i2c->clk);
i2c_lpc2k_reset(i2c); i2c_lpc2k_reset(i2c);

Просмотреть файл

@ -975,8 +975,7 @@ mv64xxx_i2c_remove(struct platform_device *dev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int mv64xxx_i2c_resume(struct device *dev) static int mv64xxx_i2c_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct mv64xxx_i2c_data *drv_data = dev_get_drvdata(dev);
struct mv64xxx_i2c_data *drv_data = platform_get_drvdata(pdev);
mv64xxx_i2c_hw_init(drv_data); mv64xxx_i2c_hw_init(drv_data);

Просмотреть файл

@ -1346,8 +1346,7 @@ static int i2c_pxa_remove(struct platform_device *dev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int i2c_pxa_suspend_noirq(struct device *dev) static int i2c_pxa_suspend_noirq(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct pxa_i2c *i2c = dev_get_drvdata(dev);
struct pxa_i2c *i2c = platform_get_drvdata(pdev);
clk_disable(i2c->clk); clk_disable(i2c->clk);
@ -1356,8 +1355,7 @@ static int i2c_pxa_suspend_noirq(struct device *dev)
static int i2c_pxa_resume_noirq(struct device *dev) static int i2c_pxa_resume_noirq(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct pxa_i2c *i2c = dev_get_drvdata(dev);
struct pxa_i2c *i2c = platform_get_drvdata(pdev);
clk_enable(i2c->clk); clk_enable(i2c->clk);
i2c_pxa_reset(i2c); i2c_pxa_reset(i2c);

Просмотреть файл

@ -1246,8 +1246,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int s3c24xx_i2c_suspend_noirq(struct device *dev) static int s3c24xx_i2c_suspend_noirq(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct s3c24xx_i2c *i2c = dev_get_drvdata(dev);
struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
i2c->suspended = 1; i2c->suspended = 1;
@ -1259,8 +1258,7 @@ static int s3c24xx_i2c_suspend_noirq(struct device *dev)
static int s3c24xx_i2c_resume_noirq(struct device *dev) static int s3c24xx_i2c_resume_noirq(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct s3c24xx_i2c *i2c = dev_get_drvdata(dev);
struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
int ret; int ret;
if (!IS_ERR(i2c->sysreg)) if (!IS_ERR(i2c->sysreg))

Просмотреть файл

@ -421,8 +421,7 @@ static int i2c_sirfsoc_remove(struct platform_device *pdev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int i2c_sirfsoc_suspend(struct device *dev) static int i2c_sirfsoc_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct i2c_adapter *adapter = dev_get_drvdata(dev);
struct i2c_adapter *adapter = platform_get_drvdata(pdev);
struct sirfsoc_i2c *siic = adapter->algo_data; struct sirfsoc_i2c *siic = adapter->algo_data;
clk_enable(siic->clk); clk_enable(siic->clk);
@ -434,8 +433,7 @@ static int i2c_sirfsoc_suspend(struct device *dev)
static int i2c_sirfsoc_resume(struct device *dev) static int i2c_sirfsoc_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct i2c_adapter *adapter = dev_get_drvdata(dev);
struct i2c_adapter *adapter = platform_get_drvdata(pdev);
struct sirfsoc_i2c *siic = adapter->algo_data; struct sirfsoc_i2c *siic = adapter->algo_data;
clk_enable(siic->clk); clk_enable(siic->clk);

Просмотреть файл

@ -745,8 +745,7 @@ static int st_i2c_xfer(struct i2c_adapter *i2c_adap,
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int st_i2c_suspend(struct device *dev) static int st_i2c_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct st_i2c_dev *i2c_dev = dev_get_drvdata(dev);
struct st_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
if (i2c_dev->busy) if (i2c_dev->busy)
return -EBUSY; return -EBUSY;

Просмотреть файл

@ -853,8 +853,7 @@ MODULE_DEVICE_TABLE(of, xiic_of_match);
static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev) static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct xiic_i2c *i2c = dev_get_drvdata(dev);
struct xiic_i2c *i2c = platform_get_drvdata(pdev);
clk_disable(i2c->clk); clk_disable(i2c->clk);
@ -863,8 +862,7 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev) static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct xiic_i2c *i2c = dev_get_drvdata(dev);
struct xiic_i2c *i2c = platform_get_drvdata(pdev);
int ret; int ret;
ret = clk_enable(i2c->clk); ret = clk_enable(i2c->clk);