Commit 55dac3a5 authored by Linus Torvalds's avatar 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
parents 0bc77ecb be44f01e
...@@ -365,6 +365,7 @@ static int cpm_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) ...@@ -365,6 +365,7 @@ static int cpm_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
pmsg = &msgs[tptr]; pmsg = &msgs[tptr];
if (pmsg->flags & I2C_M_RD) if (pmsg->flags & I2C_M_RD)
ret = wait_event_interruptible_timeout(cpm->i2c_wait, ret = wait_event_interruptible_timeout(cpm->i2c_wait,
(in_be16(&tbdf[tptr].cbd_sc) & BD_SC_NAK) ||
!(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY), !(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY),
1 * HZ); 1 * HZ);
else else
......
...@@ -56,6 +56,7 @@ enum s3c24xx_i2c_state { ...@@ -56,6 +56,7 @@ enum s3c24xx_i2c_state {
struct s3c24xx_i2c { struct s3c24xx_i2c {
spinlock_t lock; spinlock_t lock;
wait_queue_head_t wait; wait_queue_head_t wait;
unsigned int suspended:1;
struct i2c_msg *msg; struct i2c_msg *msg;
unsigned int msg_num; unsigned int msg_num;
...@@ -507,7 +508,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int ...@@ -507,7 +508,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int
unsigned long timeout; unsigned long timeout;
int ret; int ret;
if (!(readl(i2c->regs + S3C2410_IICCON) & S3C2410_IICCON_IRQEN)) if (i2c->suspended)
return -EIO; return -EIO;
ret = s3c24xx_i2c_set_master(i2c); ret = s3c24xx_i2c_set_master(i2c);
...@@ -986,17 +987,26 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev) ...@@ -986,17 +987,26 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int s3c24xx_i2c_suspend_late(struct platform_device *dev,
pm_message_t msg)
{
struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
i2c->suspended = 1;
return 0;
}
static int s3c24xx_i2c_resume(struct platform_device *dev) static int s3c24xx_i2c_resume(struct platform_device *dev)
{ {
struct s3c24xx_i2c *i2c = platform_get_drvdata(dev); struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
if (i2c != NULL) i2c->suspended = 0;
s3c24xx_i2c_init(i2c); s3c24xx_i2c_init(i2c);
return 0; return 0;
} }
#else #else
#define s3c24xx_i2c_suspend_late NULL
#define s3c24xx_i2c_resume NULL #define s3c24xx_i2c_resume NULL
#endif #endif
...@@ -1005,6 +1015,7 @@ static int s3c24xx_i2c_resume(struct platform_device *dev) ...@@ -1005,6 +1015,7 @@ static int s3c24xx_i2c_resume(struct platform_device *dev)
static struct platform_driver s3c2410_i2c_driver = { static struct platform_driver s3c2410_i2c_driver = {
.probe = s3c24xx_i2c_probe, .probe = s3c24xx_i2c_probe,
.remove = s3c24xx_i2c_remove, .remove = s3c24xx_i2c_remove,
.suspend_late = s3c24xx_i2c_suspend_late,
.resume = s3c24xx_i2c_resume, .resume = s3c24xx_i2c_resume,
.driver = { .driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
...@@ -1015,6 +1026,7 @@ static struct platform_driver s3c2410_i2c_driver = { ...@@ -1015,6 +1026,7 @@ static struct platform_driver s3c2410_i2c_driver = {
static struct platform_driver s3c2440_i2c_driver = { static struct platform_driver s3c2440_i2c_driver = {
.probe = s3c24xx_i2c_probe, .probe = s3c24xx_i2c_probe,
.remove = s3c24xx_i2c_remove, .remove = s3c24xx_i2c_remove,
.suspend_late = s3c24xx_i2c_suspend_late,
.resume = s3c24xx_i2c_resume, .resume = s3c24xx_i2c_resume,
.driver = { .driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment