mutex_lock(&bus->device_lock);
if (!mei_cl_is_connected(cl)) {
- dev_dbg(bus->dev, "Already disconnected");
+ dev_dbg(bus->dev, "Already disconnected\n");
+ err = 0;
+ goto out;
+ }
+
+ if (bus->dev_state == MEI_DEV_POWER_DOWN) {
+ dev_dbg(bus->dev, "Device is powering down don't botther with disconnection\n");
err = 0;
goto out;
}
err = mei_cl_disconnect(cl);
if (err < 0)
- dev_err(bus->dev, "Could not disconnect from the ME client");
+ dev_err(bus->dev, "Could not disconnect from the ME client\n");
out:
/* Flush queues and remove any pending read */
if (rets == -ENODATA)
break;
- if (rets && dev->dev_state != MEI_DEV_RESETTING) {
+ if (rets &&
+ (dev->dev_state != MEI_DEV_RESETTING ||
+ dev->dev_state != MEI_DEV_POWER_DOWN)) {
dev_err(dev->dev, "mei_irq_read_handler ret = %d.\n",
rets);
schedule_work(&dev->reset_work);
if (test_and_clear_bit(TXE_INTR_OUT_DB_BIT, &hw->intr_cause)) {
/* Read from TXE */
rets = mei_irq_read_handler(dev, &cmpl_list, &slots);
- if (rets && dev->dev_state != MEI_DEV_RESETTING) {
+ if (rets &&
+ (dev->dev_state != MEI_DEV_RESETTING ||
+ dev->dev_state != MEI_DEV_POWER_DOWN)) {
dev_err(dev->dev,
"mei_irq_read_handler ret = %d.\n", rets);
{
dev_dbg(dev->dev, "stopping the device.\n");
+ mutex_lock(&dev->device_lock);
+ dev->dev_state = MEI_DEV_POWER_DOWN;
+ mutex_unlock(&dev->device_lock);
mei_cl_bus_remove_devices(dev);
mei_cancel_work(dev);
mutex_lock(&dev->device_lock);
- dev->dev_state = MEI_DEV_POWER_DOWN;
mei_reset(dev);
/* move device to disabled state unconditionally */
dev->dev_state = MEI_DEV_DISABLED;