Skip to content

Commit 55dac3a

Browse files
committed
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
2 parents 0bc77ec + be44f01 commit 55dac3a

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

drivers/i2c/busses/i2c-cpm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ static int cpm_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
365365
pmsg = &msgs[tptr];
366366
if (pmsg->flags & I2C_M_RD)
367367
ret = wait_event_interruptible_timeout(cpm->i2c_wait,
368+
(in_be16(&tbdf[tptr].cbd_sc) & BD_SC_NAK) ||
368369
!(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY),
369370
1 * HZ);
370371
else

drivers/i2c/busses/i2c-s3c2410.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ enum s3c24xx_i2c_state {
5656
struct s3c24xx_i2c {
5757
spinlock_t lock;
5858
wait_queue_head_t wait;
59+
unsigned int suspended:1;
5960

6061
struct i2c_msg *msg;
6162
unsigned int msg_num;
@@ -507,7 +508,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int
507508
unsigned long timeout;
508509
int ret;
509510

510-
if (!(readl(i2c->regs + S3C2410_IICCON) & S3C2410_IICCON_IRQEN))
511+
if (i2c->suspended)
511512
return -EIO;
512513

513514
ret = s3c24xx_i2c_set_master(i2c);
@@ -986,17 +987,26 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
986987
}
987988

988989
#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+
989998
static int s3c24xx_i2c_resume(struct platform_device *dev)
990999
{
9911000
struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
9921001

993-
if (i2c != NULL)
994-
s3c24xx_i2c_init(i2c);
1002+
i2c->suspended = 0;
1003+
s3c24xx_i2c_init(i2c);
9951004

9961005
return 0;
9971006
}
9981007

9991008
#else
1009+
#define s3c24xx_i2c_suspend_late NULL
10001010
#define s3c24xx_i2c_resume NULL
10011011
#endif
10021012

@@ -1005,6 +1015,7 @@ static int s3c24xx_i2c_resume(struct platform_device *dev)
10051015
static struct platform_driver s3c2410_i2c_driver = {
10061016
.probe = s3c24xx_i2c_probe,
10071017
.remove = s3c24xx_i2c_remove,
1018+
.suspend_late = s3c24xx_i2c_suspend_late,
10081019
.resume = s3c24xx_i2c_resume,
10091020
.driver = {
10101021
.owner = THIS_MODULE,
@@ -1015,6 +1026,7 @@ static struct platform_driver s3c2410_i2c_driver = {
10151026
static struct platform_driver s3c2440_i2c_driver = {
10161027
.probe = s3c24xx_i2c_probe,
10171028
.remove = s3c24xx_i2c_remove,
1029+
.suspend_late = s3c24xx_i2c_suspend_late,
10181030
.resume = s3c24xx_i2c_resume,
10191031
.driver = {
10201032
.owner = THIS_MODULE,

0 commit comments

Comments
 (0)