Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Masahiro Yamada and committed by
Wolfram Sang
9242e72a f2326401

+24 -48
+2 -4
drivers/i2c/busses/i2c-bcm-iproc.c
··· 510 510 511 511 static int bcm_iproc_i2c_suspend(struct device *dev) 512 512 { 513 - struct platform_device *pdev = to_platform_device(dev); 514 - struct bcm_iproc_i2c_dev *iproc_i2c = platform_get_drvdata(pdev); 513 + struct bcm_iproc_i2c_dev *iproc_i2c = dev_get_drvdata(dev); 515 514 516 515 /* make sure there's no pending interrupt when we go into suspend */ 517 516 writel(0, iproc_i2c->base + IE_OFFSET); ··· 525 526 526 527 static int bcm_iproc_i2c_resume(struct device *dev) 527 528 { 528 - struct platform_device *pdev = to_platform_device(dev); 529 - struct bcm_iproc_i2c_dev *iproc_i2c = platform_get_drvdata(pdev); 529 + struct bcm_iproc_i2c_dev *iproc_i2c = dev_get_drvdata(dev); 530 530 int ret; 531 531 u32 val; 532 532
+2 -4
drivers/i2c/busses/i2c-cadence.c
··· 826 826 */ 827 827 static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev) 828 828 { 829 - struct platform_device *pdev = to_platform_device(dev); 830 - struct cdns_i2c *xi2c = platform_get_drvdata(pdev); 829 + struct cdns_i2c *xi2c = dev_get_drvdata(dev); 831 830 832 831 clk_disable(xi2c->clk); 833 832 ··· 843 844 */ 844 845 static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev) 845 846 { 846 - struct platform_device *pdev = to_platform_device(dev); 847 - struct cdns_i2c *xi2c = platform_get_drvdata(pdev); 847 + struct cdns_i2c *xi2c = dev_get_drvdata(dev); 848 848 int ret; 849 849 850 850 ret = clk_enable(xi2c->clk);
+2 -4
drivers/i2c/busses/i2c-davinci.c
··· 876 876 #ifdef CONFIG_PM 877 877 static int davinci_i2c_suspend(struct device *dev) 878 878 { 879 - struct platform_device *pdev = to_platform_device(dev); 880 - struct davinci_i2c_dev *i2c_dev = platform_get_drvdata(pdev); 879 + struct davinci_i2c_dev *i2c_dev = dev_get_drvdata(dev); 881 880 882 881 /* put I2C into reset */ 883 882 davinci_i2c_reset_ctrl(i2c_dev, 0); ··· 887 888 888 889 static int davinci_i2c_resume(struct device *dev) 889 890 { 890 - struct platform_device *pdev = to_platform_device(dev); 891 - struct davinci_i2c_dev *i2c_dev = platform_get_drvdata(pdev); 891 + struct davinci_i2c_dev *i2c_dev = dev_get_drvdata(dev); 892 892 893 893 clk_prepare_enable(i2c_dev->clk); 894 894 /* take I2C out of reset */
+2 -4
drivers/i2c/busses/i2c-designware-platdrv.c
··· 428 428 #ifdef CONFIG_PM 429 429 static int dw_i2c_plat_suspend(struct device *dev) 430 430 { 431 - struct platform_device *pdev = to_platform_device(dev); 432 - struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); 431 + struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 433 432 434 433 i_dev->disable(i_dev); 435 434 i2c_dw_plat_prepare_clk(i_dev, false); ··· 438 439 439 440 static int dw_i2c_plat_resume(struct device *dev) 440 441 { 441 - struct platform_device *pdev = to_platform_device(dev); 442 - struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); 442 + struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 443 443 444 444 i2c_dw_plat_prepare_clk(i_dev, true); 445 445 i_dev->init(i_dev);
+2 -4
drivers/i2c/busses/i2c-exynos5.c
··· 803 803 #ifdef CONFIG_PM_SLEEP 804 804 static int exynos5_i2c_suspend_noirq(struct device *dev) 805 805 { 806 - struct platform_device *pdev = to_platform_device(dev); 807 - struct exynos5_i2c *i2c = platform_get_drvdata(pdev); 806 + struct exynos5_i2c *i2c = dev_get_drvdata(dev); 808 807 809 808 i2c->suspended = 1; 810 809 ··· 814 815 815 816 static int exynos5_i2c_resume_noirq(struct device *dev) 816 817 { 817 - struct platform_device *pdev = to_platform_device(dev); 818 - struct exynos5_i2c *i2c = platform_get_drvdata(pdev); 818 + struct exynos5_i2c *i2c = dev_get_drvdata(dev); 819 819 int ret = 0; 820 820 821 821 ret = clk_prepare_enable(i2c->clk);
+2 -4
drivers/i2c/busses/i2c-hix5hd2.c
··· 505 505 #ifdef CONFIG_PM 506 506 static int hix5hd2_i2c_runtime_suspend(struct device *dev) 507 507 { 508 - struct platform_device *pdev = to_platform_device(dev); 509 - struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev); 508 + struct hix5hd2_i2c_priv *priv = dev_get_drvdata(dev); 510 509 511 510 clk_disable_unprepare(priv->clk); 512 511 ··· 514 515 515 516 static int hix5hd2_i2c_runtime_resume(struct device *dev) 516 517 { 517 - struct platform_device *pdev = to_platform_device(dev); 518 - struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev); 518 + struct hix5hd2_i2c_priv *priv = dev_get_drvdata(dev); 519 519 520 520 clk_prepare_enable(priv->clk); 521 521 hix5hd2_i2c_init(priv);
+2 -4
drivers/i2c/busses/i2c-lpc2k.c
··· 457 457 #ifdef CONFIG_PM 458 458 static int i2c_lpc2k_suspend(struct device *dev) 459 459 { 460 - struct platform_device *pdev = to_platform_device(dev); 461 - struct lpc2k_i2c *i2c = platform_get_drvdata(pdev); 460 + struct lpc2k_i2c *i2c = dev_get_drvdata(dev); 462 461 463 462 clk_disable(i2c->clk); 464 463 ··· 466 467 467 468 static int i2c_lpc2k_resume(struct device *dev) 468 469 { 469 - struct platform_device *pdev = to_platform_device(dev); 470 - struct lpc2k_i2c *i2c = platform_get_drvdata(pdev); 470 + struct lpc2k_i2c *i2c = dev_get_drvdata(dev); 471 471 472 472 clk_enable(i2c->clk); 473 473 i2c_lpc2k_reset(i2c);
+1 -2
drivers/i2c/busses/i2c-mv64xxx.c
··· 975 975 #ifdef CONFIG_PM 976 976 static int mv64xxx_i2c_resume(struct device *dev) 977 977 { 978 - struct platform_device *pdev = to_platform_device(dev); 979 - struct mv64xxx_i2c_data *drv_data = platform_get_drvdata(pdev); 978 + struct mv64xxx_i2c_data *drv_data = dev_get_drvdata(dev); 980 979 981 980 mv64xxx_i2c_hw_init(drv_data); 982 981
+2 -4
drivers/i2c/busses/i2c-pxa.c
··· 1346 1346 #ifdef CONFIG_PM 1347 1347 static int i2c_pxa_suspend_noirq(struct device *dev) 1348 1348 { 1349 - struct platform_device *pdev = to_platform_device(dev); 1350 - struct pxa_i2c *i2c = platform_get_drvdata(pdev); 1349 + struct pxa_i2c *i2c = dev_get_drvdata(dev); 1351 1350 1352 1351 clk_disable(i2c->clk); 1353 1352 ··· 1355 1356 1356 1357 static int i2c_pxa_resume_noirq(struct device *dev) 1357 1358 { 1358 - struct platform_device *pdev = to_platform_device(dev); 1359 - struct pxa_i2c *i2c = platform_get_drvdata(pdev); 1359 + struct pxa_i2c *i2c = dev_get_drvdata(dev); 1360 1360 1361 1361 clk_enable(i2c->clk); 1362 1362 i2c_pxa_reset(i2c);
+2 -4
drivers/i2c/busses/i2c-s3c2410.c
··· 1246 1246 #ifdef CONFIG_PM_SLEEP 1247 1247 static int s3c24xx_i2c_suspend_noirq(struct device *dev) 1248 1248 { 1249 - struct platform_device *pdev = to_platform_device(dev); 1250 - struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); 1249 + struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); 1251 1250 1252 1251 i2c->suspended = 1; 1253 1252 ··· 1258 1259 1259 1260 static int s3c24xx_i2c_resume_noirq(struct device *dev) 1260 1261 { 1261 - struct platform_device *pdev = to_platform_device(dev); 1262 - struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); 1262 + struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); 1263 1263 int ret; 1264 1264 1265 1265 if (!IS_ERR(i2c->sysreg))
+2 -4
drivers/i2c/busses/i2c-sirf.c
··· 421 421 #ifdef CONFIG_PM 422 422 static int i2c_sirfsoc_suspend(struct device *dev) 423 423 { 424 - struct platform_device *pdev = to_platform_device(dev); 425 - struct i2c_adapter *adapter = platform_get_drvdata(pdev); 424 + struct i2c_adapter *adapter = dev_get_drvdata(dev); 426 425 struct sirfsoc_i2c *siic = adapter->algo_data; 427 426 428 427 clk_enable(siic->clk); ··· 433 434 434 435 static int i2c_sirfsoc_resume(struct device *dev) 435 436 { 436 - struct platform_device *pdev = to_platform_device(dev); 437 - struct i2c_adapter *adapter = platform_get_drvdata(pdev); 437 + struct i2c_adapter *adapter = dev_get_drvdata(dev); 438 438 struct sirfsoc_i2c *siic = adapter->algo_data; 439 439 440 440 clk_enable(siic->clk);
+1 -2
drivers/i2c/busses/i2c-st.c
··· 745 745 #ifdef CONFIG_PM_SLEEP 746 746 static int st_i2c_suspend(struct device *dev) 747 747 { 748 - struct platform_device *pdev = to_platform_device(dev); 749 - struct st_i2c_dev *i2c_dev = platform_get_drvdata(pdev); 748 + struct st_i2c_dev *i2c_dev = dev_get_drvdata(dev); 750 749 751 750 if (i2c_dev->busy) 752 751 return -EBUSY;
+2 -4
drivers/i2c/busses/i2c-xiic.c
··· 853 853 854 854 static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev) 855 855 { 856 - struct platform_device *pdev = to_platform_device(dev); 857 - struct xiic_i2c *i2c = platform_get_drvdata(pdev); 856 + struct xiic_i2c *i2c = dev_get_drvdata(dev); 858 857 859 858 clk_disable(i2c->clk); 860 859 ··· 862 863 863 864 static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev) 864 865 { 865 - struct platform_device *pdev = to_platform_device(dev); 866 - struct xiic_i2c *i2c = platform_get_drvdata(pdev); 866 + struct xiic_i2c *i2c = dev_get_drvdata(dev); 867 867 int ret; 868 868 869 869 ret = clk_enable(i2c->clk);