Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp848978ybz; Sat, 25 Apr 2020 05:42:27 -0700 (PDT) X-Google-Smtp-Source: APiQypInsVtDXbYRa5KMEXspnHyhh45GhqU1jqjuOADKCUUhH6O/HYhbebrgQA+fci0MQv8ffbjc X-Received: by 2002:a17:907:94c8:: with SMTP id dn8mr11719930ejc.286.1587818546865; Sat, 25 Apr 2020 05:42:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587818546; cv=none; d=google.com; s=arc-20160816; b=p1+kR/G5LrTJXnRNRrLxyC9SlqYGMKY0Ga6cQPis2RSdssiH2QOA/b3u4iSSL66Ixa QjqKh7J8ehrOVeudfI1Siq5F1g7K6Swssh1B+LnJFiCFOFg3CRH9CcvvKFmisc+tOlMS fdp3RjTAl7pA1nuiv75mleCvWkYTK/V6JuJCkoWnO43AJyHtlffkkX8E7TqsP/urO9dO rybthqCkt3TwJYdQq1rEt8LAcHMQ5yRdR7ozwlllQemD6tlkAIzUxUfVKUpyvyPeo33i k9ntEUWaJ4oqctMaIKAjxgzFAY6UrvCGDPP4cMKBotYWq+oGst4nuOBmzv3/iWl/oiBh K4HA== 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=HhH80leerTbIsf1+wjXHe2npRulAHiGPwMwaCPeyAQ0=; b=aJYwrXuxBMjfltQqd+71bMTOYidqfbGciyyQLj2JNEpmQ78/GT+yv5g0abhXU03Dve KHNuebtO0zyJ6Wbayd8IlSa9EOyljgq+o4d2dtbNR8+QLdw3utrXDVbkhFyF3oI8ylnf QUs1yOKWI+60AHnZyexHiG9I1BhoDb8mH3jL6YWywOwUNLk1qxHqO4Hcwmt8eirl5t7x 87pxOtZHOOyG3dAN6tz+SLmkAgcIpPWgsUigTzW3Wy5M/HXQ0dOt2VfwAXzo6UadlyBi N1609pumrHx2CGJAoMwKTA6pdaT9Y7YIR/AQTwn9FlDATrtnObmsE3mDMYaRGP6mD8yg tnxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=DideTJiB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ck24si5081602ejb.45.2020.04.25.05.42.03; Sat, 25 Apr 2020 05:42:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=DideTJiB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726151AbgDYMj5 (ORCPT + 99 others); Sat, 25 Apr 2020 08:39:57 -0400 Received: from mout.gmx.net ([212.227.15.19]:48565 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbgDYMj4 (ORCPT ); Sat, 25 Apr 2020 08:39:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1587818391; bh=V4mn8XWOidnV35lpF6k4PLGi3eJjtkJ7bFNpYDHAFrM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=DideTJiB8slIn57i6tk5GiN8UIMfAoDmIKzYHYyQMAEuNQLmih/z/6GShZPvTb4wO g01Y2hE6Oe7L7A5QhUxlUfzQ3TCschYdobkUDxw62R6ipgcCYc7AxozJI2XlcKBRcK ab1tlYkZQwqaEEKDuZplwvzg+raJRrv+WQNgCQoY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([83.52.229.196]) by mail.gmx.com (mrgmx004 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MBUqL-1jLOki1TNn-00D2no; Sat, 25 Apr 2020 14:39:51 +0200 From: Oscar Carter To: Forest Bond , Greg Kroah-Hartman Cc: Oscar Carter , Malcolm Priestley , Quentin Deslandes , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] staging: vt6656: Remove duplicate code in vnt_rf_table_download Date: Sat, 25 Apr 2020 14:38:44 +0200 Message-Id: <20200425123844.7959-4-oscar.carter@gmx.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200425123844.7959-1-oscar.carter@gmx.com> References: <20200425123844.7959-1-oscar.carter@gmx.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:jqFWb70n9RfPKgUObno8Iw7CMmVxtFSt4+RfiveChfRkOcYAhBu IKwax26Nf3eDVNaBLhEa6abtpz6Qvym96PAmR1e3Rl0SGHTPnP9nJRWQUt6Mi+uQNbcot4R md0AWx/88QtPQsObcWnSBeMrYQiKMAC7AWaTuYAxf/7tpPiwPAhkwi47Rm9N6gvtakJWAuZ z0vxNJ1DB0llerY+cDpnQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:LoMAp7C5TW8=:1t2tuXAJZXVaYNrNcE7NnC XY7MRqDjGFQEHQ/XG6qzyHGMKwV32XvKQeqIkqarfZEB8+N2XPY3Xp6KmQn9E3hiRJR6IQUgb daxY8d+yYF1/DaNKcmJQ9vdhksqVYxnSBq3OaQW7Cm4qGmAywnQ/T2Y7w9fA/hrnnMW6xJHFP F3E5uPy8xDe3s8cFgVbUxWWWn8ByFZUvxcga67s0K30zbt8TNi86P9r3yFUc2kJSiVm1nzxqz r3ydMguppQoe4eCtGKgLuAYLZJaFbgYKRgpwO8+8bN1qI3pyd9OQsS7Tnyykvjn5NHBBwBRqx MnQjibK+yF/SNiyeSpqQqm4PkAP/gKWK1oTj0fl2YG3feIWIr4CudqAgReTn+v4RIZlv4t/jt jLJS5HzEct1oksRtgy5/XF0jUA57VrpJRDJaU4PZVnq2Vhwa0bk2GI+SLm187+UVDc8YmsDzk EvtKZQXPRBPXOZhuaXMKYSoZw1Rfnkh/n58b5JXe4dmqSZS+rBF9oQ9yAX6Q/3E31UZV5nW/c wa1L3QJvbQ9l21sGM4flh8GlvbONRUHNMs7MDceQHL01iPlMCLv77HNpL1iemi7UaYhuV2SXI MyTfxPeko1EBUH9xWM0enjAKxTCPFEBpsY9i5xKoKFMzX/TL9kZbG9a8te5limkkZhQcbfXUg VfEfLNJfwsrQ08SV9T3zomRVuw7zS3fbgRMMJvPdpCLwrpKFiAO/jR2h2zxghGi8hknLxTm+Y frzF44boLMjj89TJs/b6IEtp9UXX5cuq70m4YeUNmrCRkphATk3I7mc7cyIgLUonZ9RtRrMUn SDeJfFhMOmoenvgrsBI8sMGPCx82fVTQMfpdHzF1tZcYRe39VdLAOaVM3KetetqouiPsfXRqn X5xV2bVsj7kQMDOMNPB3rRryc24M68x0Ay2BTGOcqJmeKMD5Rsg5fICuVjCBRkXoTKH1Ix2PS fAvtI1K4pcFVBPZxHQVCT98QGXgfKn/BX7lW6oS+mNKkLg5QK4PrybWDDHyCVzPo6fRjShf+g FUzhs6E8cs6jbUPWG2flc24Z26Igm19E+73Ay66d4yWoJNSpqezkaKRCsglz4WjN2ww7z/3yI yDlT3q3K9RnvfI1CsulqXhnRurA9NLQXeDpZ0ycql60vJ8tU1EtTZ4AEdSdppJdTI+Gmh88De Sc5RUgGpju+kIf2kYimCtZKINWNSsC5kdsZfM4MO7hYfnYwPuINmjlWrWLCYi9O3TZB2Y/AJR viNmYMfHYR41h21/3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace three while loops with three calls to the vnt_control_out_blocks function. This way avoid repeat a functionality that already exists. Also remove the variables that now are not used. Signed-off-by: Oscar Carter =2D-- drivers/staging/vt6656/rf.c | 65 +++++++------------------------------ 1 file changed, 12 insertions(+), 53 deletions(-) diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 888b6fcb6e91..420e9869af76 100644 =2D-- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -769,7 +769,6 @@ int vnt_rf_table_download(struct vnt_private *priv) int ret; u16 length1 =3D 0, length2 =3D 0, length3 =3D 0; u8 *addr1 =3D NULL, *addr2 =3D NULL, *addr3 =3D NULL; - u16 length, value; switch (priv->rf_type) { case RF_AL2230: @@ -822,40 +821,14 @@ int vnt_rf_table_download(struct vnt_private *priv) return ret; /* Channel Table 0 */ - value =3D 0; - while (length2 > 0) { - if (length2 >=3D 64) - length =3D 64; - else - length =3D length2; - - ret =3D vnt_control_out(priv, MESSAGE_TYPE_WRITE, value, - MESSAGE_REQUEST_RF_CH0, length, addr2); - if (ret) - return ret; - - length2 -=3D length; - value +=3D length; - addr2 +=3D length; - } - - /* Channel table 1 */ - value =3D 0; - while (length3 > 0) { - if (length3 >=3D 64) - length =3D 64; - else - length =3D length3; - - ret =3D vnt_control_out(priv, MESSAGE_TYPE_WRITE, value, - MESSAGE_REQUEST_RF_CH1, length, addr3); - if (ret) - return ret; + ret =3D vnt_control_out_blocks(priv, VNT_REG_BLOCK_SIZE, + MESSAGE_REQUEST_RF_CH0, length2, addr2); + if (ret) + return ret; - length3 -=3D length; - value +=3D length; - addr3 +=3D length; - } + /* Channel Table 1 */ + ret =3D vnt_control_out_blocks(priv, VNT_REG_BLOCK_SIZE, + MESSAGE_REQUEST_RF_CH1, length3, addr3); if (priv->rf_type =3D=3D RF_AIROHA7230) { length1 =3D CB_AL7230_INIT_SEQ * 3; @@ -869,25 +842,11 @@ int vnt_rf_table_download(struct vnt_private *priv) if (ret) return ret; - /* Channel Table 0 */ - value =3D 0; - while (length2 > 0) { - if (length2 >=3D 64) - length =3D 64; - else - length =3D length2; - - ret =3D vnt_control_out(priv, MESSAGE_TYPE_WRITE, value, - MESSAGE_REQUEST_RF_CH2, length, - addr2); - if (ret) - return ret; - - length2 -=3D length; - value +=3D length; - addr2 +=3D length; - } + /* Channel Table 2 */ + ret =3D vnt_control_out_blocks(priv, VNT_REG_BLOCK_SIZE, + MESSAGE_REQUEST_RF_CH2, length2, + addr2); } - return 0; + return ret; } =2D- 2.20.1