Commit a9eb186e authored by Joseph Lo's avatar Joseph Lo Committed by Lee Jones

mfd: cros_ec: Prevent data transfer while device is suspended

The cros_ec driver is still active while the device is suspended.
Besides that, it also tries to transfer data even after the I2C host had
been suspended. This patch uses a simple flag to prevent this.
Signed-off-by: default avatarJoseph Lo <josephl@nvidia.com>
Signed-off-by: default avatarThierry Escande <thierry.escande@collabora.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 0f174769
...@@ -165,6 +165,7 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev) ...@@ -165,6 +165,7 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev)
disable_irq(ec_dev->irq); disable_irq(ec_dev->irq);
ec_dev->was_wake_device = ec_dev->wake_enabled; ec_dev->was_wake_device = ec_dev->wake_enabled;
ec_dev->suspended = true;
return 0; return 0;
} }
...@@ -179,6 +180,7 @@ static void cros_ec_drain_events(struct cros_ec_device *ec_dev) ...@@ -179,6 +180,7 @@ static void cros_ec_drain_events(struct cros_ec_device *ec_dev)
int cros_ec_resume(struct cros_ec_device *ec_dev) int cros_ec_resume(struct cros_ec_device *ec_dev)
{ {
ec_dev->suspended = false;
enable_irq(ec_dev->irq); enable_irq(ec_dev->irq);
/* /*
......
...@@ -447,6 +447,11 @@ static int get_next_event(struct cros_ec_device *ec_dev) ...@@ -447,6 +447,11 @@ static int get_next_event(struct cros_ec_device *ec_dev)
struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; struct cros_ec_command *msg = (struct cros_ec_command *)&buffer;
int ret; int ret;
if (ec_dev->suspended) {
dev_dbg(ec_dev->dev, "Device suspended.\n");
return -EHOSTDOWN;
}
msg->version = 0; msg->version = 0;
msg->command = EC_CMD_GET_NEXT_EVENT; msg->command = EC_CMD_GET_NEXT_EVENT;
msg->insize = sizeof(ec_dev->event_data); msg->insize = sizeof(ec_dev->event_data);
......
...@@ -103,6 +103,7 @@ struct cros_ec_command { ...@@ -103,6 +103,7 @@ struct cros_ec_command {
* @din_size: size of din buffer to allocate (zero to use static din) * @din_size: size of din buffer to allocate (zero to use static din)
* @dout_size: size of dout buffer to allocate (zero to use static dout) * @dout_size: size of dout buffer to allocate (zero to use static dout)
* @wake_enabled: true if this device can wake the system from sleep * @wake_enabled: true if this device can wake the system from sleep
* @suspended: true if this device had been suspended
* @cmd_xfer: send command to EC and get response * @cmd_xfer: send command to EC and get response
* Returns the number of bytes received if the communication succeeded, but * Returns the number of bytes received if the communication succeeded, but
* that doesn't mean the EC was happy with the command. The caller * that doesn't mean the EC was happy with the command. The caller
...@@ -136,6 +137,7 @@ struct cros_ec_device { ...@@ -136,6 +137,7 @@ struct cros_ec_device {
int din_size; int din_size;
int dout_size; int dout_size;
bool wake_enabled; bool wake_enabled;
bool suspended;
int (*cmd_xfer)(struct cros_ec_device *ec, int (*cmd_xfer)(struct cros_ec_device *ec,
struct cros_ec_command *msg); struct cros_ec_command *msg);
int (*pkt_xfer)(struct cros_ec_device *ec, int (*pkt_xfer)(struct cros_ec_device *ec,
......
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