Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3121482pxb; Sun, 20 Feb 2022 09:55:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2jDJm0Bg/bKEAX5n4APnxCxVncj2P4s+2w8CT50WdbfRVDJpYxHsRWqnatVQJknO8FDd+ X-Received: by 2002:a17:90b:2345:b0:1bc:4273:b194 with SMTP id ms5-20020a17090b234500b001bc4273b194mr553900pjb.108.1645379704780; Sun, 20 Feb 2022 09:55:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645379704; cv=none; d=google.com; s=arc-20160816; b=aRloUPD/c+R9bia884UhaDef4O0lE2oe5V3Qzrf2qw/n2O5y8I/sQFw7cvfzUImEgS V2U7FPKgAO4oGTkKT70YUUD1MsApaI9W7smXEUAkuGCxmBso1Z4iO0/zw5XujaaLVbeM gOspmA7KqKTXJ6NEKvrH1NDjrbCB/XlIRuNF7kgfZQjoulzUhCCaGwwIkjCMEamwN9WT uU/eflkNpCGkTnA3tTNK4uopDlbHmYLZYcBejY7TEci7ypKJS7nQI/V1AXYhc8bCMxc3 6FtU8Nrc4Dzz+UHAl9L86WSiyESJPyuMmF+0dcLTyvQT5rOZSkvS6iRtwOWIzapOPJru Uffw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mTYsVbDSvOAH4QYIkGgRDagMrOUXfFeihf5F3hcHwp0=; b=Q3SanDc+YucURe3uj7hUwAj9iJ4u16NTd8xXWQVDuaurP5+OIPCmuy3ON2K9v03x6a rQ8vyacZevYbbeDKHqvlvVmCzqkY7Kj2BHpbwQtU7orQhNH/DE50dMjz91ngxq4/QtYb 06saV21xkjkZeIFhNwaaPtjI5EYzWfEZCD4N8PcPskvMIK64vP4I1Dtyvp1fi1JU2AkA nXed1jORXE7S8YgFCzH3f5ALiYnGi819+ZzpcD7DW7JqDwEV+ZKrIILjZlWvdgIqENjC kYlELQyYvnh7hEgM3Y6TNV93xQqCdwOQlFwzVcNmdQd/ul3K1H+tRZXjxg9y2Q9PF38W Nt9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JEkHopJZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7si7565210pfl.232.2022.02.20.09.54.42; Sun, 20 Feb 2022 09:55:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JEkHopJZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240779AbiBTPtd (ORCPT + 99 others); Sun, 20 Feb 2022 10:49:33 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:39344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240431AbiBTPt1 (ORCPT ); Sun, 20 Feb 2022 10:49:27 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46EE4532D3 for ; Sun, 20 Feb 2022 07:49:06 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id bg10so26968317ejb.4 for ; Sun, 20 Feb 2022 07:49:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mTYsVbDSvOAH4QYIkGgRDagMrOUXfFeihf5F3hcHwp0=; b=JEkHopJZKie/5DpEOnlLTQV+KtGhmNVl3cJqcA0CZGOZErKJxZvqO3g3aK6DHFuetW giGTYma2wCdU7kOlbDPI5FziKoLV4ukFcPnKy25N5PKSmZHKhBjN3aZ/m84nFwITAa98 MhbGTXcAi/C1z3l1WMYeB8VTeYm7vzHvuU2seJX29IH3/NjBjhvqw8cfHNlanrai3C9B +UOZJ85ITqFLAqqs4lADjzCO+FNI6WRoiXwklnkTP2oG2Q67n9uwBKLOZmJZQ82GaAHB QTqOBElNBjhMChfMUTcFHm+RSP9wLcSx0uqoFVeSvNrfWWCINHgjkqM0iNi19sR9zwly v3BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mTYsVbDSvOAH4QYIkGgRDagMrOUXfFeihf5F3hcHwp0=; b=fNccwCiBi9TbBIYC97QNHtx8bUMYDdKLbRyoyzn0G1/s6ot0zO2zzvO0RXzGxO6XBz Qs897Vrs2oaATxvplgqhqfSALTWjZBAZtgtzcSsAIVWRZGTLnRItTCUZbhpsJp1PEFym anW0zPXhJ+3GKEcFWv3KNRz/LEz/uHt5lmyiqjF40gYey9dC/S+QB3FzXelD/fEgmg5M 7gYv9wRxhwTxbzhuLRIaXWHnTM1IUoxYbS50Ce3mwlBmcQEV+1EpWWZ/RONp0aDFxxgh cgUajKpJleXoZUuHMIWY5GFce8PQPZYedvyJIMVwnMzCjCH9BNwmT4Auhcw3cBjqwFBt mBJg== X-Gm-Message-State: AOAM533n8b1umprW8HrR40qGB7i0pb3j2LWSvrjaTLrN86r7vwzg2wQv 1fY4NNyVMDEQpj1fKcOXmIo= X-Received: by 2002:a17:906:538f:b0:6ce:98ad:3100 with SMTP id g15-20020a170906538f00b006ce98ad3100mr13288782ejo.566.1645372144858; Sun, 20 Feb 2022 07:49:04 -0800 (PST) Received: from localhost.localdomain (ip5f5abb8f.dynamic.kabel-deutschland.de. [95.90.187.143]) by smtp.gmail.com with ESMTPSA id ew6sm4178979ejc.217.2022.02.20.07.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 07:49:04 -0800 (PST) From: Michael Straube To: gregkh@linuxfoundation.org Cc: Larry.Finger@lwfinger.net, phil@philpotter.co.uk, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Michael Straube Subject: [PATCH 2/3] staging: r8188eu: refactor rtw_ch2freq() Date: Sun, 20 Feb 2022 16:48:46 +0100 Message-Id: <20220220154847.7521-3-straube.linux@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220154847.7521-1-straube.linux@gmail.com> References: <20220220154847.7521-1-straube.linux@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since we have only channel values from 1 to 14 we can convert the array ch_freq_map to a simple integer array and use the indices as channel numbers. This simplifies the code and avoids looping through the array to get the frequency. Signed-off-by: Michael Straube --- drivers/staging/r8188eu/core/rtw_rf.c | 40 +++++++++++---------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_rf.c b/drivers/staging/r8188eu/core/rtw_rf.c index 51425971782b..945a40e6511a 100644 --- a/drivers/staging/r8188eu/core/rtw_rf.c +++ b/drivers/staging/r8188eu/core/rtw_rf.c @@ -8,32 +8,24 @@ #include "../include/recv_osdep.h" #include "../include/xmit_osdep.h" -struct ch_freq { - u32 channel; - u32 frequency; +static const u32 ch_freq_map[] = { + 2412, + 2417, + 2422, + 2427, + 2432, + 2437, + 2442, + 2447, + 2452, + 2457, + 2462, + 2467, + 2472, + 2484 }; -static struct ch_freq ch_freq_map[] = { - {1, 2412}, {2, 2417}, {3, 2422}, {4, 2427}, {5, 2432}, - {6, 2437}, {7, 2442}, {8, 2447}, {9, 2452}, {10, 2457}, - {11, 2462}, {12, 2467}, {13, 2472}, {14, 2484}, -}; - -static int ch_freq_map_num = ARRAY_SIZE(ch_freq_map); - u32 rtw_ch2freq(u32 channel) { - u8 i; - u32 freq = 0; - - for (i = 0; i < ch_freq_map_num; i++) { - if (channel == ch_freq_map[i].channel) { - freq = ch_freq_map[i].frequency; - break; - } - } - if (i == ch_freq_map_num) - freq = 2412; - - return freq; + return ch_freq_map[channel - 1]; } -- 2.35.1