Commit 8a1e803d authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman

istallion: use bit ops for the board flags

This lets us avoid problems with races on the flag changes
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b4eda9cb
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* FIXME: brdp->state needs proper locking.
*/ */
/*****************************************************************************/ /*****************************************************************************/
...@@ -204,9 +203,9 @@ static int stli_shared; ...@@ -204,9 +203,9 @@ static int stli_shared;
* the board has been detected, and whether it is actually running a slave * the board has been detected, and whether it is actually running a slave
* or not. * or not.
*/ */
#define BST_FOUND 0x1 #define BST_FOUND 0
#define BST_STARTED 0x2 #define BST_STARTED 1
#define BST_PROBED 0x4 #define BST_PROBED 2
/* /*
* Define the set of port state flags. These are marked for internal * Define the set of port state flags. These are marked for internal
...@@ -817,7 +816,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp) ...@@ -817,7 +816,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
brdp = stli_brds[brdnr]; brdp = stli_brds[brdnr];
if (brdp == NULL) if (brdp == NULL)
return -ENODEV; return -ENODEV;
if ((brdp->state & BST_STARTED) == 0) if (!test_bit(BST_STARTED, &brdp->state))
return -ENODEV; return -ENODEV;
portnr = MINOR2PORT(minordev); portnr = MINOR2PORT(minordev);
if (portnr > brdp->nrports) if (portnr > brdp->nrports)
...@@ -1847,7 +1846,7 @@ static void stli_portinfo(struct seq_file *m, struct stlibrd *brdp, struct stlip ...@@ -1847,7 +1846,7 @@ static void stli_portinfo(struct seq_file *m, struct stlibrd *brdp, struct stlip
rc = stli_portcmdstats(NULL, portp); rc = stli_portcmdstats(NULL, portp);
uart = "UNKNOWN"; uart = "UNKNOWN";
if (brdp->state & BST_STARTED) { if (test_bit(BST_STARTED, &brdp->state)) {
switch (stli_comstats.hwid) { switch (stli_comstats.hwid) {
case 0: uart = "2681"; break; case 0: uart = "2681"; break;
case 1: uart = "SC26198"; break; case 1: uart = "SC26198"; break;
...@@ -1856,7 +1855,7 @@ static void stli_portinfo(struct seq_file *m, struct stlibrd *brdp, struct stlip ...@@ -1856,7 +1855,7 @@ static void stli_portinfo(struct seq_file *m, struct stlibrd *brdp, struct stlip
} }
seq_printf(m, "%d: uart:%s ", portnr, uart); seq_printf(m, "%d: uart:%s ", portnr, uart);
if ((brdp->state & BST_STARTED) && (rc >= 0)) { if (test_bit(BST_STARTED, &brdp->state) && rc >= 0) {
char sep; char sep;
seq_printf(m, "tx:%d rx:%d", (int) stli_comstats.txtotal, seq_printf(m, "tx:%d rx:%d", (int) stli_comstats.txtotal,
...@@ -2356,7 +2355,7 @@ static void stli_poll(unsigned long arg) ...@@ -2356,7 +2355,7 @@ static void stli_poll(unsigned long arg)
brdp = stli_brds[brdnr]; brdp = stli_brds[brdnr];
if (brdp == NULL) if (brdp == NULL)
continue; continue;
if ((brdp->state & BST_STARTED) == 0) if (!test_bit(BST_STARTED, &brdp->state))
continue; continue;
spin_lock(&brd_lock); spin_lock(&brd_lock);
...@@ -3141,7 +3140,7 @@ static int stli_initecp(struct stlibrd *brdp) ...@@ -3141,7 +3140,7 @@ static int stli_initecp(struct stlibrd *brdp)
} }
brdp->state |= BST_FOUND; set_bit(BST_FOUND, &brdp->state);
return 0; return 0;
err_unmap: err_unmap:
iounmap(brdp->membase); iounmap(brdp->membase);
...@@ -3298,7 +3297,7 @@ static int stli_initonb(struct stlibrd *brdp) ...@@ -3298,7 +3297,7 @@ static int stli_initonb(struct stlibrd *brdp)
brdp->panels[0] = brdp->nrports; brdp->panels[0] = brdp->nrports;
brdp->state |= BST_FOUND; set_bit(BST_FOUND, &brdp->state);
return 0; return 0;
err_unmap: err_unmap:
iounmap(brdp->membase); iounmap(brdp->membase);
...@@ -3408,7 +3407,7 @@ static int stli_startbrd(struct stlibrd *brdp) ...@@ -3408,7 +3407,7 @@ static int stli_startbrd(struct stlibrd *brdp)
spin_unlock_irqrestore(&brd_lock, flags); spin_unlock_irqrestore(&brd_lock, flags);
if (rc == 0) if (rc == 0)
brdp->state |= BST_STARTED; set_bit(BST_STARTED, &brdp->state);
if (! stli_timeron) { if (! stli_timeron) {
stli_timeron++; stli_timeron++;
...@@ -3711,7 +3710,7 @@ static int __devinit stli_pciprobe(struct pci_dev *pdev, ...@@ -3711,7 +3710,7 @@ static int __devinit stli_pciprobe(struct pci_dev *pdev,
if (retval) if (retval)
goto err_null; goto err_null;
brdp->state |= BST_PROBED; set_bit(BST_PROBED, &brdp->state);
pci_set_drvdata(pdev, brdp); pci_set_drvdata(pdev, brdp);
EBRDENABLE(brdp); EBRDENABLE(brdp);
...@@ -3842,7 +3841,7 @@ static int __init stli_initbrds(void) ...@@ -3842,7 +3841,7 @@ static int __init stli_initbrds(void)
brdp = stli_brds[i]; brdp = stli_brds[i];
if (brdp == NULL) if (brdp == NULL)
continue; continue;
if (brdp->state & BST_FOUND) { if (test_bit(BST_FOUND, &brdp->state)) {
EBRDENABLE(brdp); EBRDENABLE(brdp);
brdp->enable = NULL; brdp->enable = NULL;
brdp->disable = NULL; brdp->disable = NULL;
...@@ -4079,7 +4078,7 @@ static int stli_portcmdstats(struct tty_struct *tty, struct stliport *portp) ...@@ -4079,7 +4078,7 @@ static int stli_portcmdstats(struct tty_struct *tty, struct stliport *portp)
return -ENODEV; return -ENODEV;
mutex_lock(&portp->port.mutex); mutex_lock(&portp->port.mutex);
if (brdp->state & BST_STARTED) { if (test_bit(BST_STARTED, &brdp->state)) {
if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS, if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS,
&stli_cdkstats, sizeof(asystats_t), 1)) < 0) { &stli_cdkstats, sizeof(asystats_t), 1)) < 0) {
mutex_unlock(&portp->port.mutex); mutex_unlock(&portp->port.mutex);
...@@ -4194,7 +4193,7 @@ static int stli_clrportstats(struct stliport *portp, comstats_t __user *cp) ...@@ -4194,7 +4193,7 @@ static int stli_clrportstats(struct stliport *portp, comstats_t __user *cp)
mutex_lock(&portp->port.mutex); mutex_lock(&portp->port.mutex);
if (brdp->state & BST_STARTED) { if (test_bit(BST_STARTED, &brdp->state)) {
if ((rc = stli_cmdwait(brdp, portp, A_CLEARSTATS, NULL, 0, 0)) < 0) { if ((rc = stli_cmdwait(brdp, portp, A_CLEARSTATS, NULL, 0, 0)) < 0) {
mutex_unlock(&portp->port.mutex); mutex_unlock(&portp->port.mutex);
return rc; return rc;
...@@ -4323,10 +4322,10 @@ static long stli_memioctl(struct file *fp, unsigned int cmd, unsigned long arg) ...@@ -4323,10 +4322,10 @@ static long stli_memioctl(struct file *fp, unsigned int cmd, unsigned long arg)
rc = stli_startbrd(brdp); rc = stli_startbrd(brdp);
break; break;
case STL_BSTOP: case STL_BSTOP:
brdp->state &= ~BST_STARTED; clear_bit(BST_STARTED, &brdp->state);
break; break;
case STL_BRESET: case STL_BRESET:
brdp->state &= ~BST_STARTED; clear_bit(BST_STARTED, &brdp->state);
EBRDRESET(brdp); EBRDRESET(brdp);
if (stli_shared == 0) { if (stli_shared == 0) {
if (brdp->reenable != NULL) if (brdp->reenable != NULL)
...@@ -4382,7 +4381,8 @@ static void istallion_cleanup_isa(void) ...@@ -4382,7 +4381,8 @@ static void istallion_cleanup_isa(void)
unsigned int j; unsigned int j;
for (j = 0; (j < stli_nrbrds); j++) { for (j = 0; (j < stli_nrbrds); j++) {
if ((brdp = stli_brds[j]) == NULL || (brdp->state & BST_PROBED)) if ((brdp = stli_brds[j]) == NULL ||
test_bit(BST_PROBED, &brdp->state))
continue; continue;
stli_cleanup_ports(brdp); stli_cleanup_ports(brdp);
......
...@@ -86,7 +86,7 @@ struct stlibrd { ...@@ -86,7 +86,7 @@ struct stlibrd {
unsigned long magic; unsigned long magic;
unsigned int brdnr; unsigned int brdnr;
unsigned int brdtype; unsigned int brdtype;
unsigned int state; unsigned long state;
unsigned int nrpanels; unsigned int nrpanels;
unsigned int nrports; unsigned int nrports;
unsigned int nrdevs; unsigned int nrdevs;
......
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