From patchwork Mon May 16 22:25:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 789962 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4GMPfDb009754 for ; Mon, 16 May 2011 22:25:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754465Ab1EPWZb (ORCPT ); Mon, 16 May 2011 18:25:31 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:44044 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751535Ab1EPWZb (ORCPT ); Mon, 16 May 2011 18:25:31 -0400 Received: by wya21 with SMTP id 21so3797871wya.19 for ; Mon, 16 May 2011 15:25:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:from:to:content-type:date:message-id :mime-version:x-mailer:content-transfer-encoding; bh=OypVtfWNoAmix2Terheqc4KDhEsezxeDX48AQ7zyimA=; b=LwTPrBequLrX+ZQ9iuJFDVg3434gsP3S8fLg2bSfFNnIK4TBwG/tHJ7GZST8IUxJms w9qVWixjfnn1okESQHSVEwh1IFy+LPeDyec36jLylEJa1HS74EYqad/Kq0kzm+Y7Lgvy QeIta+GNKk5yyyBmpyrC5/xN3sBjLFtpCFnAE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; b=LR5zVrXVt86c+umflkSCS6/+MUVwAfqHcsE1Na1EHgwzbwYMnmN4HMCVf0+Z2xhpQz 8ab5XcPQDT8Fh4YMCVFbCTsRsYv6jakpEbEup1vaz0f9t2MZmDUHpyUg9Si25j2CoEoh GNnF3zQ6ije9YVRuRUhKQekCxTZPDjfu5E+yo= Received: by 10.227.201.144 with SMTP id fa16mr2936587wbb.19.1305584729892; Mon, 16 May 2011 15:25:29 -0700 (PDT) Received: from [10.64.64.65] (92.41.251.198.threembb.co.uk [92.41.251.198]) by mx.google.com with ESMTPS id w25sm3422884wbd.22.2011.05.16.15.25.28 (version=SSLv3 cipher=OTHER); Mon, 16 May 2011 15:25:29 -0700 (PDT) Subject: [PATCH ] v1.87 DM04/QQBOX provide error frontend detach/memory release. From: Malcolm Priestley To: linux-media@vger.kernel.org Date: Mon, 16 May 2011 23:25:23 +0100 Message-ID: <1305584723.2481.13.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 16 May 2011 22:25:42 +0000 (UTC) Remove and free any unused frontend attach on firmware change and provide memory release using priv_exit callback. Other minor changes fix le16 warning. remove unnecessary lme2510_kill_urb. Moving of rc_core is still on TODO list. Requires Patch: dvb-usb provide exit any structure inside priv. Signed-off-by: Malcolm Priestley --- drivers/media/dvb/dvb-usb/lmedm04.c | 93 +++++++++++++---------------------- 1 files changed, 34 insertions(+), 59 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/lmedm04.c b/drivers/media/dvb/dvb-usb/lmedm04.c index f36f471..c636149 100644 --- a/drivers/media/dvb/dvb-usb/lmedm04.c +++ b/drivers/media/dvb/dvb-usb/lmedm04.c @@ -831,7 +831,7 @@ static int lme_firmware_switch(struct usb_device *udev, int cold) cold_fw = !cold; - if (udev->descriptor.idProduct == 0x1122) { + if (le16_to_cpu(udev->descriptor.idProduct) == 0x1122) { switch (dvb_usb_lme2510_firmware) { default: dvb_usb_lme2510_firmware = TUNER_S0194; @@ -901,20 +901,6 @@ static int lme_firmware_switch(struct usb_device *udev, int cold) return ret; } -static int lme2510_kill_urb(struct usb_data_stream *stream) -{ - int i; - - for (i = 0; i < stream->urbs_submitted; i++) { - deb_info(3, "killing URB no. %d.", i); - /* stop the URB */ - usb_kill_urb(stream->urb_list[i]); - } - stream->urbs_submitted = 0; - - return 0; -} - static struct tda10086_config tda10086_config = { .demod_address = 0x1c, .invert = 0, @@ -1052,9 +1038,11 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap) } -end: if (ret) { - kfree(adap->fe); - adap->fe = NULL; +end: if (ret < 0) { + if (adap->fe) { + dvb_frontend_detach(adap->fe); + adap->fe = NULL; + } return -ENODEV; } @@ -1126,6 +1114,30 @@ static int lme2510_powerup(struct dvb_usb_device *d, int onoff) return ret; } +static int lme2510_priv_exit(struct dvb_usb_device *d) +{ + struct lme2510_state *st = d->priv; + + if (st->usb_buffer != NULL) { + st->i2c_talk_onoff = 1; + st->signal_lock = 0; + st->signal_level = 0; + st->signal_sn = 0; + kfree(st->usb_buffer); + } + + if (st->lme_urb != NULL) { + usb_kill_urb(st->lme_urb); + usb_free_coherent(d->udev, 5000, st->buffer, + st->lme_urb->transfer_dma); + info("Interrupt Service Stopped"); + rc_unregister_device(d->rc_dev); + info("Remote Stopped"); + } + + return 0; +} + /* DVB USB Driver stuff */ static struct dvb_usb_device_properties lme2510_properties; static struct dvb_usb_device_properties lme2510c_properties; @@ -1178,6 +1190,7 @@ MODULE_DEVICE_TABLE(usb, lme2510_table); static struct dvb_usb_device_properties lme2510_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .size_of_priv = sizeof(struct lme2510_state), + .priv_exit = lme2510_priv_exit, .num_adapters = 1, .adapter = { { @@ -1220,6 +1233,7 @@ static struct dvb_usb_device_properties lme2510_properties = { static struct dvb_usb_device_properties lme2510c_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .size_of_priv = sizeof(struct lme2510_state), + .priv_exit = lme2510_priv_exit, .num_adapters = 1, .adapter = { { @@ -1258,49 +1272,10 @@ static struct dvb_usb_device_properties lme2510c_properties = { } }; -static void *lme2510_exit_int(struct dvb_usb_device *d) -{ - struct lme2510_state *st = d->priv; - struct dvb_usb_adapter *adap = &d->adapter[0]; - void *buffer = NULL; - - if (adap != NULL) { - lme2510_kill_urb(&adap->stream); - adap->feedcount = 0; - } - - if (st->lme_urb != NULL) { - st->i2c_talk_onoff = 1; - st->signal_lock = 0; - st->signal_level = 0; - st->signal_sn = 0; - buffer = st->usb_buffer; - usb_kill_urb(st->lme_urb); - usb_free_coherent(d->udev, 5000, st->buffer, - st->lme_urb->transfer_dma); - info("Interrupt Service Stopped"); - rc_unregister_device(d->rc_dev); - info("Remote Stopped"); - } - return buffer; -} - -static void lme2510_exit(struct usb_interface *intf) -{ - struct dvb_usb_device *d = usb_get_intfdata(intf); - void *usb_buffer; - - if (d != NULL) { - usb_buffer = lme2510_exit_int(d); - dvb_usb_device_exit(intf); - kfree(usb_buffer); - } -} - static struct usb_driver lme2510_driver = { .name = "LME2510C_DVB-S", .probe = lme2510_probe, - .disconnect = lme2510_exit, + .disconnect = dvb_usb_device_exit, .id_table = lme2510_table, }; @@ -1327,5 +1302,5 @@ module_exit(lme2510_module_exit); MODULE_AUTHOR("Malcolm Priestley "); MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0"); -MODULE_VERSION("1.86"); +MODULE_VERSION("1.87"); MODULE_LICENSE("GPL");