From: Dmitri Belimov <d.belimov@gmail.com>
To: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Stefan Ringel <stefan.ringel@arcor.de>,
Felipe Sanches <juca@members.fsf.org>,
Bee Hock Goh <beehock@gmail.com>,
Luis Henrique Fagundes <lhfagundes@hacklab.com.br>,
Linux Media Mailing List <linux-media@vger.kernel.org>,
Jarod Wilson <jarod@redhat.com>
Subject: [PATCH] tm6000: rework init code
Date: Thu, 13 Jan 2011 12:46:07 +0900 [thread overview]
Message-ID: <20110113124607.2d81ff84@glory.local> (raw)
In-Reply-To: <4D0BFF4B.3060001@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2224 bytes --]
Hi
Rework device init part. Move common code part to a function.
Usefull for register multiple devices like video, radio, vbi etc.
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 <d.belimov@gmail.com>
With my best regards, Dmitry.
[-- Attachment #2: tm6000_video_init.patch --]
[-- Type: text/x-patch, Size: 2059 bytes --]
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 <d.belimov@gmail.com>
next prev parent reply other threads:[~2011-01-13 3:45 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-07 5:28 [RFC PATCH] Audio standards on tm6000 Mauro Carvalho Chehab
2010-10-08 19:03 ` Dmitri Belimov
2010-10-08 11:52 ` Mauro Carvalho Chehab
2010-10-12 18:28 ` Dmitri Belimov
2010-10-12 16:54 ` Stefan Ringel
2010-10-13 14:13 ` Dmitri Belimov
[not found] ` <20101129174412.08f2001c@glory.local>
[not found] ` <4CF51C9E.6040600@arcor.de>
[not found] ` <20101201144704.43b58f2c@glory.local>
[not found] ` <4CF67AB9.6020006@arcor.de>
[not found] ` <20101202134128.615bbfa0@glory.local>
[not found] ` <4CF71CF6.7080603@redhat.com>
[not found] ` <20101206010934.55d07569@glory.local>
[not found] ` <4CFBF62D.7010301@arcor.de>
[not found] ` <20101206190230.2259d7ab@glory.local>
[not found] ` <4CFEA3D2.4050309@arcor.de>
[not found] ` <20101208125539.739e2ed2@glory.local>
[not found] ` <4CFFAD1E.7040004@arcor.de>
2010-12-14 3:23 ` tm6000 and IR Dmitri Belimov
2010-12-14 16:27 ` Stefan Ringel
2010-12-15 7:46 ` Dmitri Belimov
2010-12-15 15:52 ` Stefan Ringel
2010-12-16 3:26 ` Dmitri Belimov
2010-12-16 9:38 ` Dmitri Belimov
2010-12-16 17:12 ` Stefan Ringel
2010-12-17 1:46 ` Dmitri Belimov
2010-12-17 5:18 ` Stefan Ringel
2010-12-17 7:08 ` Dmitri Belimov
2010-12-18 0:24 ` Mauro Carvalho Chehab
2010-12-18 13:56 ` Andy Walls
2010-12-18 15:55 ` Stefan Ringel
2010-12-20 5:41 ` Dmitri Belimov
2010-12-21 22:36 ` Jarod Wilson
2010-12-22 8:57 ` [PATCH] Rework and fix IR Dmitri Belimov
2011-01-13 3:46 ` Dmitri Belimov [this message]
2011-01-20 6:05 ` [PATCH] tm6000: add/rework reg.defines Dmitri Belimov
2011-01-20 19:25 ` Stefan Ringel
2011-01-20 23:20 ` Dmitri Belimov
2011-02-17 5:12 ` tm6000 and radio Dmitri Belimov
2011-02-17 20:58 ` Mauro Carvalho Chehab
2011-02-18 1:11 ` [PATCH] tm6000: add radio Dmitri Belimov
2011-03-01 4:55 ` [PATCH] tm6000: add audio conf for new cards Dmitri Belimov
2011-03-18 0:08 ` [PATCH] tm6000: fix s-video input Dmitri Belimov
2011-03-19 6:46 ` Stefan Ringel
2011-03-23 2:49 ` Dmitri Belimov
2011-04-19 5:29 ` [PATCH v1] tm6000: rework standards Dmitri Belimov
2011-04-19 6:42 ` Stefan Ringel
2011-05-04 16:18 ` Stefan Ringel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110113124607.2d81ff84@glory.local \
--to=d.belimov@gmail.com \
--cc=beehock@gmail.com \
--cc=jarod@redhat.com \
--cc=juca@members.fsf.org \
--cc=lhfagundes@hacklab.com.br \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@redhat.com \
--cc=stefan.ringel@arcor.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).