Skip to content

Commit 187432b

Browse files
mszyprowwsakernel
authored andcommitted
i2c: s3c24xx: add support for atomic transfers
Add support for atomic transfers using polling mode with interrupts intentionally disabled to get rid of the following warning introduced by commit 63b9698 ("i2c: core: introduce callbacks for atomic transfers") during system reboot and power-off: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 1518 at drivers/i2c/i2c-core.h:40 i2c_transfer+0xe8/0xf4 No atomic I2C transfer handler for 'i2c-0' ... ---[ end trace 0000000000000000 ]--- Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Chanho Park <chanho61.park@samsung.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent 990489e commit 187432b

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

drivers/i2c/busses/i2c-s3c2410.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#define QUIRK_HDMIPHY (1 << 1)
7777
#define QUIRK_NO_GPIO (1 << 2)
7878
#define QUIRK_POLL (1 << 3)
79+
#define QUIRK_ATOMIC (1 << 4)
7980

8081
/* Max time to wait for bus to become idle after a xfer (in us) */
8182
#define S3C2410_IDLE_TIMEOUT 5000
@@ -174,7 +175,7 @@ static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret)
174175
if (ret)
175176
i2c->msg_idx = ret;
176177

177-
if (!(i2c->quirks & QUIRK_POLL))
178+
if (!(i2c->quirks & (QUIRK_POLL | QUIRK_ATOMIC)))
178179
wake_up(&i2c->wait);
179180
}
180181

@@ -703,7 +704,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
703704
s3c24xx_i2c_enable_irq(i2c);
704705
s3c24xx_i2c_message_start(i2c, msgs);
705706

706-
if (i2c->quirks & QUIRK_POLL) {
707+
if (i2c->quirks & (QUIRK_POLL | QUIRK_ATOMIC)) {
707708
while ((i2c->msg_num != 0) && is_ack(i2c)) {
708709
unsigned long stat = readl(i2c->regs + S3C2410_IICSTAT);
709710

@@ -775,6 +776,21 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
775776
return -EREMOTEIO;
776777
}
777778

779+
static int s3c24xx_i2c_xfer_atomic(struct i2c_adapter *adap,
780+
struct i2c_msg *msgs, int num)
781+
{
782+
struct s3c24xx_i2c *i2c = (struct s3c24xx_i2c *)adap->algo_data;
783+
int ret;
784+
785+
disable_irq(i2c->irq);
786+
i2c->quirks |= QUIRK_ATOMIC;
787+
ret = s3c24xx_i2c_xfer(adap, msgs, num);
788+
i2c->quirks &= ~QUIRK_ATOMIC;
789+
enable_irq(i2c->irq);
790+
791+
return ret;
792+
}
793+
778794
/* declare our i2c functionality */
779795
static u32 s3c24xx_i2c_func(struct i2c_adapter *adap)
780796
{
@@ -785,6 +801,7 @@ static u32 s3c24xx_i2c_func(struct i2c_adapter *adap)
785801
/* i2c bus registration info */
786802
static const struct i2c_algorithm s3c24xx_i2c_algorithm = {
787803
.master_xfer = s3c24xx_i2c_xfer,
804+
.master_xfer_atomic = s3c24xx_i2c_xfer_atomic,
788805
.functionality = s3c24xx_i2c_func,
789806
};
790807

0 commit comments

Comments
 (0)