Beispiel #1
0
static int __init init_this_scst_driver(void)
{
    int res;

    TRACE_ENTRY();

    res = scst_register_target_template(&driver_target_template);
    TRACE_DBG("scst_register_target_template() returned %d", res);
    if (res < 0)
        goto out;

#ifdef SCST_REGISTER_INITIATOR_DRIVER
    driver_template.module = THIS_MODULE;
    scsi_register_module(MODULE_SCSI_HA, &driver_template);
    TRACE_DBG("driver_template.present=%d",
              driver_template.present);
    if (driver_template.present == 0) {
        res = -ENODEV;
        MOD_DEC_USE_COUNT;
        goto out;
    }
#endif

out:
    TRACE_EXIT_RES(res);
    return res;
}
Beispiel #2
0
static int __init piix_init(void)
{
	int rc;

	DPRINTK("pci_module_init\n");
	rc = pci_module_init(&piix_pci_driver);
	if (rc)
		return rc;

	in_module_init = 0;

	DPRINTK("scsi_register_host\n");
	rc = scsi_register_module(MODULE_SCSI_HA, &piix_sht);
	if (rc) {
		rc = -ENODEV;
		goto err_out;
	}

	DPRINTK("done\n");
	return 0;

err_out:
	pci_unregister_driver(&piix_pci_driver);
	return rc;
}
Beispiel #3
0
static int __init powertecscsi_init(void)
{
	scsi_register_module(MODULE_SCSI_HA, &powertecscsi_template);
	if (powertecscsi_template.present)
		return 0;

	scsi_unregister_module(MODULE_SCSI_HA, &powertecscsi_template);
	return -ENODEV;
}
static int __init init_this_scsi_driver(void)
{
	driver_template.module = THIS_MODULE;
	scsi_register_module(MODULE_SCSI_HA, &driver_template);
	if (driver_template.present)
		return 0;

	scsi_unregister_module(MODULE_SCSI_HA, &driver_template);
	return -ENODEV;
}
Beispiel #5
0
static int __init sis_init(void)
{
	int rc = pci_module_init(&sis_pci_driver);
	if (rc)
		return rc;

	rc = scsi_register_module(MODULE_SCSI_HA, &sis_sht);
	if (rc) {
		pci_unregister_driver(&sis_pci_driver);
		return -ENODEV;
	}

	return 0;
}
static int __init svia_init(void)
{
	int rc;

	rc = pci_module_init(&svia_pci_driver);
	if (rc)
		return rc;
	
	rc = scsi_register_module(MODULE_SCSI_HA, &svia_sht);
	if (rc) {
		pci_unregister_driver(&svia_pci_driver);
		/* TODO: does scsi_register_module return errno val? */
		return -ENODEV;
	}

	return 0;
}
Beispiel #7
0
int init_module(void) {
    sg_template.module = &__this_module;
    return scsi_register_module(MODULE_SCSI_DEV, &sg_template);
}
Beispiel #8
0
oskit_error_t
oskit_linux_scsi_probe(struct driver_struct *ds)
{
	struct scsi_driver_struct *sds = (struct scsi_driver_struct*)ds;
	struct Scsi_Host *host;
	oskit_error_t rc;
	int found;

	/*
	 * scsi_dev_init was already called by device_setup, which was
	 * called by oskit_linux_dev_init, which got called in
	 * oskit_linux_driver_register before we could be here.
	 *
	 * Initialize this driver if not done yet.
	 */
	if (sds->initialized)
		return 0;
	sds->initialized = 1;
	scsi_register_module(MODULE_SCSI_HA, &sds->tmpl);

	/* Add any detected SCSI host adaptors to the fdev device tree */
	found = 0;
	for (host = scsi_hostlist; host; host = host->next) {
		struct scsi_bus *bus;
		struct scsi_dev **devp;
		Scsi_Device *ldev;

		if (host->hostt != &sds->tmpl)
			continue;

		/* Create a device node for this host adaptor */
		/* XXX deal with multi-bus host adaptors */
		if ((bus = kmalloc(sizeof(*bus), 0)) == 0)
			return OSKIT_E_OUTOFMEMORY;
		bus->intf.ops = &bus_ops;
		bus->sds = sds;
		bus->host = host;
		bus->devs = NULL;
		rc = osenv_isabus_addchild(host->io_port,
				       (oskit_device_t*)bus);
		if (rc != 0)
			return rc;

		/* Create device sub-nodes for each of the devices found */
		devp = &bus->devs;
		for (ldev = host->host_queue; ldev; ldev = ldev->next) {
			struct scsi_dev *dev;
			int i;

			if (ldev->host != host)
				continue;

			/* Create a new device node */
			if ((dev = kmalloc(sizeof(*dev), 0)) == 0)
				return OSKIT_E_OUTOFMEMORY;
			dev->intf.ops = &dev_ops;
			dev->next = NULL;
			dev->dev = ldev;
			dev->bus = bus;

			/* Build the device information strings */
			memcpy(dev->model, ldev->model, 16);
			dev->model[16] = 0;
			for (i = 15; i >= 0; i--) {
				if (dev->model[i] > ' ')
					break;
				dev->model[i] = 0;
			}
			memcpy(dev->vendor, ldev->vendor, 8);
			dev->vendor[8] = 0;
			for (i = 7; i >= 0; i--) {
				if (dev->vendor[i] > ' ')
					break;
				dev->vendor[i] = 0;
			}

			/* See if we know about this particular device type */
			/* XXX would be better if the high-level drivers
			   could be separated out, later... */
			for (i = 0; i < sd_template.dev_max; i++) {
				if (rscsi_disks[i].device != ldev)
					continue;
				dev->intf.ops = (void*)&disk_ops;
				dev->devno = MKDEV(SCSI_DISK0_MAJOR, i << 4);
			}

			/* Hook this device onto the host adaptor's list */
			*devp = dev;
			devp = &dev->next;

			found++;
		}

		found++;
	}

	return found;
}
static void * mts_usb_probe (struct usb_device *dev, unsigned int interface,
			     const struct usb_device_id *id)
{
	int i;
	int result;
	int ep_out = -1;
	int ep_in_set[3]; /* this will break if we have more than three endpoints
			   which is why we check */
	int *ep_in_current = ep_in_set;

	struct mts_desc * new_desc;
	struct vendor_product const* p;

	/* the altsettting 0 on the interface we're probing */
	struct usb_interface_descriptor *altsetting;

	MTS_DEBUG_GOT_HERE();
	MTS_DEBUG( "usb-device descriptor at %x\n", (int)dev );

	MTS_DEBUG( "product id = 0x%x, vendor id = 0x%x\n",
		   (int)dev->descriptor.idProduct,
		   (int)dev->descriptor.idVendor );

	MTS_DEBUG_GOT_HERE();

	p = &mts_supported_products[id - mts_usb_ids];

	MTS_DEBUG_GOT_HERE();

	MTS_DEBUG( "found model %s\n", p->name );
	if ( p->support_status != mts_sup_full )
		MTS_MESSAGE( "model %s is not known to be fully supported, reports welcome!\n",
			     p->name );

	/* the altsettting 0 on the interface we're probing */
	altsetting =
		&(dev->actconfig->interface[interface].altsetting[0]);


	/* Check if the config is sane */

	if ( altsetting->bNumEndpoints != MTS_EP_TOTAL ) {
		MTS_WARNING( "expecting %d got %d endpoints! Bailing out.\n",
			     (int)MTS_EP_TOTAL, (int)altsetting->bNumEndpoints );
		return NULL;
	}

	for( i = 0; i < altsetting->bNumEndpoints; i++ ) {
		if ((altsetting->endpoint[i].bmAttributes &
		     USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK) {

			MTS_WARNING( "can only deal with bulk endpoints; endpoint %d is not bulk.\n",
			     (int)altsetting->endpoint[i].bEndpointAddress );
		} else {
			if (altsetting->endpoint[i].bEndpointAddress &
			    USB_DIR_IN)
				*ep_in_current++
					= altsetting->endpoint[i].bEndpointAddress &
					USB_ENDPOINT_NUMBER_MASK;
			else {
				if ( ep_out != -1 ) {
					MTS_WARNING( "can only deal with one output endpoints. Bailing out." );
					return NULL;
				}

				ep_out = altsetting->endpoint[i].bEndpointAddress &
					USB_ENDPOINT_NUMBER_MASK;
			}
		}

	}


	if ( ep_out == -1 ) {
		MTS_WARNING( "couldn't find an output bulk endpoint. Bailing out.\n" );
		return NULL;
	}


	/* I don't understand the following fully (it's from usb-storage) -- John */

	/* set the interface -- STALL is an acceptable response here */
	result = usb_set_interface(dev, altsetting->bInterfaceNumber, 0);

	MTS_DEBUG("usb_set_interface returned %d.\n",result);
	switch( result )
	{
	case 0: /* no error */
		break;
		
	case -EPIPE:
		usb_clear_halt(dev, usb_sndctrlpipe(dev, 0));
		MTS_DEBUG( "clearing clearing stall on control interface\n" );
		break;
		
	default:
		MTS_DEBUG( "unknown error %d from usb_set_interface\n",
			(int)result );
 		return NULL;
	}
	
	
	/* allocating a new descriptor */
	new_desc = (struct mts_desc *)kmalloc(sizeof(struct mts_desc), GFP_KERNEL);
	if (new_desc == NULL)
	{
		MTS_ERROR("couldn't allocate scanner desc, bailing out!\n");
		return NULL;
	}

	/* As done by usb_alloc_urb */
	memset( new_desc, 0, sizeof(*new_desc) );
	spin_lock_init(&new_desc->urb.lock);
	
		
	/* initialising that descriptor */
	new_desc->usb_dev = dev;
	new_desc->interface = interface;

	init_MUTEX(&new_desc->lock);

	if(mts_list){
		new_desc->host_number = mts_list->host_number+1;
	} else {
		new_desc->host_number = 0;
	}
	
	/* endpoints */
	
	new_desc->ep_out = ep_out;
	new_desc->ep_response = ep_in_set[0];
	new_desc->ep_image = ep_in_set[1];


	if ( new_desc->ep_out != MTS_EP_OUT )
		MTS_WARNING( "will this work? Command EP is not usually %d\n",
			     (int)new_desc->ep_out );

	if ( new_desc->ep_response != MTS_EP_RESPONSE )
		MTS_WARNING( "will this work? Response EP is not usually %d\n",
			     (int)new_desc->ep_response );

	if ( new_desc->ep_image != MTS_EP_IMAGE )
		MTS_WARNING( "will this work? Image data EP is not usually %d\n",
			     (int)new_desc->ep_image );


	/* Initialize the host template based on the default one */
	memcpy(&(new_desc->ctempl), &mts_scsi_host_template, sizeof(mts_scsi_host_template));
	/* HACK from usb-storage - this is needed for scsi detection */
	(struct mts_desc *)new_desc->ctempl.proc_dir = new_desc; /* FIXME */

	MTS_DEBUG("registering SCSI module\n");

	new_desc->ctempl.module = THIS_MODULE;
	result = scsi_register_module(MODULE_SCSI_HA, &(new_desc->ctempl));
	/* Will get hit back in microtek_detect by this func */
	if ( result )
	{
		MTS_ERROR( "error %d from scsi_register_module! Help!\n",
			   (int)result );

		/* FIXME: need more cleanup? */
		kfree( new_desc );
		return NULL;
	}
	MTS_DEBUG_GOT_HERE();

	/* FIXME: the bomb is armed, must the host be registered under lock ? */
	/* join the list - lock it */
	down(&mts_list_semaphore);

	mts_add_nolock( new_desc );

	up(&mts_list_semaphore);


	MTS_DEBUG("completed probe and exiting happily\n");

	return (void *)new_desc;
}