From patchwork Tue Mar 14 13:09:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pjambhlekar X-Patchwork-Id: 9624751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6FA4D60492 for ; Wed, 15 Mar 2017 03:28:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F9962841A for ; Wed, 15 Mar 2017 03:28:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 529B928522; Wed, 15 Mar 2017 03:28:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=2.0 tests=BAYES_00, DATE_IN_PAST_12_24, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E8FD12841A for ; Wed, 15 Mar 2017 03:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=1vZHvcmqdCpXYpU8e8xyLpfDuMLgOTSPu2H1m3edcTs=; b=U14 kYxuR5eEwiVx16oZAVbMDGxCuk5a9uljhlWRVqwIKY8wppINKR4AfrdSlYKxmDpQweiTAcqi4Ob9e zgzXIY7kGYmXTC/OZfLRFeMGvk0CnpoSTu9pBHP0nrTKvdrAoACQd6XA8yOCaUwQAl7/8tV5RuGXW 2P5Mk0/w50e3jRkTtc/zF7Dhzw3hkp/emXrXftSe2rCrRtbFKdnwW6VjPld3DZwUkc4XK8p0BpAzh DIP90Jv4ptD5F0NbGvq1W01EmaUm3x4DRPD4L5fGsabKGQD8H3T2vQWwM0W3tDabRHnuW0b40HubL HYXfz+8/ODNk4OkvtCNrTXCQseyOw8g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cnzbs-0005VA-A9; Wed, 15 Mar 2017 03:28:24 +0000 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cnzbm-0005Tc-Hi; Wed, 15 Mar 2017 03:28:20 +0000 Received: by mail-pg0-x242.google.com with SMTP id y17so675595pgh.0; Tue, 14 Mar 2017 20:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=UeWINS7hhxTPkHL02sQa2ExIpIjHfR9MKp6jokWxnNo=; b=lvR+yYimxqnsnZzFUpw+WiLPRCArWfDhBP9veP8bmOVokALuKiqm2f6YtRbNF/J+tm QrPnvY1Fz9B3KUG+QqSBf2SKEqa89Z5h+y3i0ORKn+DA8CJADUI3s+Y/DX6hCc2ccnVd j9I3Zt3fskKnn8LHM8dnAoZYpCYgGtUq/Dw48MgFhK2zJeIK0hBPPqEQYpwmZu2sh5GT MpQM1UQI7YSnNqiLxJ6Rh5JwQpxmAmT+c32y96voFDpZH4i9ykHzip2V3IT3KZCigI+w JAqHI4sHQiJoRjmcU7DAcFf1xpsv3GOq/c61pcCdbHZVEti6gVh9I+yAhLk3WbaR5OxA 2z7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UeWINS7hhxTPkHL02sQa2ExIpIjHfR9MKp6jokWxnNo=; b=A4S2E7ecmM0ysn1+UCpDLcm0QtuXaLUB8sHVf+TNCP/sMlXaXmjZBw3Ukn/u+XOFxh zKAITOAp3cY820mdNNCteXG8pbj0t/l0MFkqXRs6k1umNV8EF2c0Kk1qnuRBukZaTXy/ zYr7NdkHHeLsIfsBvJiw8g3UijdUFXAaqiBxlXLpfCFNWe1WsPiX6cy+1LBZnRXoAJQW fyjSnCq1O/baQlDqfZUMU15umVQj0Gl5g+ATYHQOhqPObM0SZlPpFgUYiNgwgrynHdFG t9dkuqwL7kIs3FCQ03W5za4KvYiHOLZ2gdOkpZsu4i9OBv8dV+ph1qeYQBHagOH72ZiY sIWw== X-Gm-Message-State: AFeK/H0NyuPEfQQx8OQjQg87fA5H0TYyHkb8GF+ic/8q+JjK8KuFFn2rTckbc/DVMBltQA== X-Received: by 10.84.212.136 with SMTP id e8mr1513471pli.140.1489548476174; Tue, 14 Mar 2017 20:27:56 -0700 (PDT) Received: from pjambhlekar-vm.nvidia.com ([202.135.238.200]) by smtp.googlemail.com with ESMTPSA id g29sm629940pfg.37.2017.03.14.20.27.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Mar 2017 20:27:55 -0700 (PDT) From: Pushkar Jambhlekar To: Stephen Warren , Lee Jones , Eric Anholt , Greg Kroah-Hartman , Michael Zoran , Daniel Stone , Stefan Wahren , =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , Stafford Horne , Pushkar Jambhlekar , popcornmix Subject: [PATCH] vc04_services: Fixing coding and logical guidelines Date: Tue, 14 Mar 2017 18:39:04 +0530 Message-Id: <1489496944-44038-1-git-send-email-pushkar.iit@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170314_202818_645565_2B642578 X-CRM114-Status: GOOD ( 11.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:STAGING SUBSYSTEM" , "moderated list:BROADCOM BCM2835 ARM ARCHITECTURE" , "moderated list:BROADCOM BCM2835 ARM ARCHITECTURE" , open list MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Description: in file 'vc04_services/interface/vchiq_arm/vchiq_shim.c', making changes to make code according to 'checkpath.pl'. Also, fixing logical issue, i.e. removing break after goto statement. Signed-off-by: Pushkar Jambhlekar --- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 33 ++++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 48984ab..6d8a1d8 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -52,7 +52,8 @@ typedef struct { /* ---------------------------------------------------------------------- * return pointer to the mphi message driver function table - * -------------------------------------------------------------------- */ + * ---------------------------------------------------------------------- + */ const VCHI_MESSAGE_DRIVER_T * vchi_mphi_message_driver_func_table(void) { @@ -61,7 +62,8 @@ vchi_mphi_message_driver_func_table(void) /* ---------------------------------------------------------------------- * return a pointer to the 'single' connection driver fops - * -------------------------------------------------------------------- */ + * ---------------------------------------------------------------------- + */ const VCHI_CONNECTION_API_T * single_get_func_table(void) { @@ -556,6 +558,7 @@ EXPORT_SYMBOL(vchi_connect); int32_t vchi_disconnect(VCHI_INSTANCE_T instance_handle) { VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; + return vchiq_status_to_vchi(vchiq_shutdown(instance)); } EXPORT_SYMBOL(vchi_disconnect); @@ -592,7 +595,6 @@ static VCHIQ_STATUS_T shim_callback(VCHIQ_REASON_T reason, VCHI_CALLBACK_MSG_AVAILABLE, NULL); goto done; - break; case VCHIQ_BULK_TRANSMIT_DONE: service->callback(service->callback_param, @@ -733,8 +735,10 @@ int32_t vchi_service_close(const VCHI_SERVICE_HANDLE_T handle) { int32_t ret = -1; SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + if (service) { VCHIQ_STATUS_T status = vchiq_close_service(service->handle); + if (status == VCHIQ_SUCCESS) { service_free(service); service = NULL; @@ -750,8 +754,10 @@ int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle) { int32_t ret = -1; SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + if (service) { VCHIQ_STATUS_T status = vchiq_remove_service(service->handle); + if (status == VCHIQ_SUCCESS) { service_free(service); service = NULL; @@ -770,6 +776,7 @@ int32_t vchi_service_set_option(const VCHI_SERVICE_HANDLE_T handle, int32_t ret = -1; SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; VCHIQ_SERVICE_OPTION_T vchiq_option; + switch (option) { case VCHI_SERVICE_OPTION_TRACE: vchiq_option = VCHIQ_SERVICE_OPTION_TRACE; @@ -797,8 +804,8 @@ int32_t vchi_get_peer_version(const VCHI_SERVICE_HANDLE_T handle, short *peer_ve { int32_t ret = -1; SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; - if (service) - { + + if (service) { VCHIQ_STATUS_T status; status = vchiq_get_peer_version(service->handle, peer_version); @@ -811,7 +818,8 @@ EXPORT_SYMBOL(vchi_get_peer_version); /* ---------------------------------------------------------------------- * read a uint32_t from buffer. * network format is defined to be little endian - * -------------------------------------------------------------------- */ + * ---------------------------------------------------------------------- + */ uint32_t vchi_readbuf_uint32(const void *_ptr) { @@ -822,11 +830,13 @@ vchi_readbuf_uint32(const void *_ptr) /* ---------------------------------------------------------------------- * write a uint32_t to buffer. * network format is defined to be little endian - * -------------------------------------------------------------------- */ + * ---------------------------------------------------------------------- + */ void vchi_writebuf_uint32(void *_ptr, uint32_t value) { unsigned char *ptr = _ptr; + ptr[0] = (unsigned char)((value >> 0) & 0xFF); ptr[1] = (unsigned char)((value >> 8) & 0xFF); ptr[2] = (unsigned char)((value >> 16) & 0xFF); @@ -836,7 +846,8 @@ vchi_writebuf_uint32(void *_ptr, uint32_t value) /* ---------------------------------------------------------------------- * read a uint16_t from buffer. * network format is defined to be little endian - * -------------------------------------------------------------------- */ + * ---------------------------------------------------------------------- + */ uint16_t vchi_readbuf_uint16(const void *_ptr) { @@ -847,11 +858,13 @@ vchi_readbuf_uint16(const void *_ptr) /* ---------------------------------------------------------------------- * write a uint16_t into the buffer. * network format is defined to be little endian - * -------------------------------------------------------------------- */ + * ---------------------------------------------------------------------- + */ void vchi_writebuf_uint16(void *_ptr, uint16_t value) { unsigned char *ptr = _ptr; + ptr[0] = (value >> 0) & 0xFF; ptr[1] = (value >> 8) & 0xFF; } @@ -870,6 +883,7 @@ int32_t vchi_service_use(const VCHI_SERVICE_HANDLE_T handle) { int32_t ret = -1; SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + if (service) ret = vchiq_status_to_vchi(vchiq_use_service(service->handle)); return ret; @@ -890,6 +904,7 @@ int32_t vchi_service_release(const VCHI_SERVICE_HANDLE_T handle) { int32_t ret = -1; SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + if (service) ret = vchiq_status_to_vchi( vchiq_release_service(service->handle));