@@ -1232,6 +1232,12 @@ static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
return USB_STOR_TRANSPORT_FAILED;
}
+static struct scsi_host_template aluda_template = {
+ .name = "aluda",
+ .proc_name = "aluda",
+ .module = THIS_MODULE,
+};
+
static int alauda_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
@@ -1239,7 +1245,8 @@ static int alauda_probe(struct usb_interface *intf,
int result;
result = usb_stor_probe1(&us, intf, id,
- (id - alauda_usb_ids) + alauda_unusual_dev_list);
+ (id - alauda_usb_ids) + alauda_unusual_dev_list,
+ &aluda_template);
if (result)
return result;
@@ -539,58 +539,58 @@ static struct device_attribute *sysfs_device_attr_list[] = {
/*
* this defines our host template, with which we'll allocate hosts
*/
-
-struct scsi_host_template usb_stor_host_template = {
+void usb_stor_template_init(struct scsi_host_template *tpnt)
+{
/* basic userland interface stuff */
- .name = "usb-storage",
- .proc_name = "usb-storage",
- .show_info = show_info,
- .write_info = write_info,
- .info = host_info,
+ if (!tpnt->name)
+ tpnt->name = "usb-storage";
+ if (!tpnt->proc_name)
+ tpnt->proc_name = "usb-storage";
+
+ tpnt->show_info = show_info;
+ tpnt->write_info = write_info;
+ tpnt->info = host_info;
/* command interface -- queued only */
- .queuecommand = queuecommand,
+ tpnt->queuecommand = queuecommand;
/* error and abort handlers */
- .eh_abort_handler = command_abort,
- .eh_device_reset_handler = device_reset,
- .eh_bus_reset_handler = bus_reset,
+ tpnt->eh_abort_handler = command_abort;
+ tpnt->eh_device_reset_handler = device_reset;
+ tpnt->eh_bus_reset_handler = bus_reset;
/* queue commands only, only one command per LUN */
- .can_queue = 1,
- .cmd_per_lun = 1,
+ tpnt->can_queue = 1;
+ tpnt->cmd_per_lun = 1;
/* unknown initiator id */
- .this_id = -1,
+ tpnt->this_id = -1;
- .slave_alloc = slave_alloc,
- .slave_configure = slave_configure,
- .target_alloc = target_alloc,
+ tpnt->slave_alloc = slave_alloc;
+ tpnt->slave_configure = slave_configure;
+ tpnt->target_alloc = target_alloc;
/* lots of sg segments can be handled */
- .sg_tablesize = SCSI_MAX_SG_CHAIN_SEGMENTS,
+ tpnt->sg_tablesize = SCSI_MAX_SG_CHAIN_SEGMENTS;
/* limit the total size of a transfer to 120 KB */
- .max_sectors = 240,
+ tpnt->max_sectors = 240;
/* merge commands... this seems to help performance, but
* periodically someone should test to see which setting is more
* optimal.
*/
- .use_clustering = 1,
+ tpnt->use_clustering = 1;
/* emulated HBA */
- .emulated = 1,
+ tpnt->emulated = 1;
/* we do our own delay after a device or bus reset */
- .skip_settle_delay = 1,
+ tpnt->skip_settle_delay = 1;
/* sysfs device attributes */
- .sdev_attrs = sysfs_device_attr_list,
-
- /* module management */
- .module = THIS_MODULE
-};
+ tpnt->sdev_attrs = sysfs_device_attr_list;
+}
/* To Report "Illegal Request: Invalid Field in CDB */
unsigned char usb_stor_sense_invalidCDB[18] = {
@@ -41,8 +41,8 @@
extern void usb_stor_report_device_reset(struct us_data *us);
extern void usb_stor_report_bus_reset(struct us_data *us);
+extern void usb_stor_template_init(struct scsi_host_template *tpnt);
extern unsigned char usb_stor_sense_invalidCDB[18];
-extern struct scsi_host_template usb_stor_host_template;
#endif
@@ -920,7 +920,8 @@ static unsigned int usb_stor_sg_tablesize(struct usb_interface *intf)
int usb_stor_probe1(struct us_data **pus,
struct usb_interface *intf,
const struct usb_device_id *id,
- struct us_unusual_dev *unusual_dev)
+ struct us_unusual_dev *unusual_dev,
+ struct scsi_host_template *tpnt)
{
struct Scsi_Host *host;
struct us_data *us;
@@ -928,11 +929,13 @@ int usb_stor_probe1(struct us_data **pus,
dev_info(&intf->dev, "USB Mass Storage device detected\n");
+
/*
* Ask the SCSI layer to allocate a host structure, with extra
* space at the end for our private us_data structure.
*/
- host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
+ usb_stor_template_init(tpnt);
+ host = scsi_host_alloc(tpnt, sizeof(*us));
if (!host) {
dev_warn(&intf->dev, "Unable to allocate the scsi host\n");
return -ENOMEM;
@@ -1069,6 +1072,10 @@ void usb_stor_disconnect(struct usb_interface *intf)
}
EXPORT_SYMBOL_GPL(usb_stor_disconnect);
+static struct scsi_host_template storage_template = {
+ .module = THIS_MODULE,
+};
+
/* The main probe routine for standard devices */
static int storage_probe(struct usb_interface *intf,
const struct usb_device_id *id)
@@ -1109,7 +1116,7 @@ static int storage_probe(struct usb_interface *intf,
id->idVendor, id->idProduct);
}
- result = usb_stor_probe1(&us, intf, id, unusual_dev);
+ result = usb_stor_probe1(&us, intf, id, unusual_dev, &storage_template);
if (result)
return result;
@@ -197,7 +197,8 @@ extern int usb_stor_post_reset(struct usb_interface *iface);
extern int usb_stor_probe1(struct us_data **pus,
struct usb_interface *intf,
const struct usb_device_id *id,
- struct us_unusual_dev *unusual_dev);
+ struct us_unusual_dev *unusual_dev,
+ struct scsi_host_template *tpnt);
extern int usb_stor_probe2(struct us_data *us);
extern void usb_stor_disconnect(struct usb_interface *intf);