mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-28 05:24:47 +08:00
i2c: brcmstb: Add support for atomic transfers
Add support for atomic transfers using polling mode with interrupts
intentionally disabled to get rid of the warning introduced by commit
63b96983a5
("i2c: core: introduce callbacks for atomic transfers")
during system reboot and power-off.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
This commit is contained in:
parent
8c56f9ef25
commit
c850ecfc89
@ -160,6 +160,7 @@ struct brcmstb_i2c_dev {
|
||||
struct completion done;
|
||||
u32 clk_freq_hz;
|
||||
int data_regsz;
|
||||
bool atomic;
|
||||
};
|
||||
|
||||
/* register accessors for both be and le cpu arch */
|
||||
@ -240,7 +241,7 @@ static int brcmstb_i2c_wait_for_completion(struct brcmstb_i2c_dev *dev)
|
||||
int ret = 0;
|
||||
unsigned long timeout = msecs_to_jiffies(I2C_TIMEOUT);
|
||||
|
||||
if (dev->irq >= 0) {
|
||||
if (dev->irq >= 0 && !dev->atomic) {
|
||||
if (!wait_for_completion_timeout(&dev->done, timeout))
|
||||
ret = -ETIMEDOUT;
|
||||
} else {
|
||||
@ -287,7 +288,7 @@ static int brcmstb_send_i2c_cmd(struct brcmstb_i2c_dev *dev,
|
||||
return rc;
|
||||
|
||||
/* only if we are in interrupt mode */
|
||||
if (dev->irq >= 0)
|
||||
if (dev->irq >= 0 && !dev->atomic)
|
||||
reinit_completion(&dev->done);
|
||||
|
||||
/* enable BSC CTL interrupt line */
|
||||
@ -520,6 +521,23 @@ out:
|
||||
|
||||
}
|
||||
|
||||
static int brcmstb_i2c_xfer_atomic(struct i2c_adapter *adapter,
|
||||
struct i2c_msg msgs[], int num)
|
||||
{
|
||||
struct brcmstb_i2c_dev *dev = i2c_get_adapdata(adapter);
|
||||
int ret;
|
||||
|
||||
if (dev->irq >= 0)
|
||||
disable_irq(dev->irq);
|
||||
dev->atomic = true;
|
||||
ret = brcmstb_i2c_xfer(adapter, msgs, num);
|
||||
dev->atomic = false;
|
||||
if (dev->irq >= 0)
|
||||
enable_irq(dev->irq);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static u32 brcmstb_i2c_functionality(struct i2c_adapter *adap)
|
||||
{
|
||||
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR
|
||||
@ -528,6 +546,7 @@ static u32 brcmstb_i2c_functionality(struct i2c_adapter *adap)
|
||||
|
||||
static const struct i2c_algorithm brcmstb_i2c_algo = {
|
||||
.master_xfer = brcmstb_i2c_xfer,
|
||||
.master_xfer_atomic = brcmstb_i2c_xfer_atomic,
|
||||
.functionality = brcmstb_i2c_functionality,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user