>From 0ff431b48f7f2d08bbf299265c67589a598ec5d4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 24 Dec 2018 22:00:31 +0100 Subject: [PATCH] FIXUP: i2c: reject new transfers when adapters are suspended Signed-off-by: Hans de Goede --- drivers/i2c/i2c-core-base.c | 2 +- drivers/i2c/i2c-core-smbus.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 3ce238b782f3..e2fae7ec6c95 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1865,7 +1865,7 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) if (WARN_ON(!msgs || num < 1)) return -EINVAL; - if (WARN(device_is_suspended(adap->dev.parent), + if (WARN(adap->dev.parent && device_is_suspended(adap->dev.parent), "Accessing already suspended I2C/SMBus adapter")) return -ESHUTDOWN; diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c index e0f7f22feabd..1376620ae204 100644 --- a/drivers/i2c/i2c-core-smbus.c +++ b/drivers/i2c/i2c-core-smbus.c @@ -547,7 +547,8 @@ s32 __i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, int try; s32 res; - if (WARN(device_is_suspended(adapter->dev.parent), + if (WARN(adapter->dev.parent && + device_is_suspended(adapter->dev.parent), "Accessing already suspended I2C/SMBus adapter")) return -ESHUTDOWN; -- 2.20.1