diff options
author | Alexander Beregalov <a.beregalov@gmail.com> | 2008-12-06 21:31:19 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-06 16:52:32 -0500 |
commit | 8cc59061f22370a60764b04c51f4cc5a01270760 (patch) | |
tree | 4a47eaf6a903a61374cde87361374bff76f3111e /drivers/staging | |
parent | 1fa511ad650c30e5e98f336732f003835af57cac (diff) |
Staging: me4000: switch to list_for_each*()
Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/me4000/me4000.c | 97 |
1 files changed, 39 insertions, 58 deletions
diff --git a/drivers/staging/me4000/me4000.c b/drivers/staging/me4000/me4000.c index 0ac04b7f34bb..e1c4a8078901 100644 --- a/drivers/staging/me4000/me4000.c +++ b/drivers/staging/me4000/me4000.c | |||
@@ -536,25 +536,19 @@ module_init(me4000_init_module); | |||
536 | 536 | ||
537 | static void clear_board_info_list(void) | 537 | static void clear_board_info_list(void) |
538 | { | 538 | { |
539 | struct list_head *board_p; | 539 | struct me4000_info *board_info, *board_info_safe; |
540 | struct list_head *dac_p; | 540 | struct me4000_ao_context *ao_context, *ao_context_safe; |
541 | struct me4000_info *board_info; | ||
542 | struct me4000_ao_context *ao_context; | ||
543 | 541 | ||
544 | /* Clear context lists */ | 542 | /* Clear context lists */ |
545 | for (board_p = me4000_board_info_list.next; | 543 | list_for_each_entry(board_info, &me4000_board_info_list, list) { |
546 | board_p != &me4000_board_info_list; board_p = board_p->next) { | ||
547 | board_info = list_entry(board_p, struct me4000_info, list); | ||
548 | /* Clear analog output context list */ | 544 | /* Clear analog output context list */ |
549 | while (!list_empty(&board_info->ao_context_list)) { | 545 | list_for_each_entry_safe(ao_context, ao_context_safe, |
550 | dac_p = board_info->ao_context_list.next; | 546 | &board_info->ao_context_list, list) { |
551 | ao_context = | ||
552 | list_entry(dac_p, struct me4000_ao_context, list); | ||
553 | me4000_ao_reset(ao_context); | 547 | me4000_ao_reset(ao_context); |
554 | free_irq(ao_context->irq, ao_context); | 548 | free_irq(ao_context->irq, ao_context); |
555 | if (ao_context->circ_buf.buf) | 549 | if (ao_context->circ_buf.buf) |
556 | kfree(ao_context->circ_buf.buf); | 550 | kfree(ao_context->circ_buf.buf); |
557 | list_del(dac_p); | 551 | list_del(&ao_context->list); |
558 | kfree(ao_context); | 552 | kfree(ao_context); |
559 | } | 553 | } |
560 | 554 | ||
@@ -574,11 +568,10 @@ static void clear_board_info_list(void) | |||
574 | } | 568 | } |
575 | 569 | ||
576 | /* Clear the board info list */ | 570 | /* Clear the board info list */ |
577 | while (!list_empty(&me4000_board_info_list)) { | 571 | list_for_each_entry_safe(board_info, board_info_safe, |
578 | board_p = me4000_board_info_list.next; | 572 | &me4000_board_info_list, list) { |
579 | board_info = list_entry(board_p, struct me4000_info, list); | ||
580 | pci_release_regions(board_info->pci_dev_p); | 573 | pci_release_regions(board_info->pci_dev_p); |
581 | list_del(board_p); | 574 | list_del(&board_info->list); |
582 | kfree(board_info); | 575 | kfree(board_info); |
583 | } | 576 | } |
584 | } | 577 | } |
@@ -663,16 +656,17 @@ static int init_board_info(struct pci_dev *pci_dev_p, | |||
663 | } | 656 | } |
664 | 657 | ||
665 | /* Get the index of the board in the global list */ | 658 | /* Get the index of the board in the global list */ |
666 | for (board_p = me4000_board_info_list.next, i = 0; | 659 | i = 0; |
667 | board_p != &me4000_board_info_list; board_p = board_p->next, i++) { | 660 | list_for_each(board_p, &me4000_board_info_list) { |
668 | if (board_p == &board_info->list) { | 661 | if (board_p == &board_info->list) { |
669 | board_info->board_count = i; | 662 | board_info->board_count = i; |
670 | break; | 663 | break; |
671 | } | 664 | } |
665 | i++; | ||
672 | } | 666 | } |
673 | if (board_p == &me4000_board_info_list) { | 667 | if (board_p == &me4000_board_info_list) { |
674 | printk(KERN_ERR | 668 | printk(KERN_ERR |
675 | "ME4000:init_board_info():Cannot get index of baord\n"); | 669 | "ME4000:init_board_info():Cannot get index of board\n"); |
676 | return -ENODEV; | 670 | return -ENODEV; |
677 | } | 671 | } |
678 | 672 | ||
@@ -863,16 +857,14 @@ static int alloc_ao_contexts(struct me4000_info *info) | |||
863 | 857 | ||
864 | static void release_ao_contexts(struct me4000_info *board_info) | 858 | static void release_ao_contexts(struct me4000_info *board_info) |
865 | { | 859 | { |
866 | struct list_head *dac_p; | 860 | struct me4000_ao_context *ao_context, *ao_context_safe; |
867 | struct me4000_ao_context *ao_context; | ||
868 | 861 | ||
869 | /* Clear analog output context list */ | 862 | /* Clear analog output context list */ |
870 | while (!list_empty(&board_info->ao_context_list)) { | 863 | list_for_each_entry_safe(ao_context, ao_context_safe, |
871 | dac_p = board_info->ao_context_list.next; | 864 | &board_info->ao_context_list, list) { |
872 | ao_context = list_entry(dac_p, struct me4000_ao_context, list); | ||
873 | free_irq(ao_context->irq, ao_context); | 865 | free_irq(ao_context->irq, ao_context); |
874 | kfree(ao_context->circ_buf.buf); | 866 | kfree(ao_context->circ_buf.buf); |
875 | list_del(dac_p); | 867 | list_del(&ao_context->list); |
876 | kfree(ao_context); | 868 | kfree(ao_context); |
877 | } | 869 | } |
878 | } | 870 | } |
@@ -1303,12 +1295,13 @@ static int me4000_open(struct inode *inode_p, struct file *file_p) | |||
1303 | dev, mode); | 1295 | dev, mode); |
1304 | 1296 | ||
1305 | /* Search for the board context */ | 1297 | /* Search for the board context */ |
1306 | for (ptr = me4000_board_info_list.next, i = 0; | 1298 | i = 0; |
1307 | ptr != &me4000_board_info_list; ptr = ptr->next, i++) { | 1299 | list_for_each(ptr, &me4000_board_info_list) { |
1308 | board_info = list_entry(ptr, struct me4000_info, list); | ||
1309 | if (i == board) | 1300 | if (i == board) |
1310 | break; | 1301 | break; |
1302 | i++; | ||
1311 | } | 1303 | } |
1304 | board_info = list_entry(ptr, struct me4000_info, list); | ||
1312 | 1305 | ||
1313 | if (ptr == &me4000_board_info_list) { | 1306 | if (ptr == &me4000_board_info_list) { |
1314 | printk(KERN_ERR | 1307 | printk(KERN_ERR |
@@ -1318,14 +1311,13 @@ static int me4000_open(struct inode *inode_p, struct file *file_p) | |||
1318 | } | 1311 | } |
1319 | 1312 | ||
1320 | /* Search for the dac context */ | 1313 | /* Search for the dac context */ |
1321 | for (ptr = board_info->ao_context_list.next, i = 0; | 1314 | i = 0; |
1322 | ptr != &board_info->ao_context_list; | 1315 | list_for_each(ptr, &board_info->ao_context_list) { |
1323 | ptr = ptr->next, i++) { | ||
1324 | ao_context = list_entry(ptr, struct me4000_ao_context, | ||
1325 | list); | ||
1326 | if (i == dev) | 1316 | if (i == dev) |
1327 | break; | 1317 | break; |
1318 | i++; | ||
1328 | } | 1319 | } |
1320 | ao_context = list_entry(ptr, struct me4000_ao_context, list); | ||
1329 | 1321 | ||
1330 | if (ptr == &board_info->ao_context_list) { | 1322 | if (ptr == &board_info->ao_context_list) { |
1331 | printk(KERN_ERR | 1323 | printk(KERN_ERR |
@@ -1384,12 +1376,13 @@ static int me4000_open(struct inode *inode_p, struct file *file_p) | |||
1384 | PDEBUG("me4000_open():ai board = %d mode = %d\n", board, mode); | 1376 | PDEBUG("me4000_open():ai board = %d mode = %d\n", board, mode); |
1385 | 1377 | ||
1386 | /* Search for the board context */ | 1378 | /* Search for the board context */ |
1387 | for (ptr = me4000_board_info_list.next, i = 0; | 1379 | i = 0; |
1388 | ptr != &me4000_board_info_list; ptr = ptr->next, i++) { | 1380 | list_for_each(ptr, &me4000_board_info_list) { |
1389 | board_info = list_entry(ptr, struct me4000_info, list); | ||
1390 | if (i == board) | 1381 | if (i == board) |
1391 | break; | 1382 | break; |
1383 | i++; | ||
1392 | } | 1384 | } |
1385 | board_info = list_entry(ptr, struct me4000_info, list); | ||
1393 | 1386 | ||
1394 | if (ptr == &me4000_board_info_list) { | 1387 | if (ptr == &me4000_board_info_list) { |
1395 | printk(KERN_ERR | 1388 | printk(KERN_ERR |
@@ -1438,14 +1431,12 @@ static int me4000_open(struct inode *inode_p, struct file *file_p) | |||
1438 | PDEBUG("me4000_open():board = %d\n", board); | 1431 | PDEBUG("me4000_open():board = %d\n", board); |
1439 | 1432 | ||
1440 | /* Search for the board context */ | 1433 | /* Search for the board context */ |
1441 | for (ptr = me4000_board_info_list.next; | 1434 | list_for_each_entry(board_info, &me4000_board_info_list, list) { |
1442 | ptr != &me4000_board_info_list; ptr = ptr->next) { | ||
1443 | board_info = list_entry(ptr, struct me4000_info, list); | ||
1444 | if (board_info->board_count == board) | 1435 | if (board_info->board_count == board) |
1445 | break; | 1436 | break; |
1446 | } | 1437 | } |
1447 | 1438 | ||
1448 | if (ptr == &me4000_board_info_list) { | 1439 | if (&board_info->list == &me4000_board_info_list) { |
1449 | printk(KERN_ERR | 1440 | printk(KERN_ERR |
1450 | "ME4000:me4000_open():Board %d not in device list\n", | 1441 | "ME4000:me4000_open():Board %d not in device list\n", |
1451 | board); | 1442 | board); |
@@ -1483,14 +1474,12 @@ static int me4000_open(struct inode *inode_p, struct file *file_p) | |||
1483 | PDEBUG("me4000_open():board = %d\n", board); | 1474 | PDEBUG("me4000_open():board = %d\n", board); |
1484 | 1475 | ||
1485 | /* Search for the board context */ | 1476 | /* Search for the board context */ |
1486 | for (ptr = me4000_board_info_list.next; | 1477 | list_for_each_entry(board_info, &me4000_board_info_list, list) { |
1487 | ptr != &me4000_board_info_list; ptr = ptr->next) { | ||
1488 | board_info = list_entry(ptr, struct me4000_info, list); | ||
1489 | if (board_info->board_count == board) | 1478 | if (board_info->board_count == board) |
1490 | break; | 1479 | break; |
1491 | } | 1480 | } |
1492 | 1481 | ||
1493 | if (ptr == &me4000_board_info_list) { | 1482 | if (&board_info->list == &me4000_board_info_list) { |
1494 | printk(KERN_ERR | 1483 | printk(KERN_ERR |
1495 | "ME4000:me4000_open():Board %d not in device list\n", | 1484 | "ME4000:me4000_open():Board %d not in device list\n", |
1496 | board); | 1485 | board); |
@@ -1526,14 +1515,12 @@ static int me4000_open(struct inode *inode_p, struct file *file_p) | |||
1526 | PDEBUG("me4000_open():board = %d\n", board); | 1515 | PDEBUG("me4000_open():board = %d\n", board); |
1527 | 1516 | ||
1528 | /* Search for the board context */ | 1517 | /* Search for the board context */ |
1529 | for (ptr = me4000_board_info_list.next; | 1518 | list_for_each_entry(board_info, &me4000_board_info_list, list) { |
1530 | ptr != &me4000_board_info_list; ptr = ptr->next) { | ||
1531 | board_info = list_entry(ptr, struct me4000_info, list); | ||
1532 | if (board_info->board_count == board) | 1519 | if (board_info->board_count == board) |
1533 | break; | 1520 | break; |
1534 | } | 1521 | } |
1535 | 1522 | ||
1536 | if (ptr == &me4000_board_info_list) { | 1523 | if (&board_info->list == &me4000_board_info_list) { |
1537 | printk(KERN_ERR | 1524 | printk(KERN_ERR |
1538 | "ME4000:me4000_open():Board %d not in device list\n", | 1525 | "ME4000:me4000_open():Board %d not in device list\n", |
1539 | board); | 1526 | board); |
@@ -5955,7 +5942,6 @@ static irqreturn_t me4000_ext_int_isr(int irq, void *dev_id) | |||
5955 | 5942 | ||
5956 | static void __exit me4000_module_exit(void) | 5943 | static void __exit me4000_module_exit(void) |
5957 | { | 5944 | { |
5958 | struct list_head *board_p; | ||
5959 | struct me4000_info *board_info; | 5945 | struct me4000_info *board_info; |
5960 | 5946 | ||
5961 | CALL_PDEBUG("cleanup_module() is executed\n"); | 5947 | CALL_PDEBUG("cleanup_module() is executed\n"); |
@@ -5975,9 +5961,7 @@ static void __exit me4000_module_exit(void) | |||
5975 | pci_unregister_driver(&me4000_driver); | 5961 | pci_unregister_driver(&me4000_driver); |
5976 | 5962 | ||
5977 | /* Reset the boards */ | 5963 | /* Reset the boards */ |
5978 | for (board_p = me4000_board_info_list.next; | 5964 | list_for_each_entry(board_info, &me4000_board_info_list, list) { |
5979 | board_p != &me4000_board_info_list; board_p = board_p->next) { | ||
5980 | board_info = list_entry(board_p, struct me4000_info, list); | ||
5981 | me4000_reset_board(board_info); | 5965 | me4000_reset_board(board_info); |
5982 | } | 5966 | } |
5983 | 5967 | ||
@@ -5992,7 +5976,6 @@ static int me4000_read_procmem(char *buf, char **start, off_t offset, int count, | |||
5992 | int len = 0; | 5976 | int len = 0; |
5993 | int limit = count - 1000; | 5977 | int limit = count - 1000; |
5994 | struct me4000_info *board_info; | 5978 | struct me4000_info *board_info; |
5995 | struct list_head *ptr; | ||
5996 | 5979 | ||
5997 | len += sprintf(buf + len, "\nME4000 DRIVER VERSION %X.%X.%X\n\n", | 5980 | len += sprintf(buf + len, "\nME4000 DRIVER VERSION %X.%X.%X\n\n", |
5998 | (ME4000_DRIVER_VERSION & 0xFF0000) >> 16, | 5981 | (ME4000_DRIVER_VERSION & 0xFF0000) >> 16, |
@@ -6000,11 +5983,7 @@ static int me4000_read_procmem(char *buf, char **start, off_t offset, int count, | |||
6000 | (ME4000_DRIVER_VERSION & 0xFF)); | 5983 | (ME4000_DRIVER_VERSION & 0xFF)); |
6001 | 5984 | ||
6002 | /* Search for the board context */ | 5985 | /* Search for the board context */ |
6003 | for (ptr = me4000_board_info_list.next; | 5986 | list_for_each_entry(board_info, &me4000_board_info_list, list) { |
6004 | (ptr != &me4000_board_info_list) && (len < limit); | ||
6005 | ptr = ptr->next) { | ||
6006 | board_info = list_entry(ptr, struct me4000_info, list); | ||
6007 | |||
6008 | len += | 5987 | len += |
6009 | sprintf(buf + len, "Board number %d:\n", | 5988 | sprintf(buf + len, "Board number %d:\n", |
6010 | board_info->board_count); | 5989 | board_info->board_count); |
@@ -6110,6 +6089,8 @@ static int me4000_read_procmem(char *buf, char **start, off_t offset, int count, | |||
6110 | sprintf(buf + len, "AO 3 status register = 0x%08X\n", | 6089 | sprintf(buf + len, "AO 3 status register = 0x%08X\n", |
6111 | inl(board_info->me4000_regbase + | 6090 | inl(board_info->me4000_regbase + |
6112 | ME4000_AO_03_STATUS_REG)); | 6091 | ME4000_AO_03_STATUS_REG)); |
6092 | if (len >= limit) | ||
6093 | break; | ||
6113 | } | 6094 | } |
6114 | 6095 | ||
6115 | *eof = 1; | 6096 | *eof = 1; |