struct wbsd_host* host = NULL; struct mmc_host* mmc = NULL; int ret;  /* * Allocate MMC structure. */ mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev); if (!mmc) return -ENOMEM;  host = mmc_priv(mmc); host->mmc = mmc;  /* * Scan for hardware. */ ret = wbsd_scan(host); if (ret) goto freemmc;  /* * Reset the chip. */ wbsd_write_config(host, WBSD_CONF_SWRST, 1); wbsd_write_config(host, WBSD_CONF_SWRST, 0);  /* * Allocate I/O ports. */ ret = wbsd_request_regions(host); if (ret) goto release;  /* * Set host parameters. */ mmc->ops = &wbsd_ops; mmc->f_min = 375000; mmc->f_max = 24000000; mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34;  spin_lock_init(&host->lock);  /* * Select SD/MMC function. */ wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);  /* * Set up card detection. */ wbsd_write_config(host, WBSD_CONF_PINS, 0x02);  /* * Configure I/O port. */ wbsd_write_config(host, WBSD_CONF_PORT_HI, host->base >> 8); wbsd_write_config(host, WBSD_CONF_PORT_LO, host->base & 0xff);  /* * Allocate interrupt. */ ret = request_irq(irq, wbsd_irq, SA_SHIRQ, DRIVER_NAME, host); if (ret) goto release;  host->irq = irq;  /* * Set up tasklets. */ tasklet_init(&host->card_tasklet, wbsd_tasklet_card, (unsigned long)host); tasklet_init(&host->fifo_tasklet, wbsd_tasklet_fifo, (unsigned long)host); tasklet_init(&host->crc_tasklet, wbsd_tasklet_crc, (unsigned long)host); tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout, (unsigned long)host); tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish, (unsigned long)host); tasklet_init(&host->block_tasklet, wbsd_tasklet_block, (unsigned long)host);  /* * Configure interrupt. */ wbsd_write_config(host, WBSD_CONF_IRQ, host->irq);  /* * Allocate DMA. */ wbsd_init_dma(host);  /* * If all went well, then configure DMA. */ if (host->dma >= 0) wbsd_write_config(host, WBSD_CONF_DRQ, host->dma);  /* * Maximum number of segments. Worst case is one sector per segment * so this will be 64kB/512. */ mmc->max_hw_segs = 128; mmc->max_phys_segs = 128;  /* * Maximum number of sectors in one transfer. Also limited by 64kB * buffer. */ mmc->max_sectors = 128;  /* * Maximum segment size. Could be one segment with the maximum number * of segments. */ mmc->max_seg_size = mmc->max_sectors * 512;  /* * Enable chip. */ wbsd_write_config(host, WBSD_CONF_ENABLE, 1);  /* * Power up chip. */ wbsd_write_config(host, WBSD_CONF_POWER, 0x20);  /* * Power Management stuff. No idea how this works. * Not tested. */ #ifdef CONFIG_PM wbsd_write_config(host, WBSD_CONF_PME, 0xA0); #endif  /* * Reset the chip into a known state. */ wbsd_init_device(host);  dev_set_drvdata(dev, mmc);  /* * Add host to MMC layer. */ mmc_add_host(mmc);  printk(KERN_INFO "%s: W83L51xD id %x at 0x%x irq %d dma %d\n", mmc->host_name, (int)host->chip_id, (int)host->base, (int)host->irq, (int)host->dma);  return 0;  release: wbsd_release_regions(host);  freemmc: mmc_free_host(mmc);  return ret; 
return wbsd_init(dev, io, irq, dma, 0); 
static int wbsd_probe(struct device* dev){	struct wbsd_host* host = NULL;	struct mmc_host* mmc = NULL;	int ret;		/*	 * Allocate MMC structure.	 */	mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev);	if (!mmc)		return -ENOMEM;		host = mmc_priv(mmc);	host->mmc = mmc;		/*	 * Scan for hardware.	 */	ret = wbsd_scan(host);	if (ret)		goto freemmc;	/*	 * Reset the chip.	 */		wbsd_write_config(host, WBSD_CONF_SWRST, 1);	wbsd_write_config(host, WBSD_CONF_SWRST, 0);	/*	 * Allocate I/O ports.	 */	ret = wbsd_request_regions(host);	if (ret)		goto release;	/*	 * Set host parameters.	 */	mmc->ops = &wbsd_ops;	mmc->f_min = 375000;	mmc->f_max = 24000000;	mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34;		spin_lock_init(&host->lock);	/*	 * Select SD/MMC function.	 */	wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);		/*	 * Set up card detection.	 */	wbsd_write_config(host, WBSD_CONF_PINS, 0x02);		/*	 * Configure I/O port.	 */	wbsd_write_config(host, WBSD_CONF_PORT_HI, host->base >> 8);	wbsd_write_config(host, WBSD_CONF_PORT_LO, host->base & 0xff);	/*	 * Allocate interrupt.	 */	ret = request_irq(irq, wbsd_irq, SA_SHIRQ, DRIVER_NAME, host);	if (ret)		goto release;		host->irq = irq;		/*	 * Set up tasklets.	 */	tasklet_init(&host->card_tasklet, wbsd_tasklet_card, (unsigned long)host);	tasklet_init(&host->fifo_tasklet, wbsd_tasklet_fifo, (unsigned long)host);	tasklet_init(&host->crc_tasklet, wbsd_tasklet_crc, (unsigned long)host);	tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout, (unsigned long)host);	tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish, (unsigned long)host);	tasklet_init(&host->block_tasklet, wbsd_tasklet_block, (unsigned long)host);		/*	 * Configure interrupt.	 */	wbsd_write_config(host, WBSD_CONF_IRQ, host->irq);		/*	 * Allocate DMA.	 */	wbsd_init_dma(host);		/*	 * If all went well, then configure DMA.	 */	if (host->dma >= 0)		wbsd_write_config(host, WBSD_CONF_DRQ, host->dma);		/*	 * Maximum number of segments. Worst case is one sector per segment	 * so this will be 64kB/512.	 */	mmc->max_hw_segs = 128;	mmc->max_phys_segs = 128;		/*	 * Maximum number of sectors in one transfer. Also limited by 64kB	 * buffer.	 */	mmc->max_sectors = 128;		/*	 * Maximum segment size. Could be one segment with the maximum number	 * of segments.	 */	mmc->max_seg_size = mmc->max_sectors * 512;		/*	 * Enable chip.	 */	wbsd_write_config(host, WBSD_CONF_ENABLE, 1);		/*	 * Power up chip.	 */	wbsd_write_config(host, WBSD_CONF_POWER, 0x20);		/*	 * Power Management stuff. No idea how this works.	 * Not tested.	 */#ifdef CONFIG_PM	wbsd_write_config(host, WBSD_CONF_PME, 0xA0);#endif	/*	 * Reset the chip into a known state.	 */	wbsd_init_device(host);		dev_set_drvdata(dev, mmc);		/*	 * Add host to MMC layer.	 */	mmc_add_host(mmc);	printk(KERN_INFO "%s: W83L51xD id %x at 0x%x irq %d dma %d\n",		mmc->host_name, (int)host->chip_id, (int)host->base,		(int)host->irq, (int)host->dma);	return 0;release:	wbsd_release_regions(host);freemmc:	mmc_free_host(mmc);	return ret;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/85bcc13072c54592596c5b41d40d1c6a18b04e19/wbsd.c/clean/drivers/mmc/wbsd.c