Commit f1bfbf24 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by James Bottomley

[PATCH] two more templates in headers

I missed aic7xxx_old and cciss_scsi.  For the first it's the trivial
move, for the second it's the patch to move to scsi_add_host & friend
as already ACKed by Steve when he still was cciss maintainer.
parent 66eee7f9
...@@ -51,8 +51,6 @@ static int sendcmd( ...@@ -51,8 +51,6 @@ static int sendcmd(
int cmd_type); int cmd_type);
int __init cciss_scsi_detect(Scsi_Host_Template *tpnt);
int cciss_scsi_release(struct Scsi_Host *sh);
const char *cciss_scsi_info(struct Scsi_Host *sa); const char *cciss_scsi_info(struct Scsi_Host *sa);
int cciss_scsi_proc_info( int cciss_scsi_proc_info(
...@@ -84,22 +82,17 @@ static struct cciss_scsi_hba_t ccissscsi[MAX_CTLR] = { ...@@ -84,22 +82,17 @@ static struct cciss_scsi_hba_t ccissscsi[MAX_CTLR] = {
{ .name = "cciss7", .ndevices = 0 }, { .name = "cciss7", .ndevices = 0 },
}; };
/* We need one Scsi_Host_Template *per controller* instead of static Scsi_Host_Template cciss_driver_template = {
the usual one Scsi_Host_Template per controller *type*. This .module = THIS_MODULE,
is so PCI hot plug could have a remote possibility of still .name = "cciss",
working even with the SCSI system. It's so .proc_name = "cciss",
scsi_unregister_host will differentiate the controllers. .proc_info = cciss_scsi_proc_info,
When register_scsi_module is called, each host template is .queuecommand = cciss_scsi_queue_command,
customized (name change) in cciss_register_scsi() (that's .can_queue = SCSI_CCISS_CAN_QUEUE,
called from cciss_engage_scsi, called from .this_id = 7,
cciss.c:cciss_proc_write(), on "engage scsi" being received .sg_tablesize = MAXSGENTRIES,
from user space.) */ .cmd_per_lun = 1,
.use_clustering = DISABLE_CLUSTERING,
static
Scsi_Host_Template driver_template[MAX_CTLR] =
{
CCISS_SCSI, CCISS_SCSI, CCISS_SCSI, CCISS_SCSI,
CCISS_SCSI, CCISS_SCSI, CCISS_SCSI, CCISS_SCSI,
}; };
#pragma pack(1) #pragma pack(1)
...@@ -700,60 +693,31 @@ complete_scsi_command( CommandList_struct *cp, int timeout, __u32 tag) ...@@ -700,60 +693,31 @@ complete_scsi_command( CommandList_struct *cp, int timeout, __u32 tag)
scsi_cmd_free(ctlr, cp); scsi_cmd_free(ctlr, cp);
} }
/* cciss_scsi_detect is called from the scsi mid layer. static int __init
The scsi mid layer (scsi_register_host) is cciss_scsi_detect(int ctlr)
called from cciss.c:cciss_init_one(). */
int __init
cciss_scsi_detect(Scsi_Host_Template *tpnt)
{ {
int i;
struct Scsi_Host *sh; struct Scsi_Host *sh;
/* Tell the kernel we want to be a SCSI driver... */ sh = scsi_register(&cciss_driver_template, sizeof(struct ctlr_info *));
sh = scsi_register(tpnt, sizeof(struct ctlr_info *)); if (sh == NULL)
if (sh == NULL) return 0; return 0;
sh->io_port = 0; // good enough? FIXME, sh->io_port = 0; // good enough? FIXME,
sh->n_io_port = 0; // I don't think we use these two... sh->n_io_port = 0; // I don't think we use these two...
sh->this_id = SELF_SCSI_ID; sh->this_id = SELF_SCSI_ID;
/* This is a bit kludgey, using the adapter name to figure out */
/* which scsi host template we've got, won't scale beyond 9 ctlrs. */
i = tpnt->name[5] - '0';
# if MAX_CTLR > 9
# error "cciss_scsi.c: MAX_CTLR > 9, code maintenance needed."
# endif
if (i<0 || i>=MAX_CTLR || hba[i] == NULL) {
/* we didn't find ourself... we shouldn't get here. */
printk("cciss_scsi_detect: could not find ourself in hba[]\n");
return 0;
}
((struct cciss_scsi_adapter_data_t *) ((struct cciss_scsi_adapter_data_t *)
hba[i]->scsi_ctlr)->scsi_host = (void *) sh; hba[ctlr]->scsi_ctlr)->scsi_host = (void *) sh;
sh->hostdata[0] = (unsigned long) hba[i]; sh->hostdata[0] = (unsigned long) hba[ctlr];
sh->irq = hba[i]->intr; sh->irq = hba[ctlr]->intr;
sh->unique_id = sh->irq; sh->unique_id = sh->irq;
scsi_set_device(sh, &hba[i]->pdev->dev); scsi_add_host(sh, &hba[ctlr]->pdev->dev);
return 1; /* Say we have 1 scsi adapter, this will be */ return 1;
/* called multiple times, once for each adapter */
/* from cciss.c:cciss_init_one(). We do it this */
/* way for PCI-hot plug reasons. (we don't know how */
/* many adapters we have total, so we say we have */
/* 1, each of a unique type.) */
} }
static void __exit cleanup_cciss_module(void); static void __exit cleanup_cciss_module(void);
int
cciss_scsi_release(struct Scsi_Host *sh)
{
return 0;
}
static void static void
cciss_unmap_one(struct pci_dev *pdev, cciss_unmap_one(struct pci_dev *pdev,
...@@ -1381,33 +1345,6 @@ cciss_scsi_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *)) ...@@ -1381,33 +1345,6 @@ cciss_scsi_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *))
return 0; return 0;
} }
static void
init_driver_template(int ctlr)
{
memset(&driver_template[ctlr], 0, sizeof(driver_template[ctlr]));
driver_template[ctlr].name = ccissscsi[ctlr].name;
driver_template[ctlr].proc_name = ccissscsi[ctlr].name;
driver_template[ctlr].detect = cciss_scsi_detect;
driver_template[ctlr].release = cciss_scsi_release;
driver_template[ctlr].proc_info = cciss_scsi_proc_info;
driver_template[ctlr].queuecommand = cciss_scsi_queue_command;
driver_template[ctlr].eh_abort_handler = NULL;
driver_template[ctlr].eh_device_reset_handler = NULL;
driver_template[ctlr].can_queue = SCSI_CCISS_CAN_QUEUE;
driver_template[ctlr].this_id = 7;
driver_template[ctlr].sg_tablesize = MAXSGENTRIES;
driver_template[ctlr].cmd_per_lun = 1;
driver_template[ctlr].use_clustering = DISABLE_CLUSTERING;
driver_template[ctlr].module = THIS_MODULE;
/* set scsi_host to NULL so our detect routine will
find us on register */
((struct cciss_scsi_adapter_data_t *)
hba[ctlr]->scsi_ctlr)->scsi_host = NULL;
}
static void static void
cciss_unregister_scsi(int ctlr) cciss_unregister_scsi(int ctlr)
{ {
...@@ -1422,15 +1359,18 @@ cciss_unregister_scsi(int ctlr) ...@@ -1422,15 +1359,18 @@ cciss_unregister_scsi(int ctlr)
stk = &sa->cmd_stack; stk = &sa->cmd_stack;
/* if we weren't ever actually registered, don't unregister */ /* if we weren't ever actually registered, don't unregister */
if (((struct cciss_scsi_adapter_data_t *) if (sa->registered) {
hba[ctlr]->scsi_ctlr)->registered) {
spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
scsi_unregister_host(&driver_template[ctlr]); scsi_remove_host(sa->scsi_host);
scsi_unregister(sa->scsi_host);
spin_lock_irqsave(CCISS_LOCK(ctlr), flags); spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
} }
init_driver_template(ctlr);
/* set scsi_host to NULL so our detect routine will
find us on register */
sa->scsi_host = NULL;
scsi_cmd_stack_free(ctlr); scsi_cmd_stack_free(ctlr);
kfree(hba[ctlr]->scsi_ctlr); kfree(sa);
spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
} }
...@@ -1440,9 +1380,6 @@ cciss_register_scsi(int ctlr) ...@@ -1440,9 +1380,6 @@ cciss_register_scsi(int ctlr)
unsigned long flags; unsigned long flags;
CPQ_TAPE_LOCK(ctlr, flags); CPQ_TAPE_LOCK(ctlr, flags);
driver_template[ctlr].name = ccissscsi[ctlr].name;
driver_template[ctlr].proc_name = ccissscsi[ctlr].name;
driver_template[ctlr].module = THIS_MODULE;;
/* Since this is really a block driver, the SCSI core may not be /* Since this is really a block driver, the SCSI core may not be
initialized at init time, in which case, calling scsi_register_host initialized at init time, in which case, calling scsi_register_host
...@@ -1454,7 +1391,7 @@ cciss_register_scsi(int ctlr) ...@@ -1454,7 +1391,7 @@ cciss_register_scsi(int ctlr)
((struct cciss_scsi_adapter_data_t *) ((struct cciss_scsi_adapter_data_t *)
hba[ctlr]->scsi_ctlr)->registered = 1; hba[ctlr]->scsi_ctlr)->registered = 1;
CPQ_TAPE_UNLOCK(ctlr, flags); CPQ_TAPE_UNLOCK(ctlr, flags);
return scsi_register_host(&driver_template[ctlr]); return cciss_scsi_detect(ctlr);
} }
CPQ_TAPE_UNLOCK(ctlr, flags); CPQ_TAPE_UNLOCK(ctlr, flags);
printk(KERN_INFO printk(KERN_INFO
...@@ -1489,8 +1426,8 @@ cciss_engage_scsi(int ctlr) ...@@ -1489,8 +1426,8 @@ cciss_engage_scsi(int ctlr)
static void static void
cciss_proc_tape_report(int ctlr, unsigned char *buffer, off_t *pos, off_t *len) cciss_proc_tape_report(int ctlr, unsigned char *buffer, off_t *pos, off_t *len)
{ {
unsigned long flags;
int size; int size;
unsigned int flags;
*pos = *pos -1; *len = *len - 1; // cut off the last trailing newline *pos = *pos -1; *len = *len - 1; // cut off the last trailing newline
......
...@@ -38,23 +38,6 @@ ...@@ -38,23 +38,6 @@
#define SCSI_CCISS_CAN_QUEUE 2 #define SCSI_CCISS_CAN_QUEUE 2
/* this notation works fine for static initializations (as is the usual
case for linux scsi drivers), but not so well for dynamic settings,
so, if you change this, you also have to change cciss_unregister_scsi()
in cciss_scsi.c */
#define CCISS_SCSI { \
name: "", \
detect: cciss_scsi_detect, \
release: cciss_scsi_release, \
proc_info: cciss_scsi_proc_info, \
queuecommand: cciss_scsi_queue_command, \
can_queue: SCSI_CCISS_CAN_QUEUE, \
this_id: 7, \
sg_tablesize: MAXSGENTRIES, \
cmd_per_lun: 1, \
use_clustering: DISABLE_CLUSTERING,\
}
/* /*
info: cciss_scsi_info, \ info: cciss_scsi_info, \
......
...@@ -1270,6 +1270,7 @@ static int aic7xxx_verbose = VERBOSE_NORMAL | VERBOSE_NEGOTIATION | ...@@ -1270,6 +1270,7 @@ static int aic7xxx_verbose = VERBOSE_NORMAL | VERBOSE_NEGOTIATION |
* *
***************************************************************************/ ***************************************************************************/
static int aic7xxx_release(struct Scsi_Host *host);
static void aic7xxx_set_syncrate(struct aic7xxx_host *p, static void aic7xxx_set_syncrate(struct aic7xxx_host *p,
struct aic7xxx_syncrate *syncrate, int target, int channel, struct aic7xxx_syncrate *syncrate, int target, int channel,
unsigned int period, unsigned int offset, unsigned char options, unsigned int period, unsigned int offset, unsigned char options,
...@@ -8361,7 +8362,7 @@ aic7xxx_register(Scsi_Host_Template *template, struct aic7xxx_host *p, ...@@ -8361,7 +8362,7 @@ aic7xxx_register(Scsi_Host_Template *template, struct aic7xxx_host *p,
* Perform a chip reset on the aic7xxx SCSI controller. The controller * Perform a chip reset on the aic7xxx SCSI controller. The controller
* is paused upon return. * is paused upon return.
*-F*************************************************************************/ *-F*************************************************************************/
int static int
aic7xxx_chip_reset(struct aic7xxx_host *p) aic7xxx_chip_reset(struct aic7xxx_host *p)
{ {
unsigned char sblkctl; unsigned char sblkctl;
...@@ -8996,7 +8997,7 @@ aic7xxx_configure_bugs(struct aic7xxx_host *p) ...@@ -8996,7 +8997,7 @@ aic7xxx_configure_bugs(struct aic7xxx_host *p)
* one do-it-all function. This may be useful when (and if) the * one do-it-all function. This may be useful when (and if) the
* mid-level SCSI code is overhauled. * mid-level SCSI code is overhauled.
*-F*************************************************************************/ *-F*************************************************************************/
int static int
aic7xxx_detect(Scsi_Host_Template *template) aic7xxx_detect(Scsi_Host_Template *template)
{ {
struct aic7xxx_host *temp_p = NULL; struct aic7xxx_host *temp_p = NULL;
...@@ -10293,7 +10294,7 @@ aic7xxx_buildscb(struct aic7xxx_host *p, Scsi_Cmnd *cmd, ...@@ -10293,7 +10294,7 @@ aic7xxx_buildscb(struct aic7xxx_host *p, Scsi_Cmnd *cmd,
* Description: * Description:
* Queue a SCB to the controller. * Queue a SCB to the controller.
*-F*************************************************************************/ *-F*************************************************************************/
int static int
aic7xxx_queue(Scsi_Cmnd *cmd, void (*fn)(Scsi_Cmnd *)) aic7xxx_queue(Scsi_Cmnd *cmd, void (*fn)(Scsi_Cmnd *))
{ {
struct aic7xxx_host *p; struct aic7xxx_host *p;
...@@ -10364,7 +10365,7 @@ aic7xxx_queue(Scsi_Cmnd *cmd, void (*fn)(Scsi_Cmnd *)) ...@@ -10364,7 +10365,7 @@ aic7xxx_queue(Scsi_Cmnd *cmd, void (*fn)(Scsi_Cmnd *))
* aborted, then we will reset the channel and have all devices renegotiate. * aborted, then we will reset the channel and have all devices renegotiate.
* Returns an enumerated type that indicates the status of the operation. * Returns an enumerated type that indicates the status of the operation.
*-F*************************************************************************/ *-F*************************************************************************/
int static int
aic7xxx_bus_device_reset(Scsi_Cmnd *cmd) aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
{ {
struct aic7xxx_host *p; struct aic7xxx_host *p;
...@@ -10566,7 +10567,7 @@ aic7xxx_bus_device_reset(Scsi_Cmnd *cmd) ...@@ -10566,7 +10567,7 @@ aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
* Description: * Description:
* Abort the current SCSI command(s). * Abort the current SCSI command(s).
*-F*************************************************************************/ *-F*************************************************************************/
void static void
aic7xxx_panic_abort(struct aic7xxx_host *p, Scsi_Cmnd *cmd) aic7xxx_panic_abort(struct aic7xxx_host *p, Scsi_Cmnd *cmd)
{ {
...@@ -10592,7 +10593,7 @@ aic7xxx_panic_abort(struct aic7xxx_host *p, Scsi_Cmnd *cmd) ...@@ -10592,7 +10593,7 @@ aic7xxx_panic_abort(struct aic7xxx_host *p, Scsi_Cmnd *cmd)
* Description: * Description:
* Abort the current SCSI command(s). * Abort the current SCSI command(s).
*-F*************************************************************************/ *-F*************************************************************************/
int static int
aic7xxx_abort(Scsi_Cmnd *cmd) aic7xxx_abort(Scsi_Cmnd *cmd)
{ {
struct aic7xxx_scb *scb = NULL; struct aic7xxx_scb *scb = NULL;
...@@ -10820,7 +10821,7 @@ aic7xxx_abort(Scsi_Cmnd *cmd) ...@@ -10820,7 +10821,7 @@ aic7xxx_abort(Scsi_Cmnd *cmd)
* DEVICE RESET message - on the offending target before pulling * DEVICE RESET message - on the offending target before pulling
* the SCSI bus reset line. * the SCSI bus reset line.
*-F*************************************************************************/ *-F*************************************************************************/
int static int
aic7xxx_reset(Scsi_Cmnd *cmd) aic7xxx_reset(Scsi_Cmnd *cmd)
{ {
struct aic7xxx_scb *scb; struct aic7xxx_scb *scb;
...@@ -10905,7 +10906,7 @@ aic7xxx_reset(Scsi_Cmnd *cmd) ...@@ -10905,7 +10906,7 @@ aic7xxx_reset(Scsi_Cmnd *cmd)
* This function is broken for today's really large drives and needs * This function is broken for today's really large drives and needs
* fixed. * fixed.
*-F*************************************************************************/ *-F*************************************************************************/
int static int
aic7xxx_biosparam(struct scsi_device *sdev, struct block_device *bdev, aic7xxx_biosparam(struct scsi_device *sdev, struct block_device *bdev,
sector_t capacity, int geom[]) sector_t capacity, int geom[])
{ {
...@@ -10955,7 +10956,7 @@ aic7xxx_biosparam(struct scsi_device *sdev, struct block_device *bdev, ...@@ -10955,7 +10956,7 @@ aic7xxx_biosparam(struct scsi_device *sdev, struct block_device *bdev,
* Free the passed in Scsi_Host memory structures prior to unloading the * Free the passed in Scsi_Host memory structures prior to unloading the
* module. * module.
*-F*************************************************************************/ *-F*************************************************************************/
int static int
aic7xxx_release(struct Scsi_Host *host) aic7xxx_release(struct Scsi_Host *host)
{ {
struct aic7xxx_host *p = (struct aic7xxx_host *) host->hostdata; struct aic7xxx_host *p = (struct aic7xxx_host *) host->hostdata;
...@@ -11141,8 +11142,25 @@ aic7xxx_print_scratch_ram(struct aic7xxx_host *p) ...@@ -11141,8 +11142,25 @@ aic7xxx_print_scratch_ram(struct aic7xxx_host *p)
MODULE_LICENSE("Dual BSD/GPL"); MODULE_LICENSE("Dual BSD/GPL");
/* Eventually this will go into an include file, but this will be later */ static Scsi_Host_Template driver_template = {
static Scsi_Host_Template driver_template = AIC7XXX; .proc_info = aic7xxx_proc_info,
.detect = aic7xxx_detect,
.release = aic7xxx_release,
.info = aic7xxx_info,
.queuecommand = aic7xxx_queue,
.slave_alloc = aic7xxx_slave_alloc,
.slave_configure = aic7xxx_slave_configure,
.slave_destroy = aic7xxx_slave_destroy,
.bios_param = aic7xxx_biosparam,
.eh_abort_handler = aic7xxx_abort,
.eh_device_reset_handler = aic7xxx_bus_device_reset,
.eh_host_reset_handler = aic7xxx_reset,
.can_queue = 255,
.this_id = -1,
.max_sectors = 2048,
.cmd_per_lun = 3,
.use_clustering = ENABLE_CLUSTERING,
};
#include "scsi_module.c" #include "scsi_module.c"
......
...@@ -25,48 +25,4 @@ ...@@ -25,48 +25,4 @@
#define AIC7XXX_H_VERSION "5.2.0" #define AIC7XXX_H_VERSION "5.2.0"
/*
* Scsi_Host_Template (see hosts.h) for AIC-7xxx - some fields
* to do with card config are filled in after the card is detected.
*/
#define AIC7XXX { \
.proc_info = aic7xxx_proc_info, \
.detect = aic7xxx_detect, \
.release = aic7xxx_release, \
.info = aic7xxx_info, \
.queuecommand = aic7xxx_queue, \
.slave_alloc = aic7xxx_slave_alloc, \
.slave_configure = aic7xxx_slave_configure, \
.slave_destroy = aic7xxx_slave_destroy, \
.bios_param = aic7xxx_biosparam, \
.eh_abort_handler = aic7xxx_abort, \
.eh_device_reset_handler = aic7xxx_bus_device_reset, \
.eh_host_reset_handler = aic7xxx_reset, \
.can_queue = 255, /* max simultaneous cmds */\
.this_id = -1, /* scsi id of host adapter */\
.sg_tablesize = 0, /* max scatter-gather cmds */\
.max_sectors = 2048, /* max physical sectors in 1 cmd */\
.cmd_per_lun = 3, /* cmds per lun (linked cmds) */\
.present = 0, /* number of 7xxx's present */\
.unchecked_isa_dma = 0, /* no memory DMA restrictions */\
.use_clustering = ENABLE_CLUSTERING, \
}
extern int aic7xxx_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
extern int aic7xxx_biosparam(struct scsi_device *, struct block_device *,
sector_t, int[]);
extern int aic7xxx_detect(Scsi_Host_Template *);
extern int aic7xxx_command(Scsi_Cmnd *);
extern int aic7xxx_release(struct Scsi_Host *);
static int aic7xxx_slave_alloc(Scsi_Device *);
static int aic7xxx_slave_configure(Scsi_Device *);
static void aic7xxx_slave_destroy(Scsi_Device *);
extern int aic7xxx_abort(Scsi_Cmnd *);
extern int aic7xxx_bus_device_reset(Scsi_Cmnd *);
extern int aic7xxx_reset(Scsi_Cmnd *);
extern const char *aic7xxx_info(struct Scsi_Host *);
extern int aic7xxx_proc_info(char *, char **, off_t, int, int, int);
#endif /* _aic7xxx_h */ #endif /* _aic7xxx_h */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment