コード例 #1
0
void our_disconnect(struct usb_interface *intf){
struct us_data *us = usb_get_intfdata(intf);
//---------------------------
pr_info("23 disconnect\n");
	US_DEBUGP("storage_disconnect() called\n");
	quiesce_and_remove_host(us);
	release_everything(us);
}
コード例 #2
0
static void rts51x_disconnect(struct usb_interface *intf)
{
	struct rts51x_chip *chip = (struct rts51x_chip *)usb_get_intfdata(intf);

	RTS51X_DEBUGP("rts51x_disconnect() called\n");
	quiesce_and_remove_host(chip);
	release_everything(chip);
}
コード例 #3
0
ファイル: rtsx.c プロジェクト: acton393/linux
static void rtsx_remove(struct pci_dev *pci)
{
	struct rtsx_dev *dev = pci_get_drvdata(pci);

	dev_info(&pci->dev, "rtsx_remove() called\n");

	quiesce_and_remove_host(dev);
	release_everything(dev);
}
コード例 #4
0
ファイル: rtsx.c プロジェクト: GerardGarcia/linux
static void __devexit rtsx_remove(struct pci_dev *pci)
{
	struct rtsx_dev *dev = (struct rtsx_dev *)pci_get_drvdata(pci);

	printk(KERN_INFO "rtsx_remove() called\n");

	quiesce_and_remove_host(dev);
	release_everything(dev);

	pci_set_drvdata(pci, NULL);
}
コード例 #5
0
ファイル: rtsx.c プロジェクト: acton393/linux
static int rtsx_probe(struct pci_dev *pci,
				const struct pci_device_id *pci_id)
{
	struct Scsi_Host *host;
	struct rtsx_dev *dev;
	int err = 0;
	struct task_struct *th;

	dev_dbg(&pci->dev, "Realtek PCI-E card reader detected\n");

	err = pcim_enable_device(pci);
	if (err < 0) {
		dev_err(&pci->dev, "PCI enable device failed!\n");
		return err;
	}

	err = pci_request_regions(pci, CR_DRIVER_NAME);
	if (err < 0) {
		dev_err(&pci->dev, "PCI request regions for %s failed!\n",
			CR_DRIVER_NAME);
		return err;
	}

	/*
	 * Ask the SCSI layer to allocate a host structure, with extra
	 * space at the end for our private rtsx_dev structure.
	 */
	host = scsi_host_alloc(&rtsx_host_template, sizeof(*dev));
	if (!host) {
		dev_err(&pci->dev, "Unable to allocate the scsi host\n");
		return -ENOMEM;
	}

	dev = host_to_rtsx(host);
	memset(dev, 0, sizeof(struct rtsx_dev));

	dev->chip = kzalloc(sizeof(struct rtsx_chip), GFP_KERNEL);
	if (!dev->chip) {
		err = -ENOMEM;
		goto errout;
	}

	spin_lock_init(&dev->reg_lock);
	mutex_init(&(dev->dev_mutex));
	init_completion(&dev->cmnd_ready);
	init_completion(&dev->control_exit);
	init_completion(&dev->polling_exit);
	init_completion(&(dev->notify));
	init_completion(&dev->scanning_done);
	init_waitqueue_head(&dev->delay_wait);

	dev->pci = pci;
	dev->irq = -1;

	dev_info(&pci->dev, "Resource length: 0x%x\n",
		 (unsigned int)pci_resource_len(pci, 0));
	dev->addr = pci_resource_start(pci, 0);
	dev->remap_addr = ioremap_nocache(dev->addr, pci_resource_len(pci, 0));
	if (!dev->remap_addr) {
		dev_err(&pci->dev, "ioremap error\n");
		err = -ENXIO;
		goto errout;
	}

	/*
	 * Using "unsigned long" cast here to eliminate gcc warning in
	 * 64-bit system
	 */
	dev_info(&pci->dev, "Original address: 0x%lx, remapped address: 0x%lx\n",
		 (unsigned long)(dev->addr), (unsigned long)(dev->remap_addr));

	dev->rtsx_resv_buf = dmam_alloc_coherent(&pci->dev, RTSX_RESV_BUF_LEN,
			&dev->rtsx_resv_buf_addr, GFP_KERNEL);
	if (!dev->rtsx_resv_buf) {
		dev_err(&pci->dev, "alloc dma buffer fail\n");
		err = -ENXIO;
		goto errout;
	}
	dev->chip->host_cmds_ptr = dev->rtsx_resv_buf;
	dev->chip->host_cmds_addr = dev->rtsx_resv_buf_addr;
	dev->chip->host_sg_tbl_ptr = dev->rtsx_resv_buf + HOST_CMDS_BUF_LEN;
	dev->chip->host_sg_tbl_addr = dev->rtsx_resv_buf_addr +
				      HOST_CMDS_BUF_LEN;

	dev->chip->rtsx = dev;

	rtsx_init_options(dev->chip);

	dev_info(&pci->dev, "pci->irq = %d\n", pci->irq);

	if (dev->chip->msi_en) {
		if (pci_enable_msi(pci) < 0)
			dev->chip->msi_en = 0;
	}

	if (rtsx_acquire_irq(dev) < 0) {
		err = -EBUSY;
		goto errout;
	}

	pci_set_master(pci);
	synchronize_irq(dev->irq);

	rtsx_init_chip(dev->chip);

	/*
	 * set the supported max_lun and max_id for the scsi host
	 * NOTE: the minimal value of max_id is 1
	 */
	host->max_id = 1;
	host->max_lun = dev->chip->max_lun;

	/* Start up our control thread */
	th = kthread_run(rtsx_control_thread, dev, CR_DRIVER_NAME);
	if (IS_ERR(th)) {
		dev_err(&pci->dev, "Unable to start control thread\n");
		err = PTR_ERR(th);
		goto errout;
	}
	dev->ctl_thread = th;

	err = scsi_add_host(host, &pci->dev);
	if (err) {
		dev_err(&pci->dev, "Unable to add the scsi host\n");
		goto errout;
	}

	/* Start up the thread for delayed SCSI-device scanning */
	th = kthread_run(rtsx_scan_thread, dev, "rtsx-scan");
	if (IS_ERR(th)) {
		dev_err(&pci->dev, "Unable to start the device-scanning thread\n");
		complete(&dev->scanning_done);
		quiesce_and_remove_host(dev);
		err = PTR_ERR(th);
		goto errout;
	}

	/* Start up the thread for polling thread */
	th = kthread_run(rtsx_polling_thread, dev, "rtsx-polling");
	if (IS_ERR(th)) {
		dev_err(&pci->dev, "Unable to start the device-polling thread\n");
		quiesce_and_remove_host(dev);
		err = PTR_ERR(th);
		goto errout;
	}
	dev->polling_thread = th;

	pci_set_drvdata(pci, dev);

	return 0;

	/* We come here if there are any problems */
errout:
	dev_err(&pci->dev, "rtsx_probe() failed\n");
	release_everything(dev);

	return err;
}
コード例 #6
0
ファイル: rtsx.c プロジェクト: uran1980/RTS5209-linux-driver
static int rtsx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
{
	struct Scsi_Host *host;
	struct rtsx_dev *dev;
	int err = 0;
	struct task_struct *th;

	printk(KERN_INFO "--- %s ---\n", DRIVER_MAKE_TIME);

	err = pci_enable_device(pci);
	if (err < 0) {
		printk(KERN_ERR "PCI enable device failed!\n");
		return err;
	}

	err = pci_request_regions(pci, CR_DRIVER_NAME);
	if (err < 0) {
		printk(KERN_ERR "PCI request regions for %s failed!\n", CR_DRIVER_NAME);
		pci_disable_device(pci);
		return err;
	}

	/*
	 * Ask the SCSI layer to allocate a host structure, with extra
	 * space at the end for our private rtsx_dev structure.
	 */
	host = scsi_host_alloc(&rtsx_host_template, sizeof(*dev));
	if (!host) {
		printk(KERN_ERR "Unable to allocate the scsi host\n");
		pci_release_regions(pci);
		pci_disable_device(pci);
		return -ENOMEM;
	}

	dev = host_to_rtsx(host);
	memset(dev, 0, sizeof(struct rtsx_dev));

	dev->chip = (struct rtsx_chip *)kmalloc(sizeof(struct rtsx_chip), GFP_KERNEL);
	if (dev->chip == NULL) {
		goto errout;
	}
	memset(dev->chip, 0, sizeof(struct rtsx_chip));

	spin_lock_init(&dev->reg_lock);
	mutex_init(&(dev->dev_mutex));
	sema_init(&(dev->sema), 0);
	init_completion(&(dev->notify));
	init_waitqueue_head(&dev->delay_wait);

	dev->pci = pci;
	dev->irq = -1;

	printk(KERN_INFO "Resource length: 0x%x\n", (unsigned int)pci_resource_len(pci,0));
	dev->addr = pci_resource_start(pci, 0);
	dev->remap_addr = ioremap_nocache(dev->addr, pci_resource_len(pci,0));
	if (dev->remap_addr == NULL) {
		printk(KERN_ERR "ioremap error\n");
		err = -ENXIO;
		goto errout;
	}

	printk(KERN_INFO "Original address: 0x%lx, remapped address: 0x%lx\n", 
			(unsigned long)(dev->addr), (unsigned long)(dev->remap_addr));

	dev->rtsx_resv_buf = dma_alloc_coherent(&(pci->dev), RTSX_RESV_BUF_LEN, 
			&(dev->rtsx_resv_buf_addr), GFP_KERNEL);
	if (dev->rtsx_resv_buf == NULL) {
		printk(KERN_ERR "alloc dma buffer fail\n");
		err = -ENXIO;
		goto errout;
	}
	dev->chip->host_cmds_ptr = dev->rtsx_resv_buf;
	dev->chip->host_cmds_addr = dev->rtsx_resv_buf_addr;
	dev->chip->host_sg_tbl_ptr = dev->rtsx_resv_buf + HOST_CMDS_BUF_LEN;
	dev->chip->host_sg_tbl_addr = dev->rtsx_resv_buf_addr + HOST_CMDS_BUF_LEN;

	dev->chip->rtsx = dev;
	
	rtsx_init_options(dev->chip);

	printk(KERN_INFO "pci->irq = %d\n", pci->irq);
	
	if (dev->chip->msi_en) {
		if (pci_enable_msi(pci) < 0) {
			dev->chip->msi_en = 0;
		}
	}
	
	if (rtsx_acquire_irq(dev) < 0) {
		err = -EBUSY;
		goto errout;
	}

	pci_set_master(pci);
	synchronize_irq(dev->irq);

	err = scsi_add_host(host, &pci->dev);
	if (err) {
		printk(KERN_ERR "Unable to add the scsi host\n");
		goto errout;
	}

	rtsx_init_chip(dev->chip);
	
	
	th = kthread_create(rtsx_control_thread, dev, CR_DRIVER_NAME);
	if (IS_ERR(th)) {
		printk(KERN_ERR "Unable to start control thread\n");
		err = PTR_ERR(th);
		goto errout;
	}

	/* Take a reference to the host for the control thread and
	 * count it among all the threads we have launched.  Then
	 * start it up. */
	scsi_host_get(rtsx_to_host(dev));
	atomic_inc(&total_threads);
	wake_up_process(th);
	
	
	th = kthread_create(rtsx_scan_thread, dev, "rtsx-scan");
	if (IS_ERR(th)) {
		printk(KERN_ERR "Unable to start the device-scanning thread\n");
		quiesce_and_remove_host(dev);
		err = PTR_ERR(th);
		goto errout;
	}

	/* Take a reference to the host for the scanning thread and
	 * count it among all the threads we have launched.  Then
	 * start it up. */
	scsi_host_get(rtsx_to_host(dev));
	atomic_inc(&total_threads);
	wake_up_process(th);

	
	th = kthread_create(rtsx_polling_thread, dev, "rtsx-polling");
	if (IS_ERR(th)) {
		printk(KERN_ERR "Unable to start the device-polling thread\n");
		quiesce_and_remove_host(dev);
		err = PTR_ERR(th);
		goto errout;
	}

	/* Take a reference to the host for the polling thread and
	 * count it among all the threads we have launched.  Then
	 * start it up. */
	scsi_host_get(rtsx_to_host(dev));
	atomic_inc(&total_threads);
	wake_up_process(th);

	pci_set_drvdata(pci, dev);

	return 0;

	
errout:
	printk(KERN_ERR "rtsx_probe() failed\n");
	release_everything(dev);

	return err;
}
コード例 #7
0
static int rts51x_probe(struct usb_interface *intf,
			const struct usb_device_id *id)
{
	struct Scsi_Host *host;
	struct rts51x_chip *chip;
	struct rts51x_usb *rts51x;
	int result;
	struct task_struct *th;

	RTS51X_DEBUGP("%s detected\n", RTS51X_NAME);

	rts51x = kzalloc(sizeof(struct rts51x_usb), GFP_KERNEL);
	if (!rts51x) {
		printk(KERN_WARNING RTS51X_TIP
		       "Unable to allocate rts51x_usb\n");
		return -ENOMEM;
	}

	host = scsi_host_alloc(&rts51x_host_template, sizeof(*chip));
	if (!host) {
		printk(KERN_WARNING RTS51X_TIP
		       "Unable to allocate the scsi host\n");
		kfree(rts51x);
		return -ENOMEM;
	}

	host->max_cmd_len = 16;
	chip = host_to_rts51x(host);
	memset(chip, 0, sizeof(struct rts51x_chip));

	chip->vendor_id = id->idVendor;
	chip->product_id = id->idProduct;

	mutex_init(&(rts51x->dev_mutex));
	init_completion(&rts51x->cmnd_ready);
	init_completion(&rts51x->control_exit);
	init_completion(&rts51x->polling_exit);
	init_completion(&(rts51x->notify));
#ifdef SCSI_SCAN_DELAY
	init_waitqueue_head(&rts51x->delay_wait);
	init_completion(&rts51x->scanning_done);
#endif

	chip->usb = rts51x;

	
	result = associate_dev(chip, intf);
	if (result)
		goto BadDevice;

	
	result = get_pipes(chip);
	if (result)
		goto BadDevice;

	
	result = rts51x_acquire_resources(chip);
	if (result)
		goto BadDevice;

	
	th = kthread_run(rts51x_control_thread, chip, RTS51X_CTL_THREAD);
	if (IS_ERR(th)) {
		printk(KERN_WARNING RTS51X_TIP
		       "Unable to start control thread\n");
		result = PTR_ERR(th);
		goto BadDevice;
	}
	rts51x->ctl_thread = th;

	result = scsi_add_host(rts51x_to_host(chip), &rts51x->pusb_intf->dev);
	if (result) {
		printk(KERN_WARNING RTS51X_TIP "Unable to add the scsi host\n");
		goto BadDevice;
	}
#ifdef SCSI_SCAN_DELAY
	
	th = kthread_create(rts51x_scan_thread, chip, RTS51X_SCAN_THREAD);
	if (IS_ERR(th)) {
		printk(KERN_WARNING RTS51X_TIP
		       "Unable to start the device-scanning thread\n");
		complete(&rts51x->scanning_done);
		quiesce_and_remove_host(chip);
		result = PTR_ERR(th);
		goto BadDevice;
	}

	wake_up_process(th);
#else
	scsi_scan_host(rts51x_to_host(chip));
#endif

	
	th = kthread_run(rts51x_polling_thread, chip, RTS51X_POLLING_THREAD);
	if (IS_ERR(th)) {
		printk(KERN_WARNING RTS51X_TIP
		       "Unable to start polling thread\n");
		result = PTR_ERR(th);
		goto BadDevice;
	}
	rts51x->polling_thread = th;

#ifdef CONFIG_PM
	if (ss_en) {
		rts51x->pusb_intf->needs_remote_wakeup = needs_remote_wakeup;
		SET_PM_USAGE_CNT(chip, 1);
		RTS51X_DEBUGP("pm_usage_cnt = %d\n", GET_PM_USAGE_CNT(chip));
	}
#endif

	return 0;

	
BadDevice:
	RTS51X_DEBUGP("rts51x_probe() failed\n");
	release_everything(chip);
	return result;
}