Commit be44f01e8af3862767f466f89c12640a2f2b0038

Authored by Ben Dooks
1 parent a804644a1a

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>

Showing 1 changed file with 15 additions and 3 deletions Side-by-side Diff

drivers/i2c/busses/i2c-s3c2410.c
... ... @@ -56,6 +56,7 @@
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;
... ... @@ -507,7 +508,7 @@
507 508 unsigned long timeout;
508 509 int ret;
509 510  
510   - if (!(readl(i2c->regs + S3C2410_IICCON) & S3C2410_IICCON_IRQEN))
  511 + if (i2c->suspended)
511 512 return -EIO;
512 513  
513 514 ret = s3c24xx_i2c_set_master(i2c);
514 515  
515 516  
... ... @@ -986,17 +987,26 @@
986 987 }
987 988  
988 989 #ifdef CONFIG_PM
  990 +static int s3c24xx_i2c_suspend_late(struct platform_device *dev,
  991 + pm_message_t msg)
  992 +{
  993 + struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
  994 + i2c->suspended = 1;
  995 + return 0;
  996 +}
  997 +
989 998 static int s3c24xx_i2c_resume(struct platform_device *dev)
990 999 {
991 1000 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
992 1001  
993   - if (i2c != NULL)
994   - s3c24xx_i2c_init(i2c);
  1002 + i2c->suspended = 0;
  1003 + s3c24xx_i2c_init(i2c);
995 1004  
996 1005 return 0;
997 1006 }
998 1007  
999 1008 #else
  1009 +#define s3c24xx_i2c_suspend_late NULL
1000 1010 #define s3c24xx_i2c_resume NULL
1001 1011 #endif
1002 1012  
... ... @@ -1005,6 +1015,7 @@
1005 1015 static struct platform_driver s3c2410_i2c_driver = {
1006 1016 .probe = s3c24xx_i2c_probe,
1007 1017 .remove = s3c24xx_i2c_remove,
  1018 + .suspend_late = s3c24xx_i2c_suspend_late,
1008 1019 .resume = s3c24xx_i2c_resume,
1009 1020 .driver = {
1010 1021 .owner = THIS_MODULE,
... ... @@ -1015,6 +1026,7 @@
1015 1026 static struct platform_driver s3c2440_i2c_driver = {
1016 1027 .probe = s3c24xx_i2c_probe,
1017 1028 .remove = s3c24xx_i2c_remove,
  1029 + .suspend_late = s3c24xx_i2c_suspend_late,
1018 1030 .resume = s3c24xx_i2c_resume,
1019 1031 .driver = {
1020 1032 .owner = THIS_MODULE,