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(
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);
int cciss_scsi_proc_info(
......@@ -84,22 +82,17 @@ static struct cciss_scsi_hba_t ccissscsi[MAX_CTLR] = {
{ .name = "cciss7", .ndevices = 0 },
};
/* We need one Scsi_Host_Template *per controller* instead of
the usual one Scsi_Host_Template per controller *type*. This
is so PCI hot plug could have a remote possibility of still
working even with the SCSI system. It's so
scsi_unregister_host will differentiate the controllers.
When register_scsi_module is called, each host template is
customized (name change) in cciss_register_scsi() (that's
called from cciss_engage_scsi, called from
cciss.c:cciss_proc_write(), on "engage scsi" being received
from user space.) */
static
Scsi_Host_Template driver_template[MAX_CTLR] =
{
CCISS_SCSI, CCISS_SCSI, CCISS_SCSI, CCISS_SCSI,
CCISS_SCSI, CCISS_SCSI, CCISS_SCSI, CCISS_SCSI,
static Scsi_Host_Template cciss_driver_template = {
.module = THIS_MODULE,
.name = "cciss",
.proc_name = "cciss",
.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,
};
#pragma pack(1)
......@@ -700,60 +693,31 @@ complete_scsi_command( CommandList_struct *cp, int timeout, __u32 tag)
scsi_cmd_free(ctlr, cp);
}
/* cciss_scsi_detect is called from the scsi mid layer.
The scsi mid layer (scsi_register_host) is
called from cciss.c:cciss_init_one(). */
int __init
cciss_scsi_detect(Scsi_Host_Template *tpnt)
static int __init
cciss_scsi_detect(int ctlr)
{
int i;
struct Scsi_Host *sh;
/* Tell the kernel we want to be a SCSI driver... */
sh = scsi_register(tpnt, sizeof(struct ctlr_info *));
if (sh == NULL) return 0;
sh = scsi_register(&cciss_driver_template, sizeof(struct ctlr_info *));
if (sh == NULL)
return 0;
sh->io_port = 0; // good enough? FIXME,
sh->n_io_port = 0; // I don't think we use these two...
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 *)
hba[i]->scsi_ctlr)->scsi_host = (void *) sh;
sh->hostdata[0] = (unsigned long) hba[i];
sh->irq = hba[i]->intr;
hba[ctlr]->scsi_ctlr)->scsi_host = (void *) sh;
sh->hostdata[0] = (unsigned long) hba[ctlr];
sh->irq = hba[ctlr]->intr;
sh->unique_id = sh->irq;
scsi_set_device(sh, &hba[i]->pdev->dev);
return 1; /* Say we have 1 scsi adapter, this will be */
/* 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.) */
scsi_add_host(sh, &hba[ctlr]->pdev->dev);
return 1;
}
static void __exit cleanup_cciss_module(void);
int
cciss_scsi_release(struct Scsi_Host *sh)
{
return 0;
}
static void
cciss_unmap_one(struct pci_dev *pdev,
......@@ -1381,33 +1345,6 @@ cciss_scsi_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *))
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
cciss_unregister_scsi(int ctlr)
{
......@@ -1422,15 +1359,18 @@ cciss_unregister_scsi(int ctlr)
stk = &sa->cmd_stack;
/* if we weren't ever actually registered, don't unregister */
if (((struct cciss_scsi_adapter_data_t *)
hba[ctlr]->scsi_ctlr)->registered) {
if (sa->registered) {
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);
}
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);
kfree(hba[ctlr]->scsi_ctlr);
kfree(sa);
spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
}
......@@ -1440,9 +1380,6 @@ cciss_register_scsi(int ctlr)
unsigned long 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
initialized at init time, in which case, calling scsi_register_host
......@@ -1454,7 +1391,7 @@ cciss_register_scsi(int ctlr)
((struct cciss_scsi_adapter_data_t *)
hba[ctlr]->scsi_ctlr)->registered = 1;
CPQ_TAPE_UNLOCK(ctlr, flags);
return scsi_register_host(&driver_template[ctlr]);
return cciss_scsi_detect(ctlr);
}
CPQ_TAPE_UNLOCK(ctlr, flags);
printk(KERN_INFO
......@@ -1489,8 +1426,8 @@ cciss_engage_scsi(int ctlr)
static void
cciss_proc_tape_report(int ctlr, unsigned char *buffer, off_t *pos, off_t *len)
{
unsigned long flags;
int size;
unsigned int flags;
*pos = *pos -1; *len = *len - 1; // cut off the last trailing newline
......
......@@ -38,23 +38,6 @@
#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, \
......
......@@ -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,
struct aic7xxx_syncrate *syncrate, int target, int channel,
unsigned int period, unsigned int offset, unsigned char options,
......@@ -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
* is paused upon return.
*-F*************************************************************************/
int
static int
aic7xxx_chip_reset(struct aic7xxx_host *p)
{
unsigned char sblkctl;
......@@ -8996,7 +8997,7 @@ aic7xxx_configure_bugs(struct aic7xxx_host *p)
* one do-it-all function. This may be useful when (and if) the
* mid-level SCSI code is overhauled.
*-F*************************************************************************/
int
static int
aic7xxx_detect(Scsi_Host_Template *template)
{
struct aic7xxx_host *temp_p = NULL;
......@@ -10293,7 +10294,7 @@ aic7xxx_buildscb(struct aic7xxx_host *p, Scsi_Cmnd *cmd,
* Description:
* Queue a SCB to the controller.
*-F*************************************************************************/
int
static int
aic7xxx_queue(Scsi_Cmnd *cmd, void (*fn)(Scsi_Cmnd *))
{
struct aic7xxx_host *p;
......@@ -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.
* Returns an enumerated type that indicates the status of the operation.
*-F*************************************************************************/
int
static int
aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
{
struct aic7xxx_host *p;
......@@ -10566,7 +10567,7 @@ aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
* Description:
* Abort the current SCSI command(s).
*-F*************************************************************************/
void
static void
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:
* Abort the current SCSI command(s).
*-F*************************************************************************/
int
static int
aic7xxx_abort(Scsi_Cmnd *cmd)
{
struct aic7xxx_scb *scb = NULL;
......@@ -10820,7 +10821,7 @@ aic7xxx_abort(Scsi_Cmnd *cmd)
* DEVICE RESET message - on the offending target before pulling
* the SCSI bus reset line.
*-F*************************************************************************/
int
static int
aic7xxx_reset(Scsi_Cmnd *cmd)
{
struct aic7xxx_scb *scb;
......@@ -10905,7 +10906,7 @@ aic7xxx_reset(Scsi_Cmnd *cmd)
* This function is broken for today's really large drives and needs
* fixed.
*-F*************************************************************************/
int
static int
aic7xxx_biosparam(struct scsi_device *sdev, struct block_device *bdev,
sector_t capacity, int geom[])
{
......@@ -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
* module.
*-F*************************************************************************/
int
static int
aic7xxx_release(struct Scsi_Host *host)
{
struct aic7xxx_host *p = (struct aic7xxx_host *) host->hostdata;
......@@ -11141,8 +11142,25 @@ aic7xxx_print_scratch_ram(struct aic7xxx_host *p)
MODULE_LICENSE("Dual BSD/GPL");
/* Eventually this will go into an include file, but this will be later */
static Scsi_Host_Template driver_template = AIC7XXX;
static Scsi_Host_Template driver_template = {
.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"
......
......@@ -25,48 +25,4 @@
#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 */
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