Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp170168imd; Fri, 26 Oct 2018 06:52:35 -0700 (PDT) X-Google-Smtp-Source: AJdET5d4kxbBqYe2GhWEWWOJutAidHPFXwRYkzTPMhaLH364ibzx8c/JLFEvpTXZzmWTg98Vdh7J X-Received: by 2002:a62:ea03:: with SMTP id t3-v6mr3971764pfh.228.1540561954986; Fri, 26 Oct 2018 06:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540561954; cv=none; d=google.com; s=arc-20160816; b=A7CBKHbUyLRllKpFbO9hyd94c5WCBror1yYmhUjQ4b2KNNK7pza4M543ifXQCnZFyC pP31d6K+JzAlTZ2BxrstHYIIduv5qnf5svA2JQwu1sBfLZfeoaJaSXGMfu+kI4csTV1e L3pDlR/sjn4ZlKJ38RgciYWMnYkN5lraLt2164MZcn82i6eE8VxX42ivvZ1tNjME2P31 CCaG1d/cJx7D1R+YK6tEUdavZOjVDDPBPDYw93f6hIgGGuxrxS+uSnyO7GFuZyyWh4CB 3riZ/rKhBlIQih7gt+D41RRgfcV0LOoP1+hhhFdfVg3MXDqYh+Fml8f4snPAnhKi84Rn 1Law== 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=8xFb2L+aRnABbXYjLUerTtbVrMMKBgvMpIuNKuT2CMs=; b=l7UZNHHX2634QqQ7EJZb5TI/mg7abkrdbyjpci+F9eeSCF7P5Qu9gKBBzTsNBq4F7U nQmzVTC5/TGnU15+8OO1WrvsYcrd5A+fbISVQUA390O8jqdGC3nXNff965GXtp9f2fWs /aKGBn6U33IN96CGFZTmVxG9vQwoqACvh6pVlvow5qKgcc67yKNdU5UpgFkgt16zeF75 dSeTODxyQ6DcVQbhwCnq+pM9XHFsO+RFpdkd0/MRrLhy+hY2r4861OZdpNfAJRrj057O aRYV7qH7JO9K6yhySSfxBLFBibfr6UXLxjSGgGSWh2hZHY1439wlK0hkUmLnPh95+9VZ ceig== 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 j30-v6si11707742pgl.4.2018.10.26.06.52.19; Fri, 26 Oct 2018 06:52:34 -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 S1726884AbeJZWZk (ORCPT + 99 others); Fri, 26 Oct 2018 18:25:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:44742 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726128AbeJZWZk (ORCPT ); Fri, 26 Oct 2018 18:25:40 -0400 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 1D7C5AF7B; 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 01/18] staging: vchiq_core: rework vchiq_get_config Date: Fri, 26 Oct 2018 15:47:56 +0200 Message-Id: <20181026134813.7775-2-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 function is overly complicated for what it's ultimately achieving. It's simply filling up a structure. Signed-off-by: Nicolas Saenz Julienne --- .../interface/vchiq_arm/vchiq_arm.c | 12 ++++---- .../interface/vchiq_arm/vchiq_core.c | 30 +++++-------------- .../interface/vchiq_arm/vchiq_if.h | 3 +- 3 files changed, 14 insertions(+), 31 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 ea789376de0f..6d503392341e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1480,13 +1480,11 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ret = -EINVAL; break; } - status = vchiq_get_config(instance, args.config_size, &config); - if (status == VCHIQ_SUCCESS) { - if (copy_to_user((void __user *)args.pconfig, - &config, args.config_size) != 0) { - ret = -EFAULT; - break; - } + + vchiq_get_config(&config); + if (copy_to_user(args.pconfig, &config, args.config_size)) { + ret = -EFAULT; + break; } } break; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 7642ced31436..89f1ccdc3b98 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3583,28 +3583,14 @@ vchiq_get_peer_version(VCHIQ_SERVICE_HANDLE_T handle, short *peer_version) return status; } -VCHIQ_STATUS_T -vchiq_get_config(VCHIQ_INSTANCE_T instance, - int config_size, VCHIQ_CONFIG_T *pconfig) -{ - VCHIQ_CONFIG_T config; - - (void)instance; - - config.max_msg_size = VCHIQ_MAX_MSG_SIZE; - config.bulk_threshold = VCHIQ_MAX_MSG_SIZE; - config.max_outstanding_bulks = VCHIQ_NUM_SERVICE_BULKS; - config.max_services = VCHIQ_MAX_SERVICES; - config.version = VCHIQ_VERSION; - config.version_min = VCHIQ_VERSION_MIN; - - if (config_size > sizeof(VCHIQ_CONFIG_T)) - return VCHIQ_ERROR; - - memcpy(pconfig, &config, - min(config_size, (int)(sizeof(VCHIQ_CONFIG_T)))); - - return VCHIQ_SUCCESS; +void vchiq_get_config(VCHIQ_CONFIG_T *config) +{ + config->max_msg_size = VCHIQ_MAX_MSG_SIZE; + config->bulk_threshold = VCHIQ_MAX_MSG_SIZE; + config->max_outstanding_bulks = VCHIQ_NUM_SERVICE_BULKS; + config->max_services = VCHIQ_MAX_SERVICES; + config->version = VCHIQ_VERSION; + config->version_min = VCHIQ_VERSION_MIN; } VCHIQ_STATUS_T diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index e4109a83e628..87829a244465 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -164,8 +164,7 @@ extern VCHIQ_STATUS_T vchiq_bulk_receive_handle(VCHIQ_SERVICE_HANDLE_T service, extern int vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T service); extern void *vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T service); extern int vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T service); -extern VCHIQ_STATUS_T vchiq_get_config(VCHIQ_INSTANCE_T instance, - int config_size, VCHIQ_CONFIG_T *pconfig); +extern void vchiq_get_config(VCHIQ_CONFIG_T *config); extern VCHIQ_STATUS_T vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T service, VCHIQ_SERVICE_OPTION_T option, int value); -- 2.19.1