Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6650419imu; Wed, 14 Nov 2018 05:03:33 -0800 (PST) X-Google-Smtp-Source: AJdET5egd9oDJemcxhSnZS+cgGAdyk9RHXELURqTN/lWZk0n3tDbBAO/W7AtlG1zk3Y6s0aRtwLB X-Received: by 2002:a63:9f19:: with SMTP id g25mr1637292pge.327.1542200613331; Wed, 14 Nov 2018 05:03:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542200613; cv=none; d=google.com; s=arc-20160816; b=HmZkoHzEFNTf7q5idwl9fxDqqZFucce2vlDZMQyoFxD4TacCpltK2UzX2Yb61SBnpR HZbZpR4S3lOUNfmbs5xpwh1NSmt0cZpUsgfbHUCA8NQHtdwSuGYDcXsaXHoH2W93Sjbk HqHkUh7uZmrIAIz4QPlaqjazahEgv3kHsJZLq2/G8OvExcD9llGNYl2PeqmnfA+Xg40w GDfamFCIW6mIZkk5U6SW7dSbjrkZFUgim1aAZBUtDvOnChTdySNQi8MhNePBF7/gZSfr rycV05hzMCSKBYMp6UtHtRoP0jkyPSoEYaXAkyHKgO+JVKclrMhbEDBNel0oRqIlGNeT DiLg== 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=DZbQKlOSLhJcmB1VHaPkDqPBBkeezV4YKpMCS2u6Fgay2ZeZJNSvTFHguIwfLToCWL QcAMqOStPFZbUozLI+Iy3sH2bNrvZerp9o94F2842J9KmPLg1iHUdT7vXHpxrh3exifS VzfhHokks15/5f2iCGkRT55YN94ywBqnmGSuvwSuetkZVsF3Zyv+oSRvZFK8ULHB5CTJ ylAt6prOw+0U1kI6nnd2ESc6IZFJ2BxPEvXRDfVEGo+HZrQXcuIHTg+3EPNaSVMitqj2 WUR5Yem1eDODOXUFMTJKoC9qy42TuO/MxIWmp2HrHoAQMcIQNHfL9X0tBFipZs0UQcwj j11A== 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 q76-v6si17572410pfa.211.2018.11.14.05.03.17; Wed, 14 Nov 2018 05:03:33 -0800 (PST) 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 S1732760AbeKNXD2 (ORCPT + 99 others); Wed, 14 Nov 2018 18:03:28 -0500 Received: from mx2.suse.de ([195.135.220.15]:44508 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727731AbeKNXD1 (ORCPT ); Wed, 14 Nov 2018 18:03:27 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8EE71B087; Wed, 14 Nov 2018 13:00:16 +0000 (UTC) From: Nicolas Saenz Julienne To: stefan.wahren@i2se.com, eric@anholt.net, dave.stevenson@raspberrypi.org Cc: linux-rpi-kernel@lists.infradead.org, gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Nicolas Saenz Julienne Subject: [PATCH 02/16] staging: vchiq_arm: rework close/remove_service IOCTLS Date: Wed, 14 Nov 2018 13:59:28 +0100 Message-Id: <20181114125942.25163-3-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181114125942.25163-1-nsaenzjulienne@suse.de> References: <20181114125942.25163-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