From patchwork Thu Mar 3 12:05:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaehyun Lim X-Patchwork-Id: 8492271 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 258799F8A8 for ; Thu, 3 Mar 2016 12:06:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50AFA2017D for ; Thu, 3 Mar 2016 12:06:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46822202E5 for ; Thu, 3 Mar 2016 12:06:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756484AbcCCMGd (ORCPT ); Thu, 3 Mar 2016 07:06:33 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33142 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754996AbcCCMGc (ORCPT ); Thu, 3 Mar 2016 07:06:32 -0500 Received: by mail-pf0-f193.google.com with SMTP id 63so1210584pfe.0 for ; Thu, 03 Mar 2016 04:06:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zifFoBoftjpM0sUMs7U2cQl2idzA/zihXQGyihJroMs=; b=vP2fzyocjOadnjEUhZ/lCV7FuGaVnAZkSq36gYOLSRITlZZHQyZzTyZGdyKC5D3KcI bPyK7XyFw23M5rOwTqt1XevbMNedgvXiFX+uT5ReC4DWoKrge3qyuHD+GhT9346JKDPe H4FWm4wINBs3eut7I/Y4Ak2r4lO/RIbvVVnlO98JUROn+EDlBz+virQTRDKbmkBfggyn z93ULa4wl9yaeQ76QsL7PAdfjrWm4P8Xjx725VrE+/qjNr5BWckvqusKMxl4xwnVbdM2 KaOHQCeKCoPBNhHIGbcNmwL/JAz7aphviAc2l9zdvcDPe916RD4LS+xlNjADjSodJZuv ORdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zifFoBoftjpM0sUMs7U2cQl2idzA/zihXQGyihJroMs=; b=cq11vJl3kPkh1qLME4E/DIzuO1DJW/2siUIArRohA44aJ8oN9CFre8dOs7bp4QsI9z eHvD0xAz8KDBOFPTJSDA0IMvvhpkNvcl5+p74LSBqxjRggmowW2A/TRbhoMKi6mtiEKU Q3wTxLBOLrjS6fixVa5i8m0dpUAG2o2jhdODEbWmSnxULdg0U5gGsixGQ7Rdmbi3fGRa BeQcp1twYWD7YBKC99VKUg/CVafzscPXTAMSBzrwg0mRsjIo4R0q7dap/8Ri8IkY1le/ gDhUfgrNLPW3aMQJlkPuqCoSpWIhak9t6BWpVRB9GSgKuDCRY23OnS45alYoEc0tlfg/ pIZw== X-Gm-Message-State: AD7BkJIz3/+fPGtPO9d03ymNZjfY4kQkznICN68Hu9KLiol57cyV/eX+jSHEzlVk2qah/A== X-Received: by 10.98.40.4 with SMTP id o4mr3177964pfo.76.1457006791653; Thu, 03 Mar 2016 04:06:31 -0800 (PST) Received: from localhost.localdomain ([218.233.16.2]) by smtp.gmail.com with ESMTPSA id v9sm15845386pfi.50.2016.03.03.04.06.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Mar 2016 04:06:31 -0800 (PST) From: Chaehyun Lim To: gregkh@linuxfoundation.org Cc: johnny.kim@atmel.com, austin.shin@atmel.com, chris.park@atmel.com, tony.cho@atmel.com, glen.lee@atmel.com, leo.kim@atmel.com, linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, Chaehyun Lim Subject: [PATCH 6/6] staging: wilc1000: use switch statement instead of multiple if statement Date: Thu, 3 Mar 2016 21:05:22 +0900 Message-Id: <1457006722-14400-6-git-send-email-chaehyun.lim@gmail.com> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1457006722-14400-1-git-send-email-chaehyun.lim@gmail.com> References: <1457006722-14400-1-git-send-email-chaehyun.lim@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is more readable than multiple if-else statement. Signed-off-by: Chaehyun Lim --- drivers/staging/wilc1000/wilc_wlan_cfg.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c index 92f6d32..b3425b9 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.c +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c @@ -378,19 +378,31 @@ int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size) u8 type = (id >> 12) & 0xf; int ret = 0; - if (type == CFG_BYTE_CMD) { + switch (type) { + case CFG_BYTE_CMD: if (size >= 1) ret = wilc_wlan_cfg_set_byte(frame, offset, id, *buf); - } else if (type == CFG_HWORD_CMD) { + break; + + case CFG_HWORD_CMD: if (size >= 2) - ret = wilc_wlan_cfg_set_hword(frame, offset, id, *((u16 *)buf)); - } else if (type == CFG_WORD_CMD) { + ret = wilc_wlan_cfg_set_hword(frame, offset, id, + *((u16 *)buf)); + break; + + case CFG_WORD_CMD: if (size >= 4) - ret = wilc_wlan_cfg_set_word(frame, offset, id, *((u32 *)buf)); - } else if (type == CFG_STR_CMD) { + ret = wilc_wlan_cfg_set_word(frame, offset, id, + *((u32 *)buf)); + break; + + case CFG_STR_CMD: ret = wilc_wlan_cfg_set_str(frame, offset, id, buf, size); - } else if (type == CFG_BIN_CMD) { + break; + + case CFG_BIN_CMD: ret = wilc_wlan_cfg_set_bin(frame, offset, id, buf, size); + break; } return ret;