From patchwork Mon Mar 21 10:19:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Mickler X-Patchwork-Id: 647561 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 p2LAKt9p017696 for ; Mon, 21 Mar 2011 10:20:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752954Ab1CUKTf (ORCPT ); Mon, 21 Mar 2011 06:19:35 -0400 Received: from ist.d-labs.de ([213.239.218.44]:44312 "EHLO mx01.d-labs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752925Ab1CUKTd (ORCPT ); Mon, 21 Mar 2011 06:19:33 -0400 Received: from schatten.dmk.lab (f053218247.adsl.alicedsl.de [78.53.218.247]) by mx01.d-labs.de (Postfix) with ESMTPSA id 9C3727F8CD; Mon, 21 Mar 2011 11:19:32 +0100 (CET) Received: by schatten.dmk.lab (Postfix, from userid 1000) id F167818002; Mon, 21 Mar 2011 11:19:31 +0100 (CET) From: Florian Mickler To: mchehab@infradead.org Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, pb@linuxtv.org, Florian Mickler Subject: [PATCH 3/9] [media] vp702x: preallocate memory on device probe Date: Mon, 21 Mar 2011 11:19:08 +0100 Message-Id: <1300702754-16376-4-git-send-email-florian@mickler.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1300702754-16376-1-git-send-email-florian@mickler.org> References: <1300702754-16376-1-git-send-email-florian@mickler.org> 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, 21 Mar 2011 10:20:56 +0000 (UTC) diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c index 25536f9..569c93f 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.c +++ b/drivers/media/dvb/dvb-usb/vp702x.c @@ -15,6 +15,7 @@ * see Documentation/dvb/README.dvb-usb for more information */ #include "vp702x.h" +#include /* debug */ int dvb_usb_vp702x_debug; @@ -29,10 +30,6 @@ struct vp702x_adapter_state { u8 pid_filter_state; }; -struct vp702x_device_state { - u8 power_state; -}; - /* check for mutex FIXME */ int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) { @@ -241,8 +238,38 @@ static struct dvb_usb_device_properties vp702x_properties; static int vp702x_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf, &vp702x_properties, - THIS_MODULE, NULL, adapter_nr); + struct dvb_usb_device *d; + struct vp702x_device_state *st; + int ret; + + ret = dvb_usb_device_init(intf, &vp702x_properties, + THIS_MODULE, &d, adapter_nr); + if (ret) + goto out; + + st = d->priv; + st->buf_len = 16; + st->buf = kmalloc(st->buf_len, GFP_KERNEL); + if (!st->buf) { + ret = -ENOMEM; + dvb_usb_device_exit(intf); + goto out; + } + mutex_init(&st->buf_mutex); + +out: + return ret; + +} + +static void vp702x_usb_disconnect(struct usb_interface *intf) +{ + struct dvb_usb_device *d = usb_get_intfdata(intf); + struct vp702x_device_state *st = d->priv; + mutex_lock(&st->buf_mutex); + kfree(st->buf); + mutex_unlock(&st->buf_mutex); + dvb_usb_device_exit(intf); } static struct usb_device_id vp702x_usb_table [] = { @@ -309,7 +336,7 @@ static struct dvb_usb_device_properties vp702x_properties = { static struct usb_driver vp702x_usb_driver = { .name = "dvb_usb_vp702x", .probe = vp702x_usb_probe, - .disconnect = dvb_usb_device_exit, + .disconnect = vp702x_usb_disconnect, .id_table = vp702x_usb_table, }; diff --git a/drivers/media/dvb/dvb-usb/vp702x.h b/drivers/media/dvb/dvb-usb/vp702x.h index c2f97f9..86960c6 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.h +++ b/drivers/media/dvb/dvb-usb/vp702x.h @@ -98,6 +98,14 @@ extern int dvb_usb_vp702x_debug; #define RESET_TUNER 0xBE /* IN i: 0, v: 0, no extra buffer */ +struct vp702x_device_state { + u8 power_state; + struct mutex buf_mutex; + int buf_len; + u8 *buf; +}; + + extern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d); extern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec);