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