i2c-s3c2410: fix check for being in suspend.

As noted by Julia Lawall <julia@diku.dk>, we can never
trigger the check for being in suspend due to the result
of !readl(i2c->regs + S3C2410_IICCON) & S3C2410_IICCON_IRQEN
always being 0.

Add suspend/resume hooks to stop i2c transactions happening
until the driver has been resumed.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>

Ben Dooks be44f01e a804644a

+15 -3
+15 -3
drivers/i2c/busses/i2c-s3c2410.c
··· 56 struct s3c24xx_i2c { 57 spinlock_t lock; 58 wait_queue_head_t wait; 59 60 struct i2c_msg *msg; 61 unsigned int msg_num; ··· 508 unsigned long timeout; 509 int ret; 510 511 - if (!(readl(i2c->regs + S3C2410_IICCON) & S3C2410_IICCON_IRQEN)) 512 return -EIO; 513 514 ret = s3c24xx_i2c_set_master(i2c); ··· 987 } 988 989 #ifdef CONFIG_PM 990 static int s3c24xx_i2c_resume(struct platform_device *dev) 991 { 992 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev); 993 994 - if (i2c != NULL) 995 - s3c24xx_i2c_init(i2c); 996 997 return 0; 998 } 999 1000 #else 1001 #define s3c24xx_i2c_resume NULL 1002 #endif 1003 ··· 1015 static struct platform_driver s3c2410_i2c_driver = { 1016 .probe = s3c24xx_i2c_probe, 1017 .remove = s3c24xx_i2c_remove, 1018 .resume = s3c24xx_i2c_resume, 1019 .driver = { 1020 .owner = THIS_MODULE, ··· 1026 static struct platform_driver s3c2440_i2c_driver = { 1027 .probe = s3c24xx_i2c_probe, 1028 .remove = s3c24xx_i2c_remove, 1029 .resume = s3c24xx_i2c_resume, 1030 .driver = { 1031 .owner = THIS_MODULE,
··· 56 struct s3c24xx_i2c { 57 spinlock_t lock; 58 wait_queue_head_t wait; 59 + unsigned int suspended:1; 60 61 struct i2c_msg *msg; 62 unsigned int msg_num; ··· 507 unsigned long timeout; 508 int ret; 509 510 + if (i2c->suspended) 511 return -EIO; 512 513 ret = s3c24xx_i2c_set_master(i2c); ··· 986 } 987 988 #ifdef CONFIG_PM 989 + static int s3c24xx_i2c_suspend_late(struct platform_device *dev, 990 + pm_message_t msg) 991 + { 992 + struct s3c24xx_i2c *i2c = platform_get_drvdata(dev); 993 + i2c->suspended = 1; 994 + return 0; 995 + } 996 + 997 static int s3c24xx_i2c_resume(struct platform_device *dev) 998 { 999 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev); 1000 1001 + i2c->suspended = 0; 1002 + s3c24xx_i2c_init(i2c); 1003 1004 return 0; 1005 } 1006 1007 #else 1008 + #define s3c24xx_i2c_suspend_late NULL 1009 #define s3c24xx_i2c_resume NULL 1010 #endif 1011 ··· 1005 static struct platform_driver s3c2410_i2c_driver = { 1006 .probe = s3c24xx_i2c_probe, 1007 .remove = s3c24xx_i2c_remove, 1008 + .suspend_late = s3c24xx_i2c_suspend_late, 1009 .resume = s3c24xx_i2c_resume, 1010 .driver = { 1011 .owner = THIS_MODULE, ··· 1015 static struct platform_driver s3c2440_i2c_driver = { 1016 .probe = s3c24xx_i2c_probe, 1017 .remove = s3c24xx_i2c_remove, 1018 + .suspend_late = s3c24xx_i2c_suspend_late, 1019 .resume = s3c24xx_i2c_resume, 1020 .driver = { 1021 .owner = THIS_MODULE,