From: Ondrej Zary <linux@rainbow-software.org>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>, linux-scsi@vger.kernel.org
Subject: [PATCH 45/52] atp870u: Introduce is880(), is885() and remove dev_id
Date: Tue, 17 Nov 2015 19:24:21 +0100 [thread overview]
Message-ID: <1447784668-23713-46-git-send-email-linux@rainbow-software.org> (raw)
In-Reply-To: <1447784668-23713-1-git-send-email-linux@rainbow-software.org>
Introduce chip type inline functions to simplify code, allowing to delete
dev_id from struct atp_unit.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
---
drivers/scsi/atp870u.c | 70 ++++++++++++++++++++++++++----------------------
drivers/scsi/atp870u.h | 1 -
2 files changed, 38 insertions(+), 33 deletions(-)
diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index 8af51a9..4bb0f4f 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -103,6 +103,17 @@ static inline u8 atp_readb_pci(struct atp_unit *atp, u8 channel, u8 reg)
return inb(atp->pciport[channel] + reg);
}
+static inline bool is880(struct atp_unit *atp)
+{
+ return atp->pdev->device == ATP880_DEVID1 ||
+ atp->pdev->device == ATP880_DEVID2;
+}
+
+static inline bool is885(struct atp_unit *atp)
+{
+ return atp->pdev->device == ATP885_DEVID;
+}
+
static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
{
unsigned long flags;
@@ -131,7 +142,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
dev->in_int[c] = 1;
cmdp = atp_readb_io(dev, c, 0x10);
if (dev->working[c] != 0) {
- if (dev->dev_id == ATP885_DEVID) {
+ if (is885(dev)) {
if ((atp_readb_io(dev, c, 0x16) & 0x80) == 0)
atp_writeb_io(dev, c, 0x16, (atp_readb_io(dev, c, 0x16) | 0x80));
}
@@ -148,7 +159,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
i = atp_readb_io(dev, c, 0x17);
- if (dev->dev_id == ATP885_DEVID)
+ if (is885(dev))
atp_writeb_pci(dev, c, 2, 0x06);
target_id = atp_readb_io(dev, c, 0x15);
@@ -169,7 +180,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
}
dev->last_cmd[c] |= 0x40;
}
- if (dev->dev_id == ATP885_DEVID)
+ if (is885(dev))
dev->r1f[c][target_id] |= j;
#ifdef ED_DBGP
printk("atp870u_intr_handle status = %x\n",i);
@@ -178,7 +189,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
if ((dev->last_cmd[c] & 0xf0) != 0x40) {
dev->last_cmd[c] = 0xff;
}
- if (dev->dev_id == ATP885_DEVID) {
+ if (is885(dev)) {
adrcnt = 0;
((unsigned char *) &adrcnt)[2] = atp_readb_io(dev, c, 0x12);
((unsigned char *) &adrcnt)[1] = atp_readb_io(dev, c, 0x13);
@@ -249,7 +260,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
return IRQ_HANDLED;
}
- if (dev->dev_id == ATP885_DEVID) {
+ if (is885(dev)) {
if ((i == 0x4c) || (i == 0x4d) || (i == 0x8c) || (i == 0x8d)) {
if ((i == 0x4c) || (i == 0x8c))
i=0x48;
@@ -301,7 +312,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
if (dev->last_cmd[c] != 0xff) {
dev->last_cmd[c] |= 0x40;
}
- if (dev->dev_id == ATP885_DEVID) {
+ if (is885(dev)) {
j = atp_readb_base(dev, 0x29) & 0xfe;
atp_writeb_base(dev, 0x29, j);
} else
@@ -316,7 +327,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
} else {
target_id &= 0x07;
}
- if (dev->dev_id == ATP885_DEVID)
+ if (is885(dev))
atp_writeb_io(dev, c, 0x10, 0x45);
workreq = dev->id[c][target_id].curr_req;
#ifdef ED_DBGP
@@ -348,15 +359,14 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
atp_writeb_io(dev, c, 0x16, 0x80);
/* enable 32 bit fifo transfer */
- if (dev->dev_id == ATP885_DEVID) {
+ if (is885(dev)) {
i = atp_readb_pci(dev, c, 1) & 0xf3;
//j=workreq->cmnd[0];
if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) {
i |= 0x0c;
}
atp_writeb_pci(dev, c, 1, i);
- } else if ((dev->dev_id == ATP880_DEVID1) ||
- (dev->dev_id == ATP880_DEVID2) ) {
+ } else if (is880(dev)) {
if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a))
atp_writeb_base(dev, 0x3b, (atp_readb_base(dev, 0x3b) & 0x3f) | 0xc0);
else
@@ -417,7 +427,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
#ifdef ED_DBGP
printk("dev->id[%d][%d].prdaddr 0x%8x\n", c, target_id, dev->id[c][target_id].prdaddr);
#endif
- if (dev->dev_id != ATP885_DEVID) {
+ if (!is885(dev)) {
atp_writeb_pci(dev, c, 2, 0x06);
atp_writeb_pci(dev, c, 2, 0x00);
}
@@ -454,14 +464,14 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
}
if (i == 0x16) {
workreq->result = atp_readb_io(dev, c, 0x0f);
- if (((dev->r1f[c][target_id] & 0x10) != 0)&&(dev->dev_id==ATP885_DEVID)) {
+ if (((dev->r1f[c][target_id] & 0x10) != 0) && is885(dev)) {
printk(KERN_WARNING "AEC67162 CRC ERROR !\n");
workreq->result = 0x02;
}
} else
workreq->result = 0x02;
- if (dev->dev_id == ATP885_DEVID) {
+ if (is885(dev)) {
j = atp_readb_base(dev, 0x29) | 0x01;
atp_writeb_base(dev, 0x29, j);
}
@@ -516,7 +526,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
atp_writeb_pci(dev, c, 2, 0x06);
atp_writeb_pci(dev, c, 2, 0x00);
atp_writeb_io(dev, c, 0x10, 0x41);
- if (dev->dev_id == ATP885_DEVID) {
+ if (is885(dev)) {
k = dev->id[c][target_id].last_len;
atp_writeb_io(dev, c, 0x12, ((unsigned char *) (&k))[2]);
atp_writeb_io(dev, c, 0x13, ((unsigned char *) (&k))[1]);
@@ -535,7 +545,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
atp_writeb_pci(dev, c, 2, 0x06);
atp_writeb_pci(dev, c, 2, 0x00);
atp_writeb_io(dev, c, 0x10, 0x41);
- if (dev->dev_id == ATP885_DEVID) {
+ if (is885(dev)) {
k = dev->id[c][target_id].last_len;
atp_writeb_io(dev, c, 0x12, ((unsigned char *) (&k))[2]);
atp_writeb_io(dev, c, 0x13, ((unsigned char *) (&k))[1]);
@@ -737,7 +747,7 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
#endif
l = scsi_bufflen(workreq);
- if (dev->dev_id == ATP885_DEVID) {
+ if (is885(dev)) {
j = atp_readb_base(dev, 0x29) & 0xfe;
atp_writeb_base(dev, 0x29, j);
dev->r1f[c][scmd_id(workreq)] = 0;
@@ -775,7 +785,7 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
atp_writeb_io(dev, c, 0x00, workreq->cmd_len);
atp_writeb_io(dev, c, 0x01, 0x2c);
- if (dev->dev_id == ATP885_DEVID)
+ if (is885(dev))
atp_writeb_io(dev, c, 0x02, 0x7f);
else
atp_writeb_io(dev, c, 0x02, 0xcf);
@@ -873,15 +883,14 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
atp_writel_pci(dev, c, 4, dev->id[c][target_id].prdaddr);
atp_writeb_pci(dev, c, 2, 0x06);
atp_writeb_pci(dev, c, 2, 0x00);
- if (dev->dev_id == ATP885_DEVID) {
+ if (is885(dev)) {
j = atp_readb_pci(dev, c, 1) & 0xf3;
if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) ||
(workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) {
j |= 0x0c;
}
atp_writeb_pci(dev, c, 1, j);
- } else if ((dev->dev_id == ATP880_DEVID1) ||
- (dev->dev_id == ATP880_DEVID2)) {
+ } else if (is880(dev)) {
if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a))
atp_writeb_base(dev, 0x3b, (atp_readb_base(dev, 0x3b) & 0x3f) | 0xc0);
else
@@ -1285,7 +1294,7 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
shpnt->unique_id = shpnt->io_port;
shpnt->irq = pdev->irq;
- if ((ent->device == ATP880_DEVID1)||(ent->device == ATP880_DEVID2)) {
+ if (is880(atpdev)) {
pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x80);//JCC082803
atpdev->ioport[0] = shpnt->io_port + 0x40;
@@ -1296,7 +1305,6 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
printk(KERN_INFO " ACARD AEC-67160 PCI Ultra3 LVD Host Adapter:"
" IO:%lx, IRQ:%d.\n", shpnt->io_port, shpnt->irq);
- atpdev->dev_id = ent->device;
atpdev->host_id[0] = host_id;
atpdev->scam_on = atp_readb_base(atpdev, 0x22);
@@ -1384,12 +1392,11 @@ flash_ok_880:
atp_writeb_base(atpdev, 0x38, 0xb0);
shpnt->max_id = 16;
shpnt->this_id = host_id;
- } else if (ent->device == ATP885_DEVID) {
+ } else if (is885(atpdev)) {
printk(KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n"
, shpnt->io_port, shpnt->irq);
atpdev->pdev = pdev;
- atpdev->dev_id = ent->device;
atpdev->ioport[0] = shpnt->io_port + 0x80;
atpdev->ioport[1] = shpnt->io_port + 0xc0;
atpdev->pciport[0] = shpnt->io_port + 0x40;
@@ -1528,7 +1535,6 @@ flash_ok_885:
atpdev->ioport[0] = shpnt->io_port;
atpdev->pciport[0] = shpnt->io_port + 0x20;
- atpdev->dev_id = ent->device;
host_id &= 0x07;
atpdev->host_id[0] = host_id;
atpdev->scam_on = atp_readb_pci(atpdev, 0, 2);
@@ -1797,7 +1803,7 @@ static void atp_is(struct atp_unit *dev, unsigned char c, bool wide_chip, unsign
dev->active_id[c] |= m;
atp_writeb_io(dev, c, 0x10, 0x30);
- if (dev->dev_id == ATP885_DEVID || dev->dev_id == ATP880_DEVID1 || dev->dev_id == ATP880_DEVID2)
+ if (is885(dev) || is880(dev))
atp_writeb_io(dev, c, 0x14, 0x00);
else /* result of is870() merge - is this a bug? */
atp_writeb_io(dev, c, 0x04, 0x00);
@@ -1877,7 +1883,7 @@ inq_ok:
if ((mbuf[7] & 0x60) == 0) {
goto not_wide;
}
- if (dev->dev_id == ATP885_DEVID || dev->dev_id == ATP880_DEVID1 || dev->dev_id == ATP880_DEVID2) {
+ if (is885(dev) || is880(dev)) {
if ((i < 8) && ((dev->global_map[c] & 0x20) == 0))
goto not_wide;
} else { /* result of is870() merge - is this a bug? */
@@ -2146,7 +2152,7 @@ not_wide:
}
continue;
set_sync:
- if ((dev->dev_id != ATP885_DEVID && dev->dev_id != ATP880_DEVID1 && dev->dev_id != ATP880_DEVID2) || (dev->sp[c][i] == 0x02)) {
+ if ((!is885(dev) && !is880(dev)) || (dev->sp[c][i] == 0x02)) {
synu[4] = 0x0c;
synuw[4] = 0x0c;
} else {
@@ -2190,7 +2196,7 @@ try_sync:
while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0) {
if ((atp_readb_io(dev, c, 0x1f) & 0x01) != 0) {
if ((m & dev->wide_id[c]) != 0) {
- if (dev->dev_id == ATP885_DEVID || dev->dev_id == ATP880_DEVID1 || dev->dev_id == ATP880_DEVID2) {
+ if (is885(dev) || is880(dev)) {
if ((m & dev->ultra_map[c]) != 0) {
atp_writeb_io(dev, c, 0x19, synuw[j++]);
} else {
@@ -2245,7 +2251,7 @@ phase_outs:
}
continue;
phase_ins:
- if (dev->dev_id == ATP885_DEVID || dev->dev_id == ATP880_DEVID1 || dev->dev_id == ATP880_DEVID2)
+ if (is885(dev) || is880(dev))
atp_writeb_io(dev, c, 0x14, 0x06);
else
atp_writeb_io(dev, c, 0x14, 0xff);
@@ -2303,7 +2309,7 @@ tar_dcons:
if (mbuf[3] > 0x64) {
continue;
}
- if (dev->dev_id == ATP885_DEVID || dev->dev_id == ATP880_DEVID1 || dev->dev_id == ATP880_DEVID2) {
+ if (is885(dev) || is880(dev)) {
if (mbuf[4] > 0x0e) {
mbuf[4] = 0x0e;
}
@@ -2313,7 +2319,7 @@ tar_dcons:
}
}
dev->id[c][i].devsp = mbuf[4];
- if (dev->dev_id == ATP885_DEVID || dev->dev_id == ATP880_DEVID1 || dev->dev_id == ATP880_DEVID2)
+ if (is885(dev) || is880(dev))
if (mbuf[3] < 0x0c) {
j = 0xb0;
goto set_syn_ok;
diff --git a/drivers/scsi/atp870u.h b/drivers/scsi/atp870u.h
index 8c47c53..f9d62a2 100644
--- a/drivers/scsi/atp870u.h
+++ b/drivers/scsi/atp870u.h
@@ -39,7 +39,6 @@ struct atp_unit
unsigned short active_id[2];
unsigned short ultra_map[2];
unsigned short async[2];
- unsigned short dev_id;
unsigned char sp[2][16];
unsigned char r1f[2][16];
struct scsi_cmnd *quereq[2][qcnt];
--
Ondrej Zary
next prev parent reply other threads:[~2015-11-17 18:36 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-17 18:23 [PATCH 00/52] [resend] atp870u: Major rework Ondrej Zary
2015-11-17 18:23 ` [PATCH 01/52] atp870u: Remove workport Ondrej Zary
2015-11-17 18:23 ` [PATCH 02/52] atp870u: Remove tmport1 Ondrej Zary
2015-11-17 18:23 ` [PATCH 03/52] atp870u: Untangle tmport Ondrej Zary
2015-11-17 18:23 ` [PATCH 04/52] atp870u: Untangle tmport #2 Ondrej Zary
2015-11-17 18:23 ` [PATCH 05/52] atp870u: Untangle tmport #3 Ondrej Zary
2015-11-17 18:23 ` [PATCH 06/52] atp870u: Untangle tmport #4 Ondrej Zary
2015-11-17 18:23 ` [PATCH 07/52] atp870u: Untangle tmport #5 Ondrej Zary
2015-11-17 18:23 ` [PATCH 08/52] atp870u: Untangle tmport #6 Ondrej Zary
2015-11-17 18:23 ` [PATCH 09/52] atp870u: Untangle tmport #7 Ondrej Zary
2015-11-17 18:23 ` [PATCH 10/52] atp870u: Untangle tmport #8 Ondrej Zary
2015-11-17 18:23 ` [PATCH 11/52] atp870u: Untangle tmpcip Ondrej Zary
2015-11-17 18:23 ` [PATCH 12/52] atp870u: Untangle tmpcip #2 Ondrej Zary
2015-11-17 18:23 ` [PATCH 13/52] atp870u: Remove ugly gotos Ondrej Zary
2015-11-17 18:23 ` [PATCH 14/52] atp870u: Remove ugly gotos #2 Ondrej Zary
2015-11-17 18:23 ` [PATCH 15/52] atp870u: Remove ugly gotos #3 Ondrej Zary
2015-11-17 18:23 ` [PATCH 16/52] atp870u: Remove ugly gotos #4 Ondrej Zary
2015-11-17 18:23 ` [PATCH 17/52] atp870u: Remove ugly gotos #5 Ondrej Zary
2015-11-17 18:23 ` [PATCH 18/52] atp870u: Introduce HW access wrappers Ondrej Zary
2015-11-17 18:23 ` [PATCH 19/52] atp870u: Convert is870() to use wrappers Ondrej Zary
2015-11-17 18:23 ` [PATCH 20/52] atp870u: Convert is880() " Ondrej Zary
2015-11-17 18:23 ` [PATCH 21/52] atp870u: Convert is885() " Ondrej Zary
2015-11-17 18:23 ` [PATCH 22/52] atp870u: Unify code format in is870(), is880() and is885() Ondrej Zary
2015-11-17 18:23 ` [PATCH 23/52] atp870u: Add channel parameter to is870() and is880() Ondrej Zary
2015-11-17 18:24 ` [PATCH 24/52] atp870u: Move chip-specific lines out of is880() and is885() Ondrej Zary
2015-11-17 18:24 ` [PATCH 25/52] atp870u: Remove is880() Ondrej Zary
2015-11-17 18:24 ` [PATCH 26/52] atp870u: Add wide_chip parameter to is870() and is885() Ondrej Zary
2015-11-17 18:24 ` [PATCH 27/52] atp870u: Add remaining 870 support to is885() Ondrej Zary
2015-11-17 18:24 ` [PATCH 28/52] atp870u: Move 870-specific code out of is870() Ondrej Zary
2015-11-17 18:24 ` [PATCH 29/52] atp870u: Remove is870() Ondrej Zary
2015-11-17 18:24 ` [PATCH 30/52] atp870u: Rename is885() to atp_is() Ondrej Zary
2015-11-17 18:24 ` [PATCH 31/52] atp870u: Convert remaining in[bwl] and out[bwl] to wrappers Ondrej Zary
2015-11-17 18:24 ` [PATCH 32/52] atp870u: Replace port 0x80 delay by udelay Ondrej Zary
2015-11-17 18:24 ` [PATCH 33/52] atp870u: Fix incorrect writeb_io access to register 0x3a Ondrej Zary
2015-11-17 18:24 ` [PATCH 34/52] atp870u: Introduce atp_set_host_id Ondrej Zary
2015-11-17 18:24 ` [PATCH 35/52] atp870u: Reduce log spam on module load/unload Ondrej Zary
2015-11-17 18:24 ` [PATCH 36/52] atp870u: Remove empty tscam_885() Ondrej Zary
2015-11-17 18:24 ` [PATCH 37/52] atp870u: Use module_pci_driver Ondrej Zary
2015-11-17 18:24 ` [PATCH 38/52] atp870u: Use n_io_port in request_region and release_region Ondrej Zary
2015-11-17 18:24 ` [PATCH 39/52] atp870u: Remove useless and broken card counting Ondrej Zary
2015-11-17 18:24 ` [PATCH 40/52] atp870u: Remove unused irq from struct atp_unit Ondrej Zary
2015-11-17 18:24 ` [PATCH 41/52] atp870u: Improve _probe() Ondrej Zary
2015-11-17 18:24 ` [PATCH 42/52] atp870u: Improve unsupported chip detection Ondrej Zary
2015-11-17 18:24 ` [PATCH 43/52] atp870u: Remove chip_ver from struct atp_unit Ondrej Zary
2015-11-17 18:24 ` [PATCH 44/52] atp870u: Simplify _probe() Ondrej Zary
2015-11-17 18:24 ` Ondrej Zary [this message]
2015-11-17 18:24 ` [PATCH 46/52] atp870u: Use pci_request_regions Ondrej Zary
2015-11-17 18:24 ` [PATCH 47/52] atp870u: Request IRQ later, remove weird locking Ondrej Zary
2015-11-17 18:24 ` [PATCH 48/52] atp870u: Remove scam_on from struct atp_unit Ondrej Zary
2015-11-17 18:24 ` [PATCH 49/52] atp870u: Initialize tables earlier Ondrej Zary
2015-11-17 18:24 ` [PATCH 50/52] atp870u: Introduce atp880_init() Ondrej Zary
2015-11-17 18:24 ` [PATCH 51/52] atp870u: Introduce atp885_init() Ondrej Zary
2015-11-17 18:24 ` [PATCH 52/52] atp870u: Introduce atp870_init() Ondrej Zary
2015-11-19 17:10 ` [PATCH 00/52] [resend] atp870u: Major rework Martin K. Petersen
-- strict thread matches above, loose matches on Subject: below --
2015-07-26 20:24 [PATCH 00/52] " Ondrej Zary
2015-07-26 20:24 ` [PATCH 45/52] atp870u: Introduce is880(), is885() and remove dev_id Ondrej Zary
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=1447784668-23713-46-git-send-email-linux@rainbow-software.org \
--to=linux@rainbow-software.org \
--cc=hch@lst.de \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/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).