diff options
author | Alan Cox <alan@linux.intel.com> | 2010-06-01 16:52:42 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 16:47:40 -0400 |
commit | 8a1e803d0148e320b9200a442dfb88f8cbde88e7 (patch) | |
tree | 431694cff4ad1a30f54aeb1bc26dc2f651bfe7bc | |
parent | b4eda9cb48eac1b7369ad33e5d015c33b4376431 (diff) |
istallion: use bit ops for the board flags
This lets us avoid problems with races on the flag changes
Signed-off-by: Alan Cox <alan@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/char/istallion.c | 36 | ||||
-rw-r--r-- | include/linux/istallion.h | 2 |
2 files changed, 19 insertions, 19 deletions
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index 750650cbac11..5e9a81d8ebcf 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * the Free Software Foundation; either version 2 of the License, or | 14 | * the Free Software Foundation; either version 2 of the License, or |
15 | * (at your option) any later version. | 15 | * (at your option) any later version. |
16 | * | 16 | * |
17 | * FIXME: brdp->state needs proper locking. | ||
18 | */ | 17 | */ |
19 | 18 | ||
20 | /*****************************************************************************/ | 19 | /*****************************************************************************/ |
@@ -204,9 +203,9 @@ static int stli_shared; | |||
204 | * the board has been detected, and whether it is actually running a slave | 203 | * the board has been detected, and whether it is actually running a slave |
205 | * or not. | 204 | * or not. |
206 | */ | 205 | */ |
207 | #define BST_FOUND 0x1 | 206 | #define BST_FOUND 0 |
208 | #define BST_STARTED 0x2 | 207 | #define BST_STARTED 1 |
209 | #define BST_PROBED 0x4 | 208 | #define BST_PROBED 2 |
210 | 209 | ||
211 | /* | 210 | /* |
212 | * Define the set of port state flags. These are marked for internal | 211 | * 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 | brdp = stli_brds[brdnr]; | 816 | brdp = stli_brds[brdnr]; |
818 | if (brdp == NULL) | 817 | if (brdp == NULL) |
819 | return -ENODEV; | 818 | return -ENODEV; |
820 | if ((brdp->state & BST_STARTED) == 0) | 819 | if (!test_bit(BST_STARTED, &brdp->state)) |
821 | return -ENODEV; | 820 | return -ENODEV; |
822 | portnr = MINOR2PORT(minordev); | 821 | portnr = MINOR2PORT(minordev); |
823 | if (portnr > brdp->nrports) | 822 | if (portnr > brdp->nrports) |
@@ -1847,7 +1846,7 @@ static void stli_portinfo(struct seq_file *m, struct stlibrd *brdp, struct stlip | |||
1847 | rc = stli_portcmdstats(NULL, portp); | 1846 | rc = stli_portcmdstats(NULL, portp); |
1848 | 1847 | ||
1849 | uart = "UNKNOWN"; | 1848 | uart = "UNKNOWN"; |
1850 | if (brdp->state & BST_STARTED) { | 1849 | if (test_bit(BST_STARTED, &brdp->state)) { |
1851 | switch (stli_comstats.hwid) { | 1850 | switch (stli_comstats.hwid) { |
1852 | case 0: uart = "2681"; break; | 1851 | case 0: uart = "2681"; break; |
1853 | case 1: uart = "SC26198"; break; | 1852 | case 1: uart = "SC26198"; break; |
@@ -1856,7 +1855,7 @@ static void stli_portinfo(struct seq_file *m, struct stlibrd *brdp, struct stlip | |||
1856 | } | 1855 | } |
1857 | seq_printf(m, "%d: uart:%s ", portnr, uart); | 1856 | seq_printf(m, "%d: uart:%s ", portnr, uart); |
1858 | 1857 | ||
1859 | if ((brdp->state & BST_STARTED) && (rc >= 0)) { | 1858 | if (test_bit(BST_STARTED, &brdp->state) && rc >= 0) { |
1860 | char sep; | 1859 | char sep; |
1861 | 1860 | ||
1862 | seq_printf(m, "tx:%d rx:%d", (int) stli_comstats.txtotal, | 1861 | seq_printf(m, "tx:%d rx:%d", (int) stli_comstats.txtotal, |
@@ -2356,7 +2355,7 @@ static void stli_poll(unsigned long arg) | |||
2356 | brdp = stli_brds[brdnr]; | 2355 | brdp = stli_brds[brdnr]; |
2357 | if (brdp == NULL) | 2356 | if (brdp == NULL) |
2358 | continue; | 2357 | continue; |
2359 | if ((brdp->state & BST_STARTED) == 0) | 2358 | if (!test_bit(BST_STARTED, &brdp->state)) |
2360 | continue; | 2359 | continue; |
2361 | 2360 | ||
2362 | spin_lock(&brd_lock); | 2361 | spin_lock(&brd_lock); |
@@ -3141,7 +3140,7 @@ static int stli_initecp(struct stlibrd *brdp) | |||
3141 | } | 3140 | } |
3142 | 3141 | ||
3143 | 3142 | ||
3144 | brdp->state |= BST_FOUND; | 3143 | set_bit(BST_FOUND, &brdp->state); |
3145 | return 0; | 3144 | return 0; |
3146 | err_unmap: | 3145 | err_unmap: |
3147 | iounmap(brdp->membase); | 3146 | iounmap(brdp->membase); |
@@ -3298,7 +3297,7 @@ static int stli_initonb(struct stlibrd *brdp) | |||
3298 | brdp->panels[0] = brdp->nrports; | 3297 | brdp->panels[0] = brdp->nrports; |
3299 | 3298 | ||
3300 | 3299 | ||
3301 | brdp->state |= BST_FOUND; | 3300 | set_bit(BST_FOUND, &brdp->state); |
3302 | return 0; | 3301 | return 0; |
3303 | err_unmap: | 3302 | err_unmap: |
3304 | iounmap(brdp->membase); | 3303 | iounmap(brdp->membase); |
@@ -3408,7 +3407,7 @@ stli_donestartup: | |||
3408 | spin_unlock_irqrestore(&brd_lock, flags); | 3407 | spin_unlock_irqrestore(&brd_lock, flags); |
3409 | 3408 | ||
3410 | if (rc == 0) | 3409 | if (rc == 0) |
3411 | brdp->state |= BST_STARTED; | 3410 | set_bit(BST_STARTED, &brdp->state); |
3412 | 3411 | ||
3413 | if (! stli_timeron) { | 3412 | if (! stli_timeron) { |
3414 | stli_timeron++; | 3413 | stli_timeron++; |
@@ -3711,7 +3710,7 @@ static int __devinit stli_pciprobe(struct pci_dev *pdev, | |||
3711 | if (retval) | 3710 | if (retval) |
3712 | goto err_null; | 3711 | goto err_null; |
3713 | 3712 | ||
3714 | brdp->state |= BST_PROBED; | 3713 | set_bit(BST_PROBED, &brdp->state); |
3715 | pci_set_drvdata(pdev, brdp); | 3714 | pci_set_drvdata(pdev, brdp); |
3716 | 3715 | ||
3717 | EBRDENABLE(brdp); | 3716 | EBRDENABLE(brdp); |
@@ -3842,7 +3841,7 @@ static int __init stli_initbrds(void) | |||
3842 | brdp = stli_brds[i]; | 3841 | brdp = stli_brds[i]; |
3843 | if (brdp == NULL) | 3842 | if (brdp == NULL) |
3844 | continue; | 3843 | continue; |
3845 | if (brdp->state & BST_FOUND) { | 3844 | if (test_bit(BST_FOUND, &brdp->state)) { |
3846 | EBRDENABLE(brdp); | 3845 | EBRDENABLE(brdp); |
3847 | brdp->enable = NULL; | 3846 | brdp->enable = NULL; |
3848 | brdp->disable = NULL; | 3847 | brdp->disable = NULL; |
@@ -4079,7 +4078,7 @@ static int stli_portcmdstats(struct tty_struct *tty, struct stliport *portp) | |||
4079 | return -ENODEV; | 4078 | return -ENODEV; |
4080 | 4079 | ||
4081 | mutex_lock(&portp->port.mutex); | 4080 | mutex_lock(&portp->port.mutex); |
4082 | if (brdp->state & BST_STARTED) { | 4081 | if (test_bit(BST_STARTED, &brdp->state)) { |
4083 | if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS, | 4082 | if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS, |
4084 | &stli_cdkstats, sizeof(asystats_t), 1)) < 0) { | 4083 | &stli_cdkstats, sizeof(asystats_t), 1)) < 0) { |
4085 | mutex_unlock(&portp->port.mutex); | 4084 | mutex_unlock(&portp->port.mutex); |
@@ -4194,7 +4193,7 @@ static int stli_clrportstats(struct stliport *portp, comstats_t __user *cp) | |||
4194 | 4193 | ||
4195 | mutex_lock(&portp->port.mutex); | 4194 | mutex_lock(&portp->port.mutex); |
4196 | 4195 | ||
4197 | if (brdp->state & BST_STARTED) { | 4196 | if (test_bit(BST_STARTED, &brdp->state)) { |
4198 | if ((rc = stli_cmdwait(brdp, portp, A_CLEARSTATS, NULL, 0, 0)) < 0) { | 4197 | if ((rc = stli_cmdwait(brdp, portp, A_CLEARSTATS, NULL, 0, 0)) < 0) { |
4199 | mutex_unlock(&portp->port.mutex); | 4198 | mutex_unlock(&portp->port.mutex); |
4200 | return rc; | 4199 | return rc; |
@@ -4323,10 +4322,10 @@ static long stli_memioctl(struct file *fp, unsigned int cmd, unsigned long arg) | |||
4323 | rc = stli_startbrd(brdp); | 4322 | rc = stli_startbrd(brdp); |
4324 | break; | 4323 | break; |
4325 | case STL_BSTOP: | 4324 | case STL_BSTOP: |
4326 | brdp->state &= ~BST_STARTED; | 4325 | clear_bit(BST_STARTED, &brdp->state); |
4327 | break; | 4326 | break; |
4328 | case STL_BRESET: | 4327 | case STL_BRESET: |
4329 | brdp->state &= ~BST_STARTED; | 4328 | clear_bit(BST_STARTED, &brdp->state); |
4330 | EBRDRESET(brdp); | 4329 | EBRDRESET(brdp); |
4331 | if (stli_shared == 0) { | 4330 | if (stli_shared == 0) { |
4332 | if (brdp->reenable != NULL) | 4331 | if (brdp->reenable != NULL) |
@@ -4382,7 +4381,8 @@ static void istallion_cleanup_isa(void) | |||
4382 | unsigned int j; | 4381 | unsigned int j; |
4383 | 4382 | ||
4384 | for (j = 0; (j < stli_nrbrds); j++) { | 4383 | for (j = 0; (j < stli_nrbrds); j++) { |
4385 | if ((brdp = stli_brds[j]) == NULL || (brdp->state & BST_PROBED)) | 4384 | if ((brdp = stli_brds[j]) == NULL || |
4385 | test_bit(BST_PROBED, &brdp->state)) | ||
4386 | continue; | 4386 | continue; |
4387 | 4387 | ||
4388 | stli_cleanup_ports(brdp); | 4388 | stli_cleanup_ports(brdp); |
diff --git a/include/linux/istallion.h b/include/linux/istallion.h index 7faca98c7d14..ad700a60c158 100644 --- a/include/linux/istallion.h +++ b/include/linux/istallion.h | |||
@@ -86,7 +86,7 @@ struct stlibrd { | |||
86 | unsigned long magic; | 86 | unsigned long magic; |
87 | unsigned int brdnr; | 87 | unsigned int brdnr; |
88 | unsigned int brdtype; | 88 | unsigned int brdtype; |
89 | unsigned int state; | 89 | unsigned long state; |
90 | unsigned int nrpanels; | 90 | unsigned int nrpanels; |
91 | unsigned int nrports; | 91 | unsigned int nrports; |
92 | unsigned int nrdevs; | 92 | unsigned int nrdevs; |