Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp859511imu; Tue, 20 Nov 2018 08:02:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/WoBwQ1sUCOqH6ww69IQvKil/I55r1+9jrFoLM070Cs4U1LqMQAfW4JtJ+nQ4K2PlCMSThU X-Received: by 2002:a17:902:124:: with SMTP id 33-v6mr2784597plb.287.1542729775010; Tue, 20 Nov 2018 08:02:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542729774; cv=none; d=google.com; s=arc-20160816; b=NJyK0/E0S0B7FDEZMnrVpBIFrTDjcqhyhaTttA/PAZlsTqtjrTCwD6n5Hg0uDBT1WJ HzUWG5QwuMVWWDPw8FLk1BG566Pl97SQiaPcs5g0N2/7p+2bfpdYR3slIcAU1Aptpg+I lgtaEuXbQkPIgqI3pNoV4Wy5kJnSQBIBLKt2b10Arceel+bomsZRGtEaFAU+c7s/mR35 jV1VTms9SARo2BKXRwTEV2zRo3m24yTPJBamGVMTZDOoPZ06DCjGyHyLaJPLS32ejWyX YBcd/ZITyWyyhLS1WYFttrjNFMmIwnAP5e64Q0JfMbltZRrAOIJ+2CcBnMG1mQagh+Xi Q+aQ== 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=ALCuI+nQUXCnkHGkPSHLQ8pWkxZfvKg6DAD5X03sM9A=; b=S7PPHPDE9ynRVZArD5E2Qf7JYD3xCvwRsvflo9PwLtLB7MobF3oOA26BjoZetlZ5E9 a7+/mhYWjZB+WGOpo+a7oUIVqxUlr7CLWOZyDDzFDAmfwlKPR3VFbDrR6tFapFSPklKs vnoBAhG6CJuHm0/s6cZZ38BdNMvGDYLAdjRpGM+uVIChamokHN2CqIJwFlriRDDouZPw W/H4kZd2RghJAnKlVLU3QezS8CIb8Fmf241hru4+wIC0JjVPEPM7LE5LdHoH55Q/NG09 ufNm4OFBjSRc7292jgMNzb60ZprYfdwsCvANNqGdA4MzziL9XwllvnmoQbr1RJ/AdAxk e/gw== 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 y5-v6si41501248pfk.172.2018.11.20.08.02.38; Tue, 20 Nov 2018 08:02:54 -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 S1729926AbeKUBXm (ORCPT + 99 others); Tue, 20 Nov 2018 20:23:42 -0500 Received: from mx2.suse.de ([195.135.220.15]:39192 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727788AbeKUBXk (ORCPT ); Tue, 20 Nov 2018 20:23:40 -0500 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 ABCD2AC43; Tue, 20 Nov 2018 14:54:06 +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: Tue, 20 Nov 2018 15:53:37 +0100 Message-Id: <20181120145351.30390-3-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120145351.30390-1-nsaenzjulienne@suse.de> References: <20181120145351.30390-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 5af3f2651bd3..835152799433 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