From patchwork Thu Jan 13 03:46:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitri Belimov X-Patchwork-Id: 475221 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 p0D3jhxV010093 for ; Thu, 13 Jan 2011 03:45:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751621Ab1AMDp3 (ORCPT ); Wed, 12 Jan 2011 22:45:29 -0500 Received: from mail-ey0-f174.google.com ([209.85.215.174]:42290 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750978Ab1AMDp2 (ORCPT ); Wed, 12 Jan 2011 22:45:28 -0500 Received: by eye27 with SMTP id 27so643077eye.19 for ; Wed, 12 Jan 2011 19:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type; bh=LIWB+c5OwzTOcMmafIObi1WHVQacsTlu5lvlLKQ3RoA=; b=vgujimDUtsDODgprvf3MBF3FT+y34mUaGg+VGjDqNbzCwsRFu8gLB2xV2Kx5sZbdTh skboigxGldTDVlfkNLUnV2nE+GmuWQ2RZIvtIN/k8dj4okzaRCDgsNXqsEzmW6C5Lt5y nV5uZaAUEWcOVl5yvYI2z86e1GDPGvqpQ2RxU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=mjVkroVDsBIu+mPqFbd1F2DdlMcFboMEEkSvAjBjzws+95Krulr6Twj5Z/CCvl8wxU PcypMiJU9FP7pt/RimXSIhupDslKGSVv8UhckoypEbV6YsDWSByW0SCip1PTEQCyr9IU XBxv1qnh7l8QsEuEmEBTnfOZxwMrT/6fSgvek= Received: by 10.14.127.136 with SMTP id d8mr1418354eei.23.1294890327135; Wed, 12 Jan 2011 19:45:27 -0800 (PST) Received: from glory.local ([83.234.160.236]) by mx.google.com with ESMTPS id t5sm1039576eeh.20.2011.01.12.19.45.23 (version=SSLv3 cipher=RC4-MD5); Wed, 12 Jan 2011 19:45:25 -0800 (PST) Date: Thu, 13 Jan 2011 12:46:07 +0900 From: Dmitri Belimov To: Mauro Carvalho Chehab Cc: Stefan Ringel , Felipe Sanches , Bee Hock Goh , Luis Henrique Fagundes , Linux Media Mailing List , Jarod Wilson Subject: [PATCH] tm6000: rework init code Message-ID: <20110113124607.2d81ff84@glory.local> In-Reply-To: <4D0BFF4B.3060001@redhat.com> References: <4CAD5A78.3070803@redhat.com> <20101008150301.2e3ceaff@glory.local> <4CAF0602.6050002@redhat.com> <20101012142856.2b4ee637@glory.local> <4CB492D4.1000609@arcor.de> <20101129174412.08f2001c@glory.local> <4CF51C9E.6040600@arcor.de> <20101201144704.43b58f2c@glory.local> <4CF67AB9.6020006@arcor.de> <20101202134128.615bbfa0@glory.local> <4CF71CF6.7080603@redhat.com> <20101206010934.55d07569@glory.local> <4CFBF62D.7010301@arcor.de> <20101206190230.2259d7ab@glory.local> <4CFEA3D2.4050309@arcor.de> <20101208125539.739e2ed2@glory.local> <4CFFAD1E.7040004@arcor.de> <20101214122325.5cdea67e@glory.local> <4D079ADF.2000705@arcor.de> <20101215164634.44846128@glory.local> <4D08E43C.8080002@arcor.de> <20101216183844.6258734e@glory.local> <4D0A4883.20804@arcor.de> <20101217104633.7c9d10d7@glory.local> <4D0AF2A7.6080100@arcor.de> <20101217160854.16a1f754@glory.local> <4D0BFF4B.3060001@redhat.com> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; i486-pc-linux-gnu) Mime-Version: 1.0 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]); Thu, 13 Jan 2011 03:46:22 +0000 (UTC) diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c index 8fe017c..4d866cc 100644 --- a/drivers/staging/tm6000/tm6000-video.c +++ b/drivers/staging/tm6000/tm6000-video.c @@ -1450,29 +1450,55 @@ static struct video_device tm6000_template = { * ------------------------------------------------------------------ */ -int tm6000_v4l2_register(struct tm6000_core *dev) +static struct video_device *vdev_init(struct tm6000_core *dev, + const struct video_device + *template, const char *type_name) { - int ret = -1; struct video_device *vfd; vfd = video_device_alloc(); - if(!vfd) { + if (NULL == vfd) + return NULL; + + *vfd = *template; + vfd->v4l2_dev = &dev->v4l2_dev; + vfd->release = video_device_release; + vfd->debug = tm6000_debug; + vfd->lock = &dev->lock; + + snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); + + video_set_drvdata(vfd, dev); + return vfd; +} + +int tm6000_v4l2_register(struct tm6000_core *dev) +{ + int ret = -1; + + dev->vfd = vdev_init(dev, &tm6000_template, "video"); + + if (!dev->vfd) { + printk(KERN_INFO "%s: can't register video device\n", + dev->name); return -ENOMEM; } - dev->vfd = vfd; /* init video dma queues */ INIT_LIST_HEAD(&dev->vidq.active); INIT_LIST_HEAD(&dev->vidq.queued); - memcpy(dev->vfd, &tm6000_template, sizeof(*(dev->vfd))); - dev->vfd->debug = tm6000_debug; - dev->vfd->lock = &dev->lock; + ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr); - vfd->v4l2_dev = &dev->v4l2_dev; - video_set_drvdata(vfd, dev); + if (ret < 0) { + printk(KERN_INFO "%s: can't register video device\n", + dev->name); + return ret; + } + + printk(KERN_INFO "%s: registered device %s\n", + dev->name, video_device_node_name(dev->vfd)); - ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr); printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret); return ret; } Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov