diff options
author | Jean Delvare <khali@linux-fr.org> | 2006-03-22 01:48:37 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-03-23 09:24:08 -0500 |
commit | daf72f408c66aee4ac939f614293a78841aa7717 (patch) | |
tree | 1a86c84e20fcc021a247510ca3ea089119a185c3 /drivers/media | |
parent | 6eb5d9ca9f1496108cb86f2d9bfc2db5d9c796fe (diff) |
V4L/DVB (3568c): zoran: Init cleanups
Cleanups to the zr36057 initialization:
* Drop intermediate local variables.
* Single error path.
Also drop a needless cast on kfree.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/zoran_card.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c index 246e67cd8b51..a2e528ccf28a 100644 --- a/drivers/media/video/zoran_card.c +++ b/drivers/media/video/zoran_card.c | |||
@@ -995,10 +995,7 @@ test_interrupts (struct zoran *zr) | |||
995 | static int __devinit | 995 | static int __devinit |
996 | zr36057_init (struct zoran *zr) | 996 | zr36057_init (struct zoran *zr) |
997 | { | 997 | { |
998 | u32 *mem; | 998 | int j, err; |
999 | void *vdev; | ||
1000 | unsigned mem_needed; | ||
1001 | int j; | ||
1002 | int two = 2; | 999 | int two = 2; |
1003 | int zero = 0; | 1000 | int zero = 0; |
1004 | 1001 | ||
@@ -1049,19 +1046,16 @@ zr36057_init (struct zoran *zr) | |||
1049 | 1046 | ||
1050 | /* allocate memory *before* doing anything to the hardware | 1047 | /* allocate memory *before* doing anything to the hardware |
1051 | * in case allocation fails */ | 1048 | * in case allocation fails */ |
1052 | mem_needed = BUZ_NUM_STAT_COM * 4; | 1049 | zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL); |
1053 | mem = kzalloc(mem_needed, GFP_KERNEL); | 1050 | zr->video_dev = kmalloc(sizeof(struct video_device), GFP_KERNEL); |
1054 | vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL); | 1051 | if (!zr->stat_com || !zr->video_dev) { |
1055 | if (!mem || !vdev) { | ||
1056 | dprintk(1, | 1052 | dprintk(1, |
1057 | KERN_ERR | 1053 | KERN_ERR |
1058 | "%s: zr36057_init() - kmalloc (STAT_COM) failed\n", | 1054 | "%s: zr36057_init() - kmalloc (STAT_COM) failed\n", |
1059 | ZR_DEVNAME(zr)); | 1055 | ZR_DEVNAME(zr)); |
1060 | kfree(vdev); | 1056 | err = -ENOMEM; |
1061 | kfree(mem); | 1057 | goto exit_free; |
1062 | return -ENOMEM; | ||
1063 | } | 1058 | } |
1064 | zr->stat_com = mem; | ||
1065 | for (j = 0; j < BUZ_NUM_STAT_COM; j++) { | 1059 | for (j = 0; j < BUZ_NUM_STAT_COM; j++) { |
1066 | zr->stat_com[j] = 1; /* mark as unavailable to zr36057 */ | 1060 | zr->stat_com[j] = 1; /* mark as unavailable to zr36057 */ |
1067 | } | 1061 | } |
@@ -1069,16 +1063,11 @@ zr36057_init (struct zoran *zr) | |||
1069 | /* | 1063 | /* |
1070 | * Now add the template and register the device unit. | 1064 | * Now add the template and register the device unit. |
1071 | */ | 1065 | */ |
1072 | zr->video_dev = vdev; | ||
1073 | memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template)); | 1066 | memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template)); |
1074 | strcpy(zr->video_dev->name, ZR_DEVNAME(zr)); | 1067 | strcpy(zr->video_dev->name, ZR_DEVNAME(zr)); |
1075 | if (video_register_device(zr->video_dev, VFL_TYPE_GRABBER, | 1068 | err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr); |
1076 | video_nr) < 0) { | 1069 | if (err < 0) |
1077 | zoran_unregister_i2c(zr); | 1070 | goto exit_unregister; |
1078 | kfree((void *) zr->stat_com); | ||
1079 | kfree(vdev); | ||
1080 | return -1; | ||
1081 | } | ||
1082 | 1071 | ||
1083 | zoran_init_hardware(zr); | 1072 | zoran_init_hardware(zr); |
1084 | if (*zr_debug > 2) | 1073 | if (*zr_debug > 2) |
@@ -1092,6 +1081,13 @@ zr36057_init (struct zoran *zr) | |||
1092 | zr->zoran_proc = NULL; | 1081 | zr->zoran_proc = NULL; |
1093 | zr->initialized = 1; | 1082 | zr->initialized = 1; |
1094 | return 0; | 1083 | return 0; |
1084 | |||
1085 | exit_unregister: | ||
1086 | zoran_unregister_i2c(zr); | ||
1087 | exit_free: | ||
1088 | kfree(zr->stat_com); | ||
1089 | kfree(zr->video_dev); | ||
1090 | return err; | ||
1095 | } | 1091 | } |
1096 | 1092 | ||
1097 | static void | 1093 | static void |
@@ -1121,7 +1117,7 @@ zoran_release (struct zoran *zr) | |||
1121 | btwrite(0, ZR36057_SPGPPCR); | 1117 | btwrite(0, ZR36057_SPGPPCR); |
1122 | free_irq(zr->pci_dev->irq, zr); | 1118 | free_irq(zr->pci_dev->irq, zr); |
1123 | /* unmap and free memory */ | 1119 | /* unmap and free memory */ |
1124 | kfree((void *) zr->stat_com); | 1120 | kfree(zr->stat_com); |
1125 | zoran_proc_cleanup(zr); | 1121 | zoran_proc_cleanup(zr); |
1126 | iounmap(zr->zr36057_mem); | 1122 | iounmap(zr->zr36057_mem); |
1127 | pci_disable_device(zr->pci_dev); | 1123 | pci_disable_device(zr->pci_dev); |