From: Geert Uytterhoeven <geert@linux-m68k.org>
To: "James E.J. Bottomley" <James.Bottomley@suse.de>
Cc: linux-m68k@lists.linux-m68k.org, linux-scsi@vger.kernel.org,
Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH 07/21] m68k/scsi: gvp11 - Use shost_priv() and kill ugly HDATA() macro
Date: Sun, 4 Apr 2010 11:00:37 +0200 [thread overview]
Message-ID: <1270371651-2584-8-git-send-email-geert@linux-m68k.org> (raw)
In-Reply-To: <1270371651-2584-7-git-send-email-geert@linux-m68k.org>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/scsi/gvp11.c | 93 ++++++++++++++++++++++++-------------------------
1 files changed, 46 insertions(+), 47 deletions(-)
diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c
index 6ec7520..b370591 100644
--- a/drivers/scsi/gvp11.c
+++ b/drivers/scsi/gvp11.c
@@ -22,7 +22,6 @@
#define DMA(ptr) ((gvp11_scsiregs *)((ptr)->base))
-#define HDATA(ptr) ((struct WD33C93_hostdata *)((ptr)->hostdata))
static irqreturn_t gvp11_intr(int irq, void *_instance)
{
@@ -49,70 +48,66 @@ void gvp11_setup(char *str, int *ints)
static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
{
+ struct Scsi_Host *instance = cmd->device->host;
+ struct WD33C93_hostdata *hdata = shost_priv(instance);
unsigned short cntr = GVP11_DMAC_INT_ENABLE;
unsigned long addr = virt_to_bus(cmd->SCp.ptr);
int bank_mask;
static int scsi_alloc_out_of_range = 0;
/* use bounce buffer if the physical address is bad */
- if (addr & HDATA(cmd->device->host)->dma_xfer_mask) {
- HDATA(cmd->device->host)->dma_bounce_len =
- (cmd->SCp.this_residual + 511) & ~0x1ff;
+ if (addr & hdata->dma_xfer_mask) {
+ hdata->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff;
if (!scsi_alloc_out_of_range) {
- HDATA(cmd->device->host)->dma_bounce_buffer =
- kmalloc(HDATA(cmd->device->host)->dma_bounce_len,
- GFP_KERNEL);
- HDATA(cmd->device->host)->dma_buffer_pool =
- BUF_SCSI_ALLOCED;
+ hdata->dma_bounce_buffer =
+ kmalloc(hdata->dma_bounce_len, GFP_KERNEL);
+ hdata->dma_buffer_pool = BUF_SCSI_ALLOCED;
}
if (scsi_alloc_out_of_range ||
- !HDATA(cmd->device->host)->dma_bounce_buffer) {
- HDATA(cmd->device->host)->dma_bounce_buffer =
- amiga_chip_alloc(HDATA(cmd->device->host)->dma_bounce_len,
+ !hdata->dma_bounce_buffer) {
+ hdata->dma_bounce_buffer =
+ amiga_chip_alloc(hdata->dma_bounce_len,
"GVP II SCSI Bounce Buffer");
- if (!HDATA(cmd->device->host)->dma_bounce_buffer) {
- HDATA(cmd->device->host)->dma_bounce_len = 0;
+ if (!hdata->dma_bounce_buffer) {
+ hdata->dma_bounce_len = 0;
return 1;
}
- HDATA(cmd->device->host)->dma_buffer_pool =
- BUF_CHIP_ALLOCED;
+ hdata->dma_buffer_pool = BUF_CHIP_ALLOCED;
}
/* check if the address of the bounce buffer is OK */
- addr = virt_to_bus(HDATA(cmd->device->host)->dma_bounce_buffer);
+ addr = virt_to_bus(hdata->dma_bounce_buffer);
- if (addr & HDATA(cmd->device->host)->dma_xfer_mask) {
+ if (addr & hdata->dma_xfer_mask) {
/* fall back to Chip RAM if address out of range */
- if (HDATA(cmd->device->host)->dma_buffer_pool ==
- BUF_SCSI_ALLOCED) {
- kfree(HDATA(cmd->device->host)->dma_bounce_buffer);
+ if (hdata->dma_buffer_pool == BUF_SCSI_ALLOCED) {
+ kfree(hdata->dma_bounce_buffer);
scsi_alloc_out_of_range = 1;
} else {
- amiga_chip_free(HDATA(cmd->device->host)->dma_bounce_buffer);
+ amiga_chip_free(hdata->dma_bounce_buffer);
}
- HDATA(cmd->device->host)->dma_bounce_buffer =
- amiga_chip_alloc(HDATA(cmd->device->host)->dma_bounce_len,
+ hdata->dma_bounce_buffer =
+ amiga_chip_alloc(hdata->dma_bounce_len,
"GVP II SCSI Bounce Buffer");
- if (!HDATA(cmd->device->host)->dma_bounce_buffer) {
- HDATA(cmd->device->host)->dma_bounce_len = 0;
+ if (!hdata->dma_bounce_buffer) {
+ hdata->dma_bounce_len = 0;
return 1;
}
- addr = virt_to_bus(HDATA(cmd->device->host)->dma_bounce_buffer);
- HDATA(cmd->device->host)->dma_buffer_pool =
- BUF_CHIP_ALLOCED;
+ addr = virt_to_bus(hdata->dma_bounce_buffer);
+ hdata->dma_buffer_pool = BUF_CHIP_ALLOCED;
}
if (!dir_in) {
/* copy to bounce buffer for a write */
- memcpy(HDATA(cmd->device->host)->dma_bounce_buffer,
- cmd->SCp.ptr, cmd->SCp.this_residual);
+ memcpy(hdata->dma_bounce_buffer, cmd->SCp.ptr,
+ cmd->SCp.this_residual);
}
}
@@ -120,7 +115,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
if (!dir_in)
cntr |= GVP11_DMAC_DIR_WRITE;
- HDATA(cmd->device->host)->dma_dir = dir_in;
+ hdata->dma_dir = dir_in;
DMA(cmd->device->host)->CNTR = cntr;
/* setup DMA *physical* address */
@@ -134,7 +129,8 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
cache_push(addr, cmd->SCp.this_residual);
}
- if ((bank_mask = (~HDATA(cmd->device->host)->dma_xfer_mask >> 18) & 0x01c0))
+ bank_mask = (~hdata->dma_xfer_mask >> 18) & 0x01c0;
+ if (bank_mask)
DMA(cmd->device->host)->BANK = bank_mask & (addr >> 18);
/* start DMA */
@@ -147,25 +143,26 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
int status)
{
+ struct WD33C93_hostdata *hdata = shost_priv(instance);
+
/* stop DMA */
DMA(instance)->SP_DMA = 1;
/* remove write bit from CONTROL bits */
DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE;
/* copy from a bounce buffer, if necessary */
- if (status && HDATA(instance)->dma_bounce_buffer) {
- if (HDATA(instance)->dma_dir && SCpnt)
- memcpy(SCpnt->SCp.ptr,
- HDATA(instance)->dma_bounce_buffer,
+ if (status && hdata->dma_bounce_buffer) {
+ if (hdata->dma_dir && SCpnt)
+ memcpy(SCpnt->SCp.ptr, hdata->dma_bounce_buffer,
SCpnt->SCp.this_residual);
- if (HDATA(instance)->dma_buffer_pool == BUF_SCSI_ALLOCED)
- kfree(HDATA(instance)->dma_bounce_buffer);
+ if (hdata->dma_buffer_pool == BUF_SCSI_ALLOCED)
+ kfree(hdata->dma_bounce_buffer);
else
- amiga_chip_free(HDATA(instance)->dma_bounce_buffer);
+ amiga_chip_free(hdata->dma_bounce_buffer);
- HDATA(instance)->dma_bounce_buffer = NULL;
- HDATA(instance)->dma_bounce_len = 0;
+ hdata->dma_bounce_buffer = NULL;
+ hdata->dma_bounce_len = 0;
}
}
@@ -179,6 +176,7 @@ int __init gvp11_detect(struct scsi_host_template *tpnt)
unsigned int epc;
struct zorro_dev *z = NULL;
unsigned int default_dma_xfer_mask;
+ struct WD33C93_hostdata *hdata;
wd33c93_regs regs;
int num_gvp11 = 0;
#ifdef CHECK_WD33C93
@@ -305,10 +303,11 @@ int __init gvp11_detect(struct scsi_host_template *tpnt)
instance->irq = IRQ_AMIGA_PORTS;
instance->unique_id = z->slotaddr;
+ hdata = shost_priv(instance);
if (gvp11_xfer_mask)
- HDATA(instance)->dma_xfer_mask = gvp11_xfer_mask;
+ hdata->dma_xfer_mask = gvp11_xfer_mask;
else
- HDATA(instance)->dma_xfer_mask = default_dma_xfer_mask;
+ hdata->dma_xfer_mask = default_dma_xfer_mask;
DMA(instance)->secret2 = 1;
DMA(instance)->secret1 = 0;
@@ -326,9 +325,9 @@ int __init gvp11_detect(struct scsi_host_template *tpnt)
*/
regs.SASR = &(DMA(instance)->SASR);
regs.SCMD = &(DMA(instance)->SCMD);
- HDATA(instance)->no_sync = 0xff;
- HDATA(instance)->fast = 0;
- HDATA(instance)->dma_mode = CTRL_DMA;
+ hdata->no_sync = 0xff;
+ hdata->fast = 0;
+ hdata->dma_mode = CTRL_DMA;
wd33c93_init(instance, regs, dma_setup, dma_stop,
(epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10
: WD33C93_FS_12_15);
--
1.6.0.4
next prev parent reply other threads:[~2010-04-04 9:00 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-04 9:00 [PATCH 0/21] m68k/scsi: wd33c93 driver cleanups Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 01/21] scsi: wd33c93 - Kill empty wd33c93_release() Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 02/21] m68k/scsi: a2091 - Reindentation Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 03/21] m68k/scsi: gvp11 " Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 04/21] m68k/scsi: mvme147 " Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 05/21] m68k/scsi: a3000 " Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 06/21] m68k/scsi: a2091 - Use shost_priv() and kill ugly HDATA() macro Geert Uytterhoeven
2010-04-04 9:00 ` Geert Uytterhoeven [this message]
2010-04-04 9:00 ` [PATCH 08/21] m68k/scsi: mvme147 " Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 09/21] m68k/scsi: a3000 " Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 10/21] m68k/scsi: a2091 - Kill ugly DMA() macro Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 11/21] m68k/scsi: gvp11 " Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 12/21] m68k/scsi: a3000 " Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 13/21] m68k/scsi: mvme147 - Kill static global mvme147_host Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 14/21] m68k/scsi: a3000 - Kill static global a3000_host Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 15/21] m68k/scsi: gvp11 - Extract check_wd33c93() Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 16/21] m68k/scsi: a2091 - Kill a2091_scsiregs typedef Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 17/21] m68k/scsi: gvp11 - Kill gvp11_scsiregs typedef Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 18/21] m68k/scsi: a3000 - Kill a3000_scsiregs typedef Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 19/21] m68k/scsi: mvme147 - Kill obsolete HOSTS_C logic Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 20/21] m68k: amiga - A2091/A590 SCSI zorro_driver conversion Geert Uytterhoeven
2010-04-04 9:00 ` [PATCH 21/21] m68k: amiga - GVP Series II " Geert Uytterhoeven
2010-04-05 6:25 ` [PATCH 10/21] m68k/scsi: a2091 - Kill ugly DMA() macro Christoph Hellwig
2010-04-05 19:42 ` Geert Uytterhoeven
2010-04-23 8:37 ` Geert Uytterhoeven
2010-04-23 8:38 ` Geert Uytterhoeven
2010-04-23 8:40 ` Geert Uytterhoeven
2010-04-23 10:15 ` [PATCH] SCSI: sgiwd93: remove use of legacy base field of host struct Ralf Baechle
2010-04-23 10:26 ` [PATCH] SCSI: sgiwd93: Convert to use shost_priv() Ralf Baechle
2010-05-02 20:05 ` [PATCH 10/21] m68k/scsi: a2091 - Kill ugly DMA() macro James Bottomley
2010-05-03 19:25 ` Geert Uytterhoeven
2010-05-13 19:41 ` Geert Uytterhoeven
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=1270371651-2584-8-git-send-email-geert@linux-m68k.org \
--to=geert@linux-m68k.org \
--cc=James.Bottomley@suse.de \
--cc=linux-m68k@lists.linux-m68k.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).