Commit ddd7536a authored by Nicolas Saenz Julienne's avatar Nicolas Saenz Julienne Committed by Greg Kroah-Hartman

staging: vchiq_arm: rework close/remove_service IOCTLS

The implementation of both IOCTLS was the same except for one function
call. This joins both implementations and updates the code to avoid
unneeded indentations.
Signed-off-by: default avatarNicolas Saenz Julienne <nsaenzjulienne@suse.de>
Acked-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 49fa9157
...@@ -1019,42 +1019,25 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1019,42 +1019,25 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
} }
} break; } break;
case VCHIQ_IOC_CLOSE_SERVICE: { case VCHIQ_IOC_CLOSE_SERVICE:
case VCHIQ_IOC_REMOVE_SERVICE: {
VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg;
USER_SERVICE_T *user_service;
service = find_service_for_instance(instance, handle); service = find_service_for_instance(instance, handle);
if (service != NULL) { if (!service) {
USER_SERVICE_T *user_service = ret = -EINVAL;
(USER_SERVICE_T *)service->base.userdata;
/* close_pending is false on first entry, and when the
wait in vchiq_close_service has been interrupted. */
if (!user_service->close_pending) {
status = vchiq_close_service(service->handle);
if (status != VCHIQ_SUCCESS)
break; break;
} }
/* close_pending is true once the underlying service user_service = service->base.userdata;
has been closed until the client library calls the
CLOSE_DELIVERED ioctl, signalling close_event. */
if (user_service->close_pending &&
down_interruptible(&user_service->close_event))
status = VCHIQ_RETRY;
} else
ret = -EINVAL;
} break;
case VCHIQ_IOC_REMOVE_SERVICE: {
VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg;
service = find_service_for_instance(instance, handle);
if (service != NULL) {
USER_SERVICE_T *user_service =
(USER_SERVICE_T *)service->base.userdata;
/* close_pending is false on first entry, and when the /* close_pending is false on first entry, and when the
wait in vchiq_close_service has been interrupted. */ wait in vchiq_close_service has been interrupted. */
if (!user_service->close_pending) { if (!user_service->close_pending) {
status = vchiq_remove_service(service->handle); status = (cmd == VCHIQ_IOC_CLOSE_SERVICE) ?
vchiq_close_service(service->handle) :
vchiq_remove_service(service->handle);
if (status != VCHIQ_SUCCESS) if (status != VCHIQ_SUCCESS)
break; break;
} }
...@@ -1065,9 +1048,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1065,9 +1048,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (user_service->close_pending && if (user_service->close_pending &&
down_interruptible(&user_service->close_event)) down_interruptible(&user_service->close_event))
status = VCHIQ_RETRY; status = VCHIQ_RETRY;
} else break;
ret = -EINVAL; }
} break;
case VCHIQ_IOC_USE_SERVICE: case VCHIQ_IOC_USE_SERVICE:
case VCHIQ_IOC_RELEASE_SERVICE: { case VCHIQ_IOC_RELEASE_SERVICE: {
......
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