Commit 55dac3a5553b13891f0ae4bbd11920619b5436d4

Authored by Linus Torvalds

Merge branch 'i2c-fixes' of git://aeryn.fluff.org.uk/bjdooks/linux

* 'i2c-fixes' of git://aeryn.fluff.org.uk/bjdooks/linux:
  i2c-s3c2410: fix check for being in suspend.
  i2c-cpm: Detect and report NAK right away instead of timing out

Showing 2 changed files Side-by-side Diff

drivers/i2c/busses/i2c-cpm.c
... ... @@ -365,6 +365,7 @@
365 365 pmsg = &msgs[tptr];
366 366 if (pmsg->flags & I2C_M_RD)
367 367 ret = wait_event_interruptible_timeout(cpm->i2c_wait,
  368 + (in_be16(&tbdf[tptr].cbd_sc) & BD_SC_NAK) ||
368 369 !(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY),
369 370 1 * HZ);
370 371 else
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,