Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp980507ybz; Sat, 25 Apr 2020 08:23:27 -0700 (PDT) X-Google-Smtp-Source: APiQypJ6M7GJBHqUOPSyMdCRFR2t4OWg2Xdz/lTmP2HOUwKpElJfQw/qOEYSrugzMxvjWKvS8x4U X-Received: by 2002:a17:906:4e02:: with SMTP id z2mr11869110eju.212.1587828207108; Sat, 25 Apr 2020 08:23:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587828207; cv=none; d=google.com; s=arc-20160816; b=p1eFBB2+T9pO0CHCV3cLbQ1pKXzSNGGcN9guXfwAViRcvV9Y42fg39kne08X2v8dgO d5913ccqji7G1Ywzw49+Xq9qwRtV5n5t0tWMdaJ/OEL7zCMFfDY1/1LH0PjKKq0UafSj TmVkFOxhhNclBsjcw0CoBvZC1ydNfmPBRP87QtXVfFN7QmTauAANNcBTYsJ77R+OHZIf JL4NNkVr/fY3x2I1obOG9w54iYzZZZ6+85fQYCienwG6mVnHVWZtHOjSU5RWVVA7Ekd3 ok58GhakHKfAkLC56InwlIBrAV0/gUkB55ZM0y8OplW1oOXnyh8cdLIGJqY3dAqEWSoP ZESA== 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=yYTHEcYa9SqFyX3/RW3Ocu0aCmdo5xL1m5y5Z2lujM8mTb263SGyGZb41jSgkGxX4E mXeUMG4pOEhUZ4Hi+HyHN7QQBdha1HvYBERSipR8poIjX19rJbx7next/gHy0A1qYrzd KQEpMYXAkR4PZ8ylnpyoPssJIEZ6JTrEXA1QlXhulzZPNdRGGvN6SkRUwkhcfz7D2i/W 871/29urwo8B4WYnZ3y/qQG6xAN0DWfts9WaSPrF2/eOc667oDdJqcZcellJkKgVu7GU UdDzSbeNsSgzLD7ng6O1pNOoDZJpxIVJjgCpsbXWCoBDb4Ot5UbHJ/rgwhutEj2qoMcI 8H3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b="b2HK/aFj"; 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 u7si2957680edp.132.2020.04.25.08.23.03; Sat, 25 Apr 2020 08:23:27 -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="b2HK/aFj"; 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 S1726191AbgDYPSt (ORCPT + 99 others); Sat, 25 Apr 2020 11:18:49 -0400 Received: from mout.gmx.net ([212.227.17.21]:53825 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726143AbgDYPSq (ORCPT ); Sat, 25 Apr 2020 11:18:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1587827919; bh=V4mn8XWOidnV35lpF6k4PLGi3eJjtkJ7bFNpYDHAFrM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=b2HK/aFjc/NgxS6heebeuWwbwZIfNCCAoaM5rua60nDkJ4gtc3mBKKWJwoGyxA7NM rIMUfhxM+YuGff2CoDmpIo4w3IBTryflI8UntDPjLSWERAjrlAiYBKuaukQC/unqzH nfcPEF69w4NTBd99/9IhmRIEEV4ArQNcNuoH/qMU= 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 1MysRu-1jFlbp2aos-00w0Sg; Sat, 25 Apr 2020 17:18:39 +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, Joe Perches Subject: [PATCH v2 3/3] staging: vt6656: Remove duplicate code in vnt_rf_table_download Date: Sat, 25 Apr 2020 17:17:47 +0200 Message-Id: <20200425151747.8199-4-oscar.carter@gmx.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200425151747.8199-1-oscar.carter@gmx.com> References: <20200425151747.8199-1-oscar.carter@gmx.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:O0CbRDf92e151EFq1Tr62g7Abu264JDJMB0TQsvFCf5to1J4tlu uGIVzKgrpivucPTVkS+I8nfkoGKr11imtK/QLaOPiAwHgbHVhFLLnn0eRvVZ2TTV5TZa+Nv gEPHNRtQNLnQqISLx141zUzA8Nl3+52wFDezmPueb6NiG7WAmCTSJoZQ8rOvupN0L3esxfa M5UVFcCM/0BzuP2kYL2SQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:P7XaABjktOo=:mYSAPT8yUikJd6o5uzjVjS gbDmQcWxXGAC3xuAmK3hAeKzD5YKhZJhVjMMF+yg2jcYjB8JDULAVnaKRBcJMh9ec4q6h4PF6 CEySSeGjEhmGwmtuEMPmOLxBKvyMJL2djBRlky3xfOh1LEttp9n53cQQNo6MuhcXOnedf9/qH +BEJBfXN216SyRi64avQNC/DJNdNQr6j+AcFXrXfwXDvSCithxujcgasrnQ1JANNN1bAhBplD jax4KgkMOe06tajaEYYHJk4xoZwFihftT0rDkVFWruUkVZjxvswJ8lZG1CK8sksiPMkw917EW sKs930UIixEYuDP4Qi4MkEt3XURVG6HxiwTsW63KN5umAS1RQZzRDt0liXp5nUh1TxR52mRj8 yO7QDclwdHx09pe47aBW8xQTyOqRaConXy73wmeVJJt7sKvs9d0DK/btMyed1VKsPoP9P9K3R J2HJuPUPi7v48hk/GbaPLo4iy+4QdURiKLPo2s8TfoS6FxJ8U4qNDuQ1LB2NLDdtd1F6xWfJ/ 7gsqYOTmXJeG0upG49MLPpBUDcwCmYKlK5bOP6R93w5H4aMndwaLEVYh1CLDEJrTbKR08DV3S b1dU3f3fPIKssujyPnqo1ojgrWnFnXgSYd6U+5SjqJ9YU8Peum57VjYmZ97CNwQwGMP1hkQpi sEeYg/0K6k5Z56E4dh+fg50BZHeJVGDQyPZ77X2UxQL/kFQ4Q6wA9AZN+uWiSoPE85sHQMBGe YnDUMyDTnmqLopIob1+fNCwOr1P6xUwW52WiWmPx70oLhiddhPaMlIj52gfdZ06m1Nkqw9b+Z 9fwcWciwZnHR3EMLbtxiZ7p/RSxn05xsjtMvS2A8NmULgQIJGtF4KxBKoDERhejZGaaNMdNL4 D07/Elpj2yPVoILjshnFKh1zXgI9bXB31S+O9P0L93c53q5XsGuoh0IhBSb+qte+ED+S2YhLb rBsTV/pfW2RojsptfcWpZBks1H93WVpgTyN7owe6EVtlQlCRT9Vopn/Zpnu3uL2QdNhyYlhYf /wi0RniHbiP51oNarAiZe8OSvYqvu6/dc+DUSt0MBYZVaKGUbMUi2RaEz8VuDdT5DJKxC1C55 9ZHbLxNoc1aUnEvk7HR+tXyHC+YN7Q3Ql2mU7l1g1RtS1lYGUZPyWqqysk6g5bG4zCH/OfJYq 2n1S+yVnMEZRVNgGf9EhBFEMrSLQTAjiLhmkzwN/1KYYVIbHXdeFBE2z2RhiiL5o1v67oLan9 HtbuntM+1gcnL7P9x 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