Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alan Cox and committed by
Greg Kroah-Hartman
8a1e803d b4eda9cb

+19 -19
+18 -18
drivers/char/istallion.c
··· 14 14 * the Free Software Foundation; either version 2 of the License, or 15 15 * (at your option) any later version. 16 16 * 17 - * FIXME: brdp->state needs proper locking. 18 17 */ 19 18 20 19 /*****************************************************************************/ ··· 203 204 * the board has been detected, and whether it is actually running a slave 204 205 * or not. 205 206 */ 206 - #define BST_FOUND 0x1 207 - #define BST_STARTED 0x2 208 - #define BST_PROBED 0x4 207 + #define BST_FOUND 0 208 + #define BST_STARTED 1 209 + #define BST_PROBED 2 209 210 210 211 /* 211 212 * Define the set of port state flags. These are marked for internal ··· 816 817 brdp = stli_brds[brdnr]; 817 818 if (brdp == NULL) 818 819 return -ENODEV; 819 - if ((brdp->state & BST_STARTED) == 0) 820 + if (!test_bit(BST_STARTED, &brdp->state)) 820 821 return -ENODEV; 821 822 portnr = MINOR2PORT(minordev); 822 823 if (portnr > brdp->nrports) ··· 1846 1847 rc = stli_portcmdstats(NULL, portp); 1847 1848 1848 1849 uart = "UNKNOWN"; 1849 - if (brdp->state & BST_STARTED) { 1850 + if (test_bit(BST_STARTED, &brdp->state)) { 1850 1851 switch (stli_comstats.hwid) { 1851 1852 case 0: uart = "2681"; break; 1852 1853 case 1: uart = "SC26198"; break; ··· 1855 1856 } 1856 1857 seq_printf(m, "%d: uart:%s ", portnr, uart); 1857 1858 1858 - if ((brdp->state & BST_STARTED) && (rc >= 0)) { 1859 + if (test_bit(BST_STARTED, &brdp->state) && rc >= 0) { 1859 1860 char sep; 1860 1861 1861 1862 seq_printf(m, "tx:%d rx:%d", (int) stli_comstats.txtotal, ··· 2355 2356 brdp = stli_brds[brdnr]; 2356 2357 if (brdp == NULL) 2357 2358 continue; 2358 - if ((brdp->state & BST_STARTED) == 0) 2359 + if (!test_bit(BST_STARTED, &brdp->state)) 2359 2360 continue; 2360 2361 2361 2362 spin_lock(&brd_lock); ··· 3140 3141 } 3141 3142 3142 3143 3143 - brdp->state |= BST_FOUND; 3144 + set_bit(BST_FOUND, &brdp->state); 3144 3145 return 0; 3145 3146 err_unmap: 3146 3147 iounmap(brdp->membase); ··· 3297 3298 brdp->panels[0] = brdp->nrports; 3298 3299 3299 3300 3300 - brdp->state |= BST_FOUND; 3301 + set_bit(BST_FOUND, &brdp->state); 3301 3302 return 0; 3302 3303 err_unmap: 3303 3304 iounmap(brdp->membase); ··· 3407 3408 spin_unlock_irqrestore(&brd_lock, flags); 3408 3409 3409 3410 if (rc == 0) 3410 - brdp->state |= BST_STARTED; 3411 + set_bit(BST_STARTED, &brdp->state); 3411 3412 3412 3413 if (! stli_timeron) { 3413 3414 stli_timeron++; ··· 3710 3711 if (retval) 3711 3712 goto err_null; 3712 3713 3713 - brdp->state |= BST_PROBED; 3714 + set_bit(BST_PROBED, &brdp->state); 3714 3715 pci_set_drvdata(pdev, brdp); 3715 3716 3716 3717 EBRDENABLE(brdp); ··· 3841 3842 brdp = stli_brds[i]; 3842 3843 if (brdp == NULL) 3843 3844 continue; 3844 - if (brdp->state & BST_FOUND) { 3845 + if (test_bit(BST_FOUND, &brdp->state)) { 3845 3846 EBRDENABLE(brdp); 3846 3847 brdp->enable = NULL; 3847 3848 brdp->disable = NULL; ··· 4078 4079 return -ENODEV; 4079 4080 4080 4081 mutex_lock(&portp->port.mutex); 4081 - if (brdp->state & BST_STARTED) { 4082 + if (test_bit(BST_STARTED, &brdp->state)) { 4082 4083 if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS, 4083 4084 &stli_cdkstats, sizeof(asystats_t), 1)) < 0) { 4084 4085 mutex_unlock(&portp->port.mutex); ··· 4193 4194 4194 4195 mutex_lock(&portp->port.mutex); 4195 4196 4196 - if (brdp->state & BST_STARTED) { 4197 + if (test_bit(BST_STARTED, &brdp->state)) { 4197 4198 if ((rc = stli_cmdwait(brdp, portp, A_CLEARSTATS, NULL, 0, 0)) < 0) { 4198 4199 mutex_unlock(&portp->port.mutex); 4199 4200 return rc; ··· 4322 4323 rc = stli_startbrd(brdp); 4323 4324 break; 4324 4325 case STL_BSTOP: 4325 - brdp->state &= ~BST_STARTED; 4326 + clear_bit(BST_STARTED, &brdp->state); 4326 4327 break; 4327 4328 case STL_BRESET: 4328 - brdp->state &= ~BST_STARTED; 4329 + clear_bit(BST_STARTED, &brdp->state); 4329 4330 EBRDRESET(brdp); 4330 4331 if (stli_shared == 0) { 4331 4332 if (brdp->reenable != NULL) ··· 4381 4382 unsigned int j; 4382 4383 4383 4384 for (j = 0; (j < stli_nrbrds); j++) { 4384 - if ((brdp = stli_brds[j]) == NULL || (brdp->state & BST_PROBED)) 4385 + if ((brdp = stli_brds[j]) == NULL || 4386 + test_bit(BST_PROBED, &brdp->state)) 4385 4387 continue; 4386 4388 4387 4389 stli_cleanup_ports(brdp);
+1 -1
include/linux/istallion.h
··· 86 86 unsigned long magic; 87 87 unsigned int brdnr; 88 88 unsigned int brdtype; 89 - unsigned int state; 89 + unsigned long state; 90 90 unsigned int nrpanels; 91 91 unsigned int nrports; 92 92 unsigned int nrdevs;