From patchwork Mon Dec 10 21:37:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 1860041 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id CA344DFB79 for ; Mon, 10 Dec 2012 21:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752209Ab2LJVhq (ORCPT ); Mon, 10 Dec 2012 16:37:46 -0500 Received: from smtp207.alice.it ([82.57.200.103]:39912 "EHLO smtp207.alice.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751849Ab2LJVhn (ORCPT ); Mon, 10 Dec 2012 16:37:43 -0500 Received: from jcn (82.59.100.230) by smtp207.alice.it (8.6.058.01) id 5091339C05FE46A3; Mon, 10 Dec 2012 22:37:42 +0100 Received: from ao2 by jcn with local (Exim 4.80) (envelope-from ) id 1TiB2j-0005dm-Bu; Mon, 10 Dec 2012 22:37:41 +0100 From: Antonio Ospite To: linux-media@vger.kernel.org Cc: Antonio Ospite , Antti Palosaari Subject: [PATCHv2 3/9] [media] m920x: factor out a m920x_write_seq() function Date: Mon, 10 Dec 2012 22:37:11 +0100 Message-Id: <1355175437-21623-4-git-send-email-ospite@studenti.unina.it> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355175437-21623-1-git-send-email-ospite@studenti.unina.it> References: <1352158096-17737-1-git-send-email-ospite@studenti.unina.it> <1355175437-21623-1-git-send-email-ospite@studenti.unina.it> X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This is in preparation for the vp7049 frontend attach function which is going to set a sequence of registers as well. Signed-off-by: Antonio Ospite --- drivers/media/usb/dvb-usb/m920x.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/media/usb/dvb-usb/m920x.c b/drivers/media/usb/dvb-usb/m920x.c index 433696d..23416fb 100644 --- a/drivers/media/usb/dvb-usb/m920x.c +++ b/drivers/media/usb/dvb-usb/m920x.c @@ -63,6 +63,21 @@ static inline int m920x_write(struct usb_device *udev, u8 request, return ret; } +static inline int m920x_write_seq(struct usb_device *udev, u8 request, + struct m920x_inits *seq) +{ + int ret; + while (seq->address) { + ret = m920x_write(udev, request, seq->data, seq->address); + if (ret != 0) + return ret; + + seq++; + } + + return ret; +} + static int m920x_init(struct dvb_usb_device *d, struct m920x_inits *rc_seq) { int ret = 0, i, epi, flags = 0; @@ -71,15 +86,10 @@ static int m920x_init(struct dvb_usb_device *d, struct m920x_inits *rc_seq) /* Remote controller init. */ if (d->props.rc.legacy.rc_query) { deb("Initialising remote control\n"); - while (rc_seq->address) { - if ((ret = m920x_write(d->udev, M9206_CORE, - rc_seq->data, - rc_seq->address)) != 0) { - deb("Initialising remote control failed\n"); - return ret; - } - - rc_seq++; + ret = m920x_write_seq(d->udev, M9206_CORE, rc_seq); + if (ret != 0) { + deb("Initialising remote control failed\n"); + return ret; } deb("Initialising remote control success\n");