From: Matthew Wilcox <matthew@wil.cx>
To: linux-scsi@vger.kernel.org
Cc: Matthew Wilcox <matthew@wil.cx>
Subject: [PATCH 18/21] advansys: Move struct device out of the cfg structures
Date: Thu, 26 Jul 2007 13:22:54 -0400 [thread overview]
Message-ID: <11854705771407-git-send-email-matthew@wil.cx> (raw)
In-Reply-To: 20070726171141.GE19275@parisc-linux.org
In-Reply-To: <20070726171141.GE19275@parisc-linux.org>
The cfg structures are supposed to be disposable after initialisation;
with the 'dev' used for DMA mapping in there, that's not possible. Move
the dev to the board.
Also inline AscInitFromAscDvcVar into its only caller, remove some
unnecessary prototypes and sort out a few minor formatting issues.
Signed-off-by: Matthew Wilcox <matthew@wil.cx>
---
drivers/scsi/advansys.c | 104 ++++++++++++++++++----------------------------
1 files changed, 41 insertions(+), 63 deletions(-)
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 3a006ed..40ce4a8 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -1391,7 +1391,6 @@ typedef struct asc_dvc_cfg {
uchar sdtr_period_offset[ASC_MAX_TID + 1];
ushort pci_slot_info;
uchar adapter_info[6];
- struct device *dev;
} ASC_DVC_CFG;
#define ASC_DEF_DVC_CNTL 0xFFFF
@@ -1842,7 +1841,6 @@ static void AscMemDWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
static void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int);
static ushort AscInitAscDvcVar(ASC_DVC_VAR *);
static ushort AscInitFromEEP(ASC_DVC_VAR *);
-static ushort AscInitFromAscDvcVar(ASC_DVC_VAR *);
static ushort AscInitMicroCodeVar(ASC_DVC_VAR *);
static int AscTestExternalLram(ASC_DVC_VAR *);
static uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar);
@@ -2840,7 +2838,6 @@ typedef struct adv_dvc_cfg {
ushort serial1; /* EEPROM serial number word 1 */
ushort serial2; /* EEPROM serial number word 2 */
ushort serial3; /* EEPROM serial number word 3 */
- struct device *dev; /* pointer to the pci dev structure for this board */
} ADV_DVC_CFG;
struct adv_dvc_var;
@@ -3013,7 +3010,6 @@ static void DvcDelayMicroSecond(ADV_DVC_VAR *, ushort);
*/
static int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
static int AdvISR(ADV_DVC_VAR *);
-static int AdvInitGetConfig(ADV_DVC_VAR *);
static int AdvInitAsc3550Driver(ADV_DVC_VAR *);
static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *);
static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *);
@@ -3614,6 +3610,7 @@ typedef struct adv_req {
* field. It is guaranteed to be allocated from DMA-able memory.
*/
typedef struct asc_board {
+ struct device *dev;
int id; /* Board Id */
uint flags; /* Board flags */
union {
@@ -4729,7 +4726,6 @@ static void asc_scsi_done_list(struct scsi_cmnd *scp)
ASC_DBG(2, "asc_scsi_done_list: begin\n");
while (scp != NULL) {
asc_board_t *boardp;
- struct device *dev;
ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong)scp);
tscp = REQPNEXT(scp);
@@ -4737,17 +4733,12 @@ static void asc_scsi_done_list(struct scsi_cmnd *scp)
boardp = ASC_BOARDP(scp->device->host);
- if (ASC_NARROW_BOARD(boardp))
- dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
- else
- dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
-
if (scp->use_sg)
- dma_unmap_sg(dev,
+ dma_unmap_sg(boardp->dev,
(struct scatterlist *)scp->request_buffer,
scp->use_sg, scp->sc_data_direction);
else if (scp->request_bufflen)
- dma_unmap_single(dev, scp->SCp.dma_handle,
+ dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
scp->request_bufflen,
scp->sc_data_direction);
@@ -4986,8 +4977,6 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
*/
static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
{
- struct device *dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
-
/*
* Mutually exclusive access is required to 'asc_scsi_q' and
* 'asc_sg_head' until after the request is started.
@@ -5051,7 +5040,7 @@ static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
*/
ASC_STATS(scp->device->host, cont_cnt);
scp->SCp.dma_handle = scp->request_bufflen ?
- dma_map_single(dev, scp->request_buffer,
+ dma_map_single(boardp->dev, scp->request_buffer,
scp->request_bufflen,
scp->sc_data_direction) : 0;
asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
@@ -5069,15 +5058,14 @@ static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
struct scatterlist *slp;
slp = (struct scatterlist *)scp->request_buffer;
- use_sg =
- dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
+ use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
+ scp->sc_data_direction);
if (use_sg > scp->device->host->sg_tablesize) {
- ASC_PRINT3
- ("asc_build_req: board %d: use_sg %d > sg_tablesize %d\n",
- boardp->id, use_sg,
- scp->device->host->sg_tablesize);
- dma_unmap_sg(dev, slp, scp->use_sg,
+ ASC_PRINT3("asc_build_req: board %d: use_sg %d > "
+ "sg_tablesize %d\n", boardp->id, use_sg,
+ scp->device->host->sg_tablesize);
+ dma_unmap_sg(boardp->dev, slp, scp->use_sg,
scp->sc_data_direction);
scp->result = HOST_BYTE(DID_ERROR);
asc_enqueue(&boardp->done, scp, ASC_BACK);
@@ -5138,7 +5126,6 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
ADV_SCSI_REQ_Q *scsiqp;
int i;
int ret;
- struct device *dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
/*
* Allocate an adv_req_t structure from the board to execute
@@ -5225,7 +5212,7 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
if (scp->request_bufflen) {
scsiqp->vdata_addr = scp->request_buffer;
scp->SCp.dma_handle =
- dma_map_single(dev, scp->request_buffer,
+ dma_map_single(boardp->dev, scp->request_buffer,
scp->request_bufflen,
scp->sc_data_direction);
} else {
@@ -5246,22 +5233,21 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
int use_sg;
slp = (struct scatterlist *)scp->request_buffer;
- use_sg =
- dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
+ use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
+ scp->sc_data_direction);
if (use_sg > ADV_MAX_SG_LIST) {
- ASC_PRINT3
- ("adv_build_req: board %d: use_sg %d > ADV_MAX_SG_LIST %d\n",
- boardp->id, use_sg,
- scp->device->host->sg_tablesize);
- dma_unmap_sg(dev, slp, scp->use_sg,
+ ASC_PRINT3("adv_build_req: board %d: use_sg %d > "
+ "ADV_MAX_SG_LIST %d\n", boardp->id, use_sg,
+ scp->device->host->sg_tablesize);
+ dma_unmap_sg(boardp->dev, slp, scp->use_sg,
scp->sc_data_direction);
scp->result = HOST_BYTE(DID_ERROR);
asc_enqueue(&boardp->done, scp, ASC_BACK);
/*
- * Free the 'adv_req_t' structure by adding it back to the
- * board free list.
+ * Free the 'adv_req_t' structure by adding it back
+ * to the board free list.
*/
reqp->next_reqp = boardp->adv_reqp;
boardp->adv_reqp = reqp;
@@ -5269,12 +5255,11 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
return ASC_ERROR;
}
- if ((ret =
- adv_get_sglist(boardp, reqp, scp,
- use_sg)) != ADV_SUCCESS) {
+ ret = adv_get_sglist(boardp, reqp, scp, use_sg);
+ if (ret != ADV_SUCCESS) {
/*
- * Free the adv_req_t structure by adding it back to the
- * board free list.
+ * Free the adv_req_t structure by adding it back to
+ * the board free list.
*/
reqp->next_reqp = boardp->adv_reqp;
boardp->adv_reqp = reqp;
@@ -10377,30 +10362,21 @@ static ushort __devinit AscInitGetConfig(ASC_DVC_VAR *asc_dvc)
return warn_code;
}
-static ushort __devinit AscInitSetConfig(ASC_DVC_VAR *asc_dvc)
+static unsigned short __devinit
+AscInitSetConfig(struct pci_dev *pdev, ASC_DVC_VAR *asc_dvc)
{
- ushort warn_code = 0;
+ PortAddr iop_base = asc_dvc->iop_base;
+ unsigned short cfg_msw;
+ unsigned short warn_code = 0;
asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
if (asc_dvc->err_code != 0)
- return (UW_ERR);
- if (AscFindSignature(asc_dvc->iop_base)) {
- warn_code |= AscInitFromAscDvcVar(asc_dvc);
- asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
- } else {
+ return UW_ERR;
+ if (!AscFindSignature(asc_dvc->iop_base)) {
asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
+ return 0;
}
- return (warn_code);
-}
-
-static ushort __devinit AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
-{
- PortAddr iop_base;
- ushort cfg_msw;
- ushort warn_code;
- iop_base = asc_dvc->iop_base;
- warn_code = 0;
cfg_msw = AscGetChipCfgMsw(iop_base);
if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
@@ -10423,7 +10399,6 @@ static ushort __devinit AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
}
#ifdef CONFIG_PCI
if (asc_dvc->bus_type & ASC_IS_PCI) {
- struct pci_dev *pdev = to_pci_dev(asc_dvc->cfg->dev);
cfg_msw &= 0xFFC0;
AscSetChipCfgMsw(iop_base, cfg_msw);
if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
@@ -10453,7 +10428,9 @@ static ushort __devinit AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
}
#endif /* CONFIG_ISA */
- return (warn_code);
+
+ asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
+ return warn_code;
}
static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
@@ -13757,11 +13734,11 @@ static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata =
* For a non-fatal error return a warning code. If there are no warnings
* then 0 is returned.
*/
-static int __devinit AdvInitGetConfig(ADV_DVC_VAR *asc_dvc)
+static int __devinit
+AdvInitGetConfig(struct pci_dev *pdev, ADV_DVC_VAR *asc_dvc)
{
unsigned short warn_code = 0;
AdvPortAddr iop_base = asc_dvc->iop_base;
- struct pci_dev *pdev = to_pci_dev(asc_dvc->cfg->dev);
u16 cmd;
int status;
@@ -17244,6 +17221,7 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
memset(boardp, 0, sizeof(asc_board_t));
boardp->id = asc_board_count - 1;
spin_lock_init(&boardp->lock);
+ boardp->dev = dev;
/*
* Handle both narrow and wide boards.
@@ -17330,7 +17308,6 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
#endif /* CONFIG_PROC_FS */
if (ASC_NARROW_BOARD(boardp)) {
- asc_dvc_varp->cfg->dev = dev;
/*
* Set the board bus type and PCI IRQ before
* calling AscInitGetConfig().
@@ -17370,7 +17347,6 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
break;
}
} else {
- adv_dvc_varp->cfg->dev = dev;
/*
* For Wide boards set PCI information before calling
* AdvInitGetConfig().
@@ -17439,7 +17415,9 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
}
} else {
ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
- if ((ret = AdvInitGetConfig(adv_dvc_varp)) != 0) {
+
+ ret = AdvInitGetConfig(pdev, adv_dvc_varp);
+ if (ret != 0) {
ASC_PRINT2
("AdvInitGetConfig: board %d: warning: 0x%x\n",
boardp->id, ret);
@@ -17495,7 +17473,7 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
* Modify board configuration.
*/
ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
- switch (ret = AscInitSetConfig(asc_dvc_varp)) {
+ switch (ret = AscInitSetConfig(pdev, asc_dvc_varp)) {
case 0: /* No error. */
break;
case ASC_WARN_IO_PORT_ROTATE:
--
1.4.4.4
next prev parent reply other threads:[~2007-07-26 18:01 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-26 17:11 Advansys driver Matthew Wilcox
2007-07-26 17:22 ` [PATCH 1/21] advansys: Clean up proc_info implementation Matthew Wilcox
2007-07-26 18:51 ` Jeff Garzik
2007-07-26 19:05 ` Matthew Wilcox
2007-07-26 17:22 ` [PATCH 2/21] advansys: version, copyright, etc Matthew Wilcox
2007-07-26 18:56 ` Jeff Garzik
2007-07-26 19:03 ` Matthew Wilcox
2007-07-26 19:08 ` Jeff Garzik
2007-07-26 19:16 ` Matthew Wilcox
2007-07-26 19:25 ` Christer Weinigel
2007-07-26 17:22 ` [PATCH 3/21] advansys: Convert to pci_register_driver interface Matthew Wilcox
2007-07-26 19:05 ` Jeff Garzik
2007-07-26 19:31 ` Jeff Garzik
2007-07-26 20:49 ` Matthew Wilcox
2007-07-26 21:21 ` Jeff Garzik
2007-07-27 13:48 ` Jeff Garzik
2007-07-26 17:22 ` [PATCH 4/21] advansys: restructure error handling in advansys_board_found Matthew Wilcox
2007-07-26 17:22 ` [PATCH 5/21] advansys: split advansys_init_wide_chip() out of advansys_board_found() Matthew Wilcox
2007-07-26 17:22 ` [PATCH 6/21] advansys: Move to scsi hotplug initialisation model Matthew Wilcox
2007-07-26 18:01 ` Christoph Hellwig
2007-07-26 18:04 ` Matthew Wilcox
2007-07-26 18:06 ` Matthew Wilcox
2007-07-26 18:16 ` Jeff Garzik
2007-07-26 18:29 ` Matthew Wilcox
2007-07-26 18:13 ` Jeff Garzik
2007-07-26 19:19 ` Jeff Garzik
2007-07-26 17:22 ` [PATCH 7/21] advansys: Convert to EISA driver model Matthew Wilcox
2007-07-26 19:38 ` Jeff Garzik
2007-07-26 20:37 ` Matthew Wilcox
2007-07-27 13:50 ` Jeff Garzik
2007-07-27 14:16 ` Matthew Wilcox
2007-07-27 14:55 ` Jeff Garzik
2007-07-26 17:22 ` [PATCH 8/21] advansys: Rewrite resource management Matthew Wilcox
2007-07-26 19:41 ` Jeff Garzik
2007-07-26 17:22 ` [PATCH 9/21] advansys: More PCI cleanups Matthew Wilcox
2007-07-26 19:43 ` Jeff Garzik
2007-07-26 19:50 ` Matthew Wilcox
2007-07-26 19:55 ` Jeff Garzik
2007-07-26 17:22 ` [PATCH 10/21] advansys: remove AscCompareString() Matthew Wilcox
2007-07-26 17:22 ` [PATCH 11/21] Add QUANTUM XP34301 to the blacklist Matthew Wilcox
2007-07-26 17:22 ` [PATCH 12/21] advansys: remove INQUIRY sniffing Matthew Wilcox
2007-07-26 17:22 ` [PATCH 13/21] advansys: misc reformatting Matthew Wilcox
2007-07-26 17:22 ` [PATCH 14/21] advansys: delete AscGetChipBusType Matthew Wilcox
2007-07-26 17:22 ` [PATCH 15/21] advansys: ioremap no longer needs page-aligned addresses Matthew Wilcox
2007-07-26 17:22 ` [PATCH 16/21] advansys: Stop using n_io_port in Scsi_Host structure Matthew Wilcox
2007-07-26 17:22 ` [PATCH 17/21] advansys: remove detect_called Matthew Wilcox
2007-07-26 19:48 ` Jeff Garzik
2007-07-26 17:22 ` Matthew Wilcox [this message]
2007-07-26 19:49 ` [PATCH 18/21] advansys: Move struct device out of the cfg structures Jeff Garzik
2007-07-26 20:26 ` Matthew Wilcox
2007-07-26 17:22 ` [PATCH 19/21] advansys: Remove library-style callback routines Matthew Wilcox
2007-07-26 17:22 ` [PATCH 20/21] advansys: Remove pci_slot_info Matthew Wilcox
2007-07-26 17:22 ` [PATCH 21/21] advansys: use memcpy instead of open-coded loop Matthew Wilcox
2007-07-26 19:50 ` Jeff Garzik
2007-07-27 4:58 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11854705771407-git-send-email-matthew@wil.cx \
--to=matthew@wil.cx \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.