struct em2820 *dev; 
struct em2820 *dev = *devhandle; 
static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,			   int minor, int model){	struct em2820 *dev;	int retval = -ENOMEM;	int errCode, i;	unsigned int maxh, maxw;	struct usb_interface *uif;	/* allocate memory for our device state and initialize it */	dev = kmalloc(sizeof(*dev), GFP_KERNEL);	if (dev == NULL) {		em2820_err(DRIVER_NAME ": out of memory!\n");		return -ENOMEM;	}	memset(dev, 0x00, sizeof(*dev));	snprintf(dev->name, 29, "em2820 #%d", minor);	dev->udev = udev;	dev->model = model;	init_MUTEX(&dev->lock);	init_waitqueue_head(&dev->open);	dev->em2820_write_regs = em2820_write_regs;	dev->em2820_read_reg = em2820_read_reg;	dev->em2820_read_reg_req_len = em2820_read_reg_req_len;	dev->em2820_write_regs_req = em2820_write_regs_req;	dev->em2820_read_reg_req = em2820_read_reg_req;	dev->has_tuner = em2820_boards[model].has_tuner;	dev->has_msp34xx = em2820_boards[model].has_msp34xx;	dev->tda9887_conf = em2820_boards[model].tda9887_conf;	dev->decoder = em2820_boards[model].decoder;	if (tuner >= 0)		dev->tuner_type = tuner;	else		dev->tuner_type = em2820_boards[model].tuner_type;	dev->video_inputs = em2820_boards[model].vchannels;	for (i = 0; i < TVNORMS; i++)		if (em2820_boards[model].norm == tvnorms[i].mode)			break;	if (i == TVNORMS)		i = 0;	dev->tvnorm = &tvnorms[i];	/* set default norm */	em2820_videodbg("tvnorm=%s\n", dev->tvnorm->name);	maxw = norm_maxw(dev);	maxh = norm_maxh(dev);	/* set default image size */	dev->width = maxw;	dev->height = maxh;	dev->interlaced = EM2820_INTERLACED_DEFAULT;	dev->field_size = dev->width * dev->height;	dev->frame_size =	    dev->interlaced ? dev->field_size << 1 : dev->field_size;	dev->bytesperline = dev->width * 2;	dev->hscale = 0;	dev->vscale = 0;	dev->ctl_input = 2;	/* setup video picture settings for saa7113h */	memset(&dev->vpic, 0, sizeof(dev->vpic));	dev->vpic.colour = 128 << 8;	dev->vpic.hue = 128 << 8;	dev->vpic.brightness = 128 << 8;	dev->vpic.contrast = 192 << 8;	dev->vpic.whiteness = 128 << 8;	/* This one isn't used */	dev->vpic.depth = 16;	dev->vpic.palette = VIDEO_PALETTE_YUV422;	/* compute alternate max packet sizes */	uif = dev->udev->actconfig->interface[0];	dev->alt_max_pkt_size[0] = 0;	for (i = 1; i <= EM2820_MAX_ALT; i++) {		u16 tmp =		    le16_to_cpu(uif->altsetting[i].endpoint[1].desc.				wMaxPacketSize);		dev->alt_max_pkt_size[i] =		    (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);	}#ifdef CONFIG_MODULES	/* request some modules */	if (dev->decoder == EM2820_SAA7113)		request_module("saa7113");	if (dev->decoder == EM2820_SAA7114)		request_module("saa7114");	if (dev->decoder == EM2820_TVP5150)		request_module("tvp5150");	if (dev->has_tuner)		request_module("tuner");	if (dev->tda9887_conf)		request_module("tda9887");#endif	errCode = em2820_config(dev);	if (errCode) {		em2820_errdev("error configuring device\n");		kfree(dev);		return -ENOMEM;	}	down(&dev->lock);	/* register i2c bus */	em2820_i2c_register(dev);	/* Do board specific init and eeprom reading */	em2820_card_setup(dev);	/* configure the device */	em2820_config_i2c(dev);	up(&dev->lock);	errCode = em2820_config(dev);#ifdef CONFIG_MODULES	if (dev->has_msp34xx)		request_module("msp3400");#endif	/* allocate and fill v4l2 device struct */	dev->vdev = video_device_alloc();	if (NULL == dev->vdev) {		em2820_errdev("cannot allocate video_device.\n");		kfree(dev);		return -ENOMEM;	}	dev->vdev->owner = THIS_MODULE;	dev->vdev->type = VID_TYPE_CAPTURE;	if (dev->has_tuner)		dev->vdev->type |= VID_TYPE_TUNER;	dev->vdev->hardware = 0;	dev->vdev->fops = &em2820_v4l_fops;	dev->vdev->minor = -1;	dev->vdev->dev = &dev->udev->dev;	dev->vdev->release = video_device_release;	snprintf(dev->vdev->name, sizeof(dev->vdev->name), "%s",		 "em2820 video");	video_set_drvdata(dev->vdev, dev);	/* register v4l2 device */	down(&dev->lock);	if ((retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1))) {		em2820_errdev("unable to register video device (error=%i).\n",			      retval);		up(&dev->lock);		video_set_drvdata(dev->vdev, NULL);		video_device_release(dev->vdev);		kfree(dev);		return -ENODEV;	}	if (dev->has_msp34xx) {		/* Send a reset to other chips via gpio */		em2820_write_regs_req(dev, 0x00, 0x08, "\xf7", 1);		udelay(2500);		em2820_write_regs_req(dev, 0x00, 0x08, "\xff", 1);		udelay(2500);	}	video_mux(dev, 0);	up(&dev->lock);	em2820_info("V4L2 device registered as /dev/video%d\n",		    dev->vdev->minor);	*devhandle = dev;	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/596d92d5128d308b5a79f21c3e72c87f5fc7e58b/em28xx-video.c/buggy/drivers/media/video/em28xx/em28xx-video.c