Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1517585ybb; Sat, 11 Apr 2020 05:28:15 -0700 (PDT) X-Google-Smtp-Source: APiQypLxh/6eEXyydQJZley5tBKS9IvCFDD+97xNnYqUhtFMdeibSLtuj31DE/PTNZKAHVDJQ0Z/ X-Received: by 2002:a05:620a:cee:: with SMTP id c14mr8136775qkj.453.1586608095292; Sat, 11 Apr 2020 05:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586608095; cv=none; d=google.com; s=arc-20160816; b=Vz+eYzusGYh67VJw5wFs8Bie5JtSZg/n6uibJlesLAbM4dk7da1JvsQf8wKzMPIaDS C7Bbv7/P3nynkJf2BjzV8Fol7sxYuHDJ6olUf1oscNjL2gwricMRBsw8AxmCGFPNRkYk taJW5cHmEJyfQ99BXLSvD/F+eXK/fcsxCvGQZNcBU5Wn3yD6tGkgXFE7TXsy7LcWj+lE jjDyHDsOXfL5FYs1qTJkyTT//niEUJ0qa2SUGCic2WKwJHWP9JttWj/JDgzcV1ZCyOCp Fm99pY9cyKgvYYnioE6KWyJPGc1BjgMwRfk59JV6LFNHbyXLoCZxX3DOBPySPAl0hkP2 VVCg== 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 :dkim-signature; bh=jJO52t1VD38Cnffs4HSxLJJBN3b2GDenDRYiYNgwxzM=; b=Y8Pp9yB8GFxTn7lbZamsUfo+DXjaXS3IurLX3O3DAho9VhFi22StFm5vwHuosHjZdj BFvZh/jjnFs+U5uoseRlKmmtMGAOzxEM+EeCOGdtpc/7xt9NhlrA5QoQuUo8+nX2xeWs YlKgMPaoEpZ8ExgAcblr4lCia3esNq0os+OGoks8hwxcvJb2NPBr3K8+aKlcCmxsmo2x h920ALEGMSGHierQD9l9i/BAEk7u8wUBEgZJcPt0v71qevry3gxiFzzHw6PFE9LC3wB5 Qr9wbSFj0VDfOn+GOJzCf23rwec2x8jp6zyT4KLSXKFTZP6PmdsCo7V82X3hMgiqKAZf ukTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=j9Z1itco; 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 f8si2448470qta.157.2020.04.11.05.28.01; Sat, 11 Apr 2020 05:28:15 -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; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=j9Z1itco; 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 S1728081AbgDKM0q (ORCPT + 99 others); Sat, 11 Apr 2020 08:26:46 -0400 Received: from mout.gmx.net ([212.227.17.22]:54081 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbgDKM0p (ORCPT ); Sat, 11 Apr 2020 08:26:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1586608000; bh=Qe5TIhwuZ0lnZ5c49QtZbb8+6UAILtOmv8OpMKPtW/s=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=j9Z1itcolLDUNFB+tj54D1Kb9LAbS8mZQl0wvvKcbrD1f2D7k9xOe+sEkQQIjE3Tq LXK/VcHu07BbpCy3TWXZJHLOZT0HIiwhFey59Qa6pbV3X7j1yupRYn0JAVCn+zuhdg JfzWD2yGlDrvXayoqhHV9zaIKcpg2rbUHLp28TDI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([83.52.229.196]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MFbRm-1jVRde2QSU-00H59S; Sat, 11 Apr 2020 14:26:40 +0200 From: Oscar Carter To: Forest Bond , Greg Kroah-Hartman Cc: Oscar Carter , Malcolm Priestley , Quentin Deslandes , Amir Mahdi Ghorbanian , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] staging: vt6656: Refactor the assignment of the phy->signal variable Date: Sat, 11 Apr 2020 14:26:09 +0200 Message-Id: <20200411122610.7901-2-oscar.carter@gmx.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200411122610.7901-1-oscar.carter@gmx.com> References: <20200411122610.7901-1-oscar.carter@gmx.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:ZbsLyPJkFpbPl9JOMkJVgPELbbkpG+CtT4twaz1GSAXQ5zaan7a PDa4lFhU9GuERl6zX3zSWCXhYctwzy8e9q/7DsJXL0YdKtTA+0Gbt1/tG6yqwg7JMYyXgI2 ULp8MsacRUTFEatRc7HE6uVkpv24OZWNWa/BMerZG2LFoY/3Dl03E/Uc/sx6XLUrT/IGTyP YXV8kXZpqw+o70p5ezqJA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:+FvOKfZMQ5Y=:ahFcYghwnA88kwwwTL6F2X FWUE+QFn0IT8cHNUi770MPJCksl0ifdZ+fs4GzJyVXE1xFJIVWdgZYv/wQMxdsnOVDdHCgfDs lnf+uD8jmGxSeb4TVFt57W0ERJ22f6r9iaMcvMmtKVp4W493GSqfnMiZE9T1SEaJhnQxvcTrb 49LY9skLeiOZmwaOlBDEMRByiP6l5Wi/zrn87z7L9LT8arJQ6Gm0VGSrQH+/bzYar2acWlPoL Dk63f+lhOYnFGWZqfnj7352s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: linux-kernel@vger.kernel.org Create a constant array with the values of the "phy->signal" for every rate. Remove all "phy->signal" assignments inside the switch statement and replace these with a single reading from the new vnt_phy_signal array. The constant array can be of one dimension because the OR mask with BIT(3) or BIT(4) allow obtain a second value according to the rate, the preamble_type and the pkt_type. Signed-off-by: Oscar Carter =2D-- drivers/staging/vt6656/baseband.c | 105 ++++++++---------------------- 1 file changed, 26 insertions(+), 79 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/ba= seband.c index a19a563d8bcc..05cc4797df52 100644 =2D-- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -115,6 +115,21 @@ static const u16 vnt_frame_time[MAX_RATE] =3D { 10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216 }; +static const u8 vnt_phy_signal[] =3D { + 0x00, /* RATE_1M */ + 0x01, /* RATE_2M */ + 0x02, /* RATE_5M */ + 0x03, /* RATE_11M */ + 0x8b, /* RATE_6M */ + 0x8f, /* RATE_9M */ + 0x8a, /* RATE_12M */ + 0x8e, /* RATE_18M */ + 0x89, /* RATE_24M */ + 0x8d, /* RATE_36M */ + 0x88, /* RATE_48M */ + 0x8c /* RATE_54M */ +}; + /* * Description: Calculate data frame transmitting time * @@ -183,6 +198,8 @@ void vnt_get_phy_field(struct vnt_private *priv, u32 f= rame_length, u32 count =3D 0; u32 tmp; int ext_bit; + int i; + u8 mask =3D 0; u8 preamble_type =3D priv->preamble_type; bit_count =3D frame_length * 8; @@ -191,27 +208,12 @@ void vnt_get_phy_field(struct vnt_private *priv, u32= frame_length, switch (tx_rate) { case RATE_1M: count =3D bit_count; - - phy->signal =3D 0x00; - break; case RATE_2M: count =3D bit_count / 2; - - if (preamble_type =3D=3D 1) - phy->signal =3D 0x09; - else - phy->signal =3D 0x01; - break; case RATE_5M: count =3D DIV_ROUND_UP(bit_count * 10, 55); - - if (preamble_type =3D=3D 1) - phy->signal =3D 0x0a; - else - phy->signal =3D 0x02; - break; case RATE_11M: count =3D bit_count / 11; @@ -224,75 +226,20 @@ void vnt_get_phy_field(struct vnt_private *priv, u32= frame_length, ext_bit =3D true; } - if (preamble_type =3D=3D 1) - phy->signal =3D 0x0b; - else - phy->signal =3D 0x03; - - break; - case RATE_6M: - if (pkt_type =3D=3D PK_TYPE_11A) - phy->signal =3D 0x9b; - else - phy->signal =3D 0x8b; - break; - case RATE_9M: - if (pkt_type =3D=3D PK_TYPE_11A) - phy->signal =3D 0x9f; - else - phy->signal =3D 0x8f; - - break; - case RATE_12M: - if (pkt_type =3D=3D PK_TYPE_11A) - phy->signal =3D 0x9a; - else - phy->signal =3D 0x8a; - - break; - case RATE_18M: - if (pkt_type =3D=3D PK_TYPE_11A) - phy->signal =3D 0x9e; - else - phy->signal =3D 0x8e; - - break; - case RATE_24M: - if (pkt_type =3D=3D PK_TYPE_11A) - phy->signal =3D 0x99; - else - phy->signal =3D 0x89; - - break; - case RATE_36M: - if (pkt_type =3D=3D PK_TYPE_11A) - phy->signal =3D 0x9d; - else - phy->signal =3D 0x8d; - - break; - case RATE_48M: - if (pkt_type =3D=3D PK_TYPE_11A) - phy->signal =3D 0x98; - else - phy->signal =3D 0x88; + } - break; - case RATE_54M: + if (tx_rate > RATE_11M) { if (pkt_type =3D=3D PK_TYPE_11A) - phy->signal =3D 0x9c; - else - phy->signal =3D 0x8c; - break; - default: - if (pkt_type =3D=3D PK_TYPE_11A) - phy->signal =3D 0x9c; - else - phy->signal =3D 0x8c; - break; + mask =3D BIT(4); + } else if (tx_rate > RATE_1M) { + if (preamble_type =3D=3D PREAMBLE_SHORT) + mask =3D BIT(3); } + i =3D tx_rate > RATE_54M ? RATE_54M : tx_rate; + phy->signal =3D vnt_phy_signal[i] | mask; + if (pkt_type =3D=3D PK_TYPE_11B) { phy->service =3D 0x00; if (ext_bit) =2D- 2.20.1