Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3de8e37 authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman
Browse files

mei: bus: call device disable handler prior to disconnection



call device's disable handler prior to disconnection
so it can possibly close the communication with fw client
in graceful way

Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a9bed610
Loading
Loading
Loading
Loading
+11 −14
Original line number Original line Diff line number Diff line
@@ -467,37 +467,34 @@ int mei_cl_disable_device(struct mei_cl_device *device)


	dev = cl->dev;
	dev = cl->dev;


	if (device->ops && device->ops->disable)
		device->ops->disable(device);

	device->event_cb = NULL;

	mutex_lock(&dev->device_lock);
	mutex_lock(&dev->device_lock);


	if (cl->state != MEI_FILE_CONNECTED) {
	if (cl->state != MEI_FILE_CONNECTED) {
		mutex_unlock(&dev->device_lock);
		dev_err(dev->dev, "Already disconnected");
		dev_err(dev->dev, "Already disconnected");

		err = 0;
		return 0;
		goto out;
	}
	}


	cl->state = MEI_FILE_DISCONNECTING;
	cl->state = MEI_FILE_DISCONNECTING;


	err = mei_cl_disconnect(cl);
	err = mei_cl_disconnect(cl);
	if (err < 0) {
	if (err < 0) {
		mutex_unlock(&dev->device_lock);
		dev_err(dev->dev, "Could not disconnect from the ME client");
		dev_err(dev->dev,
		goto out;
			"Could not disconnect from the ME client");

		return err;
	}
	}


	/* Flush queues and remove any pending read */
	/* Flush queues and remove any pending read */
	mei_cl_flush_queues(cl, NULL);
	mei_cl_flush_queues(cl, NULL);


	device->event_cb = NULL;
out:

	mutex_unlock(&dev->device_lock);
	mutex_unlock(&dev->device_lock);
	return err;


	if (!device->ops || !device->ops->disable)
		return 0;

	return device->ops->disable(device);
}
}
EXPORT_SYMBOL_GPL(mei_cl_disable_device);
EXPORT_SYMBOL_GPL(mei_cl_disable_device);