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

dma-debug: introduce dma_debug_disabled

Add a helper function which returns whether the DMA debugging API is
disabled, right now we only check for global_disable, but in order to
accommodate early callers of the DMA-API, we will check for more
initialization flags in the next patch.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Horia Geanta <horia.geanta@freescale.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Florian Fainelli and committed by
Linus Torvalds
01ce18b3 662e9b2b

+21 -16
+21 -16
lib/dma-debug.c
··· 102 102 /* Global disable flag - will be set in case of an error */ 103 103 static u32 global_disable __read_mostly; 104 104 105 + static inline bool dma_debug_disabled(void) 106 + { 107 + return global_disable; 108 + } 109 + 105 110 /* Global error count */ 106 111 static u32 error_count; 107 112 ··· 950 945 struct dma_debug_entry *uninitialized_var(entry); 951 946 int count; 952 947 953 - if (global_disable) 948 + if (dma_debug_disabled()) 954 949 return 0; 955 950 956 951 switch (action) { ··· 978 973 { 979 974 struct notifier_block *nb; 980 975 981 - if (global_disable) 976 + if (dma_debug_disabled()) 982 977 return; 983 978 984 979 nb = kzalloc(sizeof(struct notifier_block), GFP_KERNEL); ··· 999 994 { 1000 995 int i; 1001 996 1002 - if (global_disable) 997 + if (dma_debug_disabled()) 1003 998 return; 1004 999 1005 1000 for (i = 0; i < HASH_SIZE; ++i) { ··· 1248 1243 { 1249 1244 struct dma_debug_entry *entry; 1250 1245 1251 - if (unlikely(global_disable)) 1246 + if (unlikely(dma_debug_disabled())) 1252 1247 return; 1253 1248 1254 1249 if (dma_mapping_error(dev, dma_addr)) ··· 1288 1283 struct hash_bucket *bucket; 1289 1284 unsigned long flags; 1290 1285 1291 - if (unlikely(global_disable)) 1286 + if (unlikely(dma_debug_disabled())) 1292 1287 return; 1293 1288 1294 1289 ref.dev = dev; ··· 1330 1325 .direction = direction, 1331 1326 }; 1332 1327 1333 - if (unlikely(global_disable)) 1328 + if (unlikely(dma_debug_disabled())) 1334 1329 return; 1335 1330 1336 1331 if (map_single) ··· 1347 1342 struct scatterlist *s; 1348 1343 int i; 1349 1344 1350 - if (unlikely(global_disable)) 1345 + if (unlikely(dma_debug_disabled())) 1351 1346 return; 1352 1347 1353 1348 for_each_sg(sg, s, mapped_ents, i) { ··· 1400 1395 struct scatterlist *s; 1401 1396 int mapped_ents = 0, i; 1402 1397 1403 - if (unlikely(global_disable)) 1398 + if (unlikely(dma_debug_disabled())) 1404 1399 return; 1405 1400 1406 1401 for_each_sg(sglist, s, nelems, i) { ··· 1432 1427 { 1433 1428 struct dma_debug_entry *entry; 1434 1429 1435 - if (unlikely(global_disable)) 1430 + if (unlikely(dma_debug_disabled())) 1436 1431 return; 1437 1432 1438 1433 if (unlikely(virt == NULL)) ··· 1467 1462 .direction = DMA_BIDIRECTIONAL, 1468 1463 }; 1469 1464 1470 - if (unlikely(global_disable)) 1465 + if (unlikely(dma_debug_disabled())) 1471 1466 return; 1472 1467 1473 1468 check_unmap(&ref); ··· 1479 1474 { 1480 1475 struct dma_debug_entry ref; 1481 1476 1482 - if (unlikely(global_disable)) 1477 + if (unlikely(dma_debug_disabled())) 1483 1478 return; 1484 1479 1485 1480 ref.type = dma_debug_single; ··· 1499 1494 { 1500 1495 struct dma_debug_entry ref; 1501 1496 1502 - if (unlikely(global_disable)) 1497 + if (unlikely(dma_debug_disabled())) 1503 1498 return; 1504 1499 1505 1500 ref.type = dma_debug_single; ··· 1520 1515 { 1521 1516 struct dma_debug_entry ref; 1522 1517 1523 - if (unlikely(global_disable)) 1518 + if (unlikely(dma_debug_disabled())) 1524 1519 return; 1525 1520 1526 1521 ref.type = dma_debug_single; ··· 1541 1536 { 1542 1537 struct dma_debug_entry ref; 1543 1538 1544 - if (unlikely(global_disable)) 1539 + if (unlikely(dma_debug_disabled())) 1545 1540 return; 1546 1541 1547 1542 ref.type = dma_debug_single; ··· 1561 1556 struct scatterlist *s; 1562 1557 int mapped_ents = 0, i; 1563 1558 1564 - if (unlikely(global_disable)) 1559 + if (unlikely(dma_debug_disabled())) 1565 1560 return; 1566 1561 1567 1562 for_each_sg(sg, s, nelems, i) { ··· 1594 1589 struct scatterlist *s; 1595 1590 int mapped_ents = 0, i; 1596 1591 1597 - if (unlikely(global_disable)) 1592 + if (unlikely(dma_debug_disabled())) 1598 1593 return; 1599 1594 1600 1595 for_each_sg(sg, s, nelems, i) {