Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp168656imd; Fri, 26 Oct 2018 06:51:09 -0700 (PDT) X-Google-Smtp-Source: AJdET5efL7yTa3I3g3+YRr4MC/ZO1Ux5QweeUfbRuMuk4L85u1tCD1+1Td0bTeLtIBnGN23VZzNI X-Received: by 2002:a17:902:1ea:: with SMTP id b97-v6mr3702972plb.152.1540561869725; Fri, 26 Oct 2018 06:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540561869; cv=none; d=google.com; s=arc-20160816; b=wLnSGWXDaM9rr6EdZOnKmFyfCpRrTNEpk/zOlM4zq/Z7F9/ctDmcQ+ZTrtcyWq1eEy wGKwGzxCQKiwdPkM5YYYyh37FXtKs2NyFExa70MvhyapyJ3G7ParpJiwkEltIv/g2z2Z dDiiiBiG+18E/o/QJIhM4eBPKmNhW1O46nC9EaPgiCC/FCQ2YaFVLNUdNzQy8CayO5Qt /1uvwXiIEjeyUFsEU9eM0HzOGGK26FBhpLYWu2KjrDOy9UCoir1d90Af+9BrAjpznyDQ WF2uJubC4nMNAHl7wy12YCeGe6+N78DFWQcjbopowGpgmamUBM3tlFqBfP7RW0mf0wUx LXIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/TQV9/tak+ra8/GgFlmO7WImgTkIFlIXVbd7jWBjlnk=; b=aXB4evbSQh1O44V2uNLU8XSQNt8drl0SklbXdfNjmdr6+d2H0fjnVigssvHookthHL VfZc8jxl5h6TLW+ct4jquzuu2uVnRWGAVuD4dsxkne5wVNTsGfe+uRls5VRZwVXCBZBO myHSULNSdySj+pB9nJxTOaRj7TQmDzW43KeAqjiJ50WklqteGwRsSsTmsEk4n3vO+tYI u3ZzMoIW12NnKbLJaqjyk3MrP4uCp/DxaPcfKRwj8ySRr+DKO4oNU/vGNBDj3gyckkyb qLDiEULemum46zut4B72oYStjgIRhXlyoMVT1Z9RT/nIfyW2qJvWm3PfaFo2W2sQsgGA F3xw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9-v6si10335609plg.18.2018.10.26.06.50.53; Fri, 26 Oct 2018 06:51:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727250AbeJZWZm (ORCPT + 99 others); Fri, 26 Oct 2018 18:25:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:44772 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726014AbeJZWZl (ORCPT ); Fri, 26 Oct 2018 18:25:41 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CDC45AFB2; Fri, 26 Oct 2018 13:48:30 +0000 (UTC) From: Nicolas Saenz Julienne To: stefan.wahren@i2se.com, eric@anholt.net, dave.stevenson@raspberrypi.org Cc: nsaenzjulienne@suse.de, linux-rpi-kernel@lists.infradead.org, gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 02/18] staging: vchiq_arm: rework close/remove_service IOCTLS Date: Fri, 26 Oct 2018 15:47:57 +0200 Message-Id: <20181026134813.7775-3-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181026134813.7775-1-nsaenzjulienne@suse.de> References: <20181026134813.7775-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: Nicolas Saenz Julienne --- .../interface/vchiq_arm/vchiq_arm.c | 66 +++++++------------ 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 6d503392341e..d88dd7415e1e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1019,55 +1019,37 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } } 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; + USER_SERVICE_T *user_service; 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 - wait in vchiq_close_service has been interrupted. */ - if (!user_service->close_pending) { - status = vchiq_close_service(service->handle); - if (status != VCHIQ_SUCCESS) - break; - } - - /* close_pending is true once the underlying service - 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 + if (!service) { ret = -EINVAL; - } break; + break; + } - case VCHIQ_IOC_REMOVE_SERVICE: { - VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; + user_service = service->base.userdata; - 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 - wait in vchiq_close_service has been interrupted. */ - if (!user_service->close_pending) { - status = vchiq_remove_service(service->handle); - if (status != VCHIQ_SUCCESS) - break; - } + /* close_pending is false on first entry, and when the + wait in vchiq_close_service has been interrupted. */ + if (!user_service->close_pending) { + status = (cmd == VCHIQ_IOC_CLOSE_SERVICE) ? + vchiq_close_service(service->handle) : + vchiq_remove_service(service->handle); + if (status != VCHIQ_SUCCESS) + break; + } - /* close_pending is true once the underlying service - 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; + /* close_pending is true once the underlying service + 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; + break; + } case VCHIQ_IOC_USE_SERVICE: case VCHIQ_IOC_RELEASE_SERVICE: { -- 2.19.1