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

dmaengine: at_hdmac: add wrappers for testing channel state

Cyclic property and paused state are encoded as bits in the channel status
bitfield. Tests of those bits are wrapped in convenient helper functions.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>

authored by

Nicolas Ferre and committed by
Vinod Koul
3c477482 c0ba5947

+26 -10
+9 -10
drivers/dma/at_hdmac.c
··· 301 301 302 302 /* for cyclic transfers, 303 303 * no need to replay callback function while stopping */ 304 - if (!test_bit(ATC_IS_CYCLIC, &atchan->status)) { 304 + if (!atc_chan_is_cyclic(atchan)) { 305 305 dma_async_tx_callback callback = txd->callback; 306 306 void *param = txd->callback_param; 307 307 ··· 478 478 spin_lock_irqsave(&atchan->lock, flags); 479 479 if (test_and_clear_bit(ATC_IS_ERROR, &atchan->status)) 480 480 atc_handle_error(atchan); 481 - else if (test_bit(ATC_IS_CYCLIC, &atchan->status)) 481 + else if (atc_chan_is_cyclic(atchan)) 482 482 atc_handle_cyclic(atchan); 483 483 else 484 484 atc_advance_work(atchan); ··· 945 945 946 946 spin_unlock_irqrestore(&atchan->lock, flags); 947 947 } else if (cmd == DMA_RESUME) { 948 - if (!test_bit(ATC_IS_PAUSED, &atchan->status)) 948 + if (!atc_chan_is_paused(atchan)) 949 949 return 0; 950 950 951 951 spin_lock_irqsave(&atchan->lock, flags); ··· 1035 1035 else 1036 1036 dma_set_tx_state(txstate, last_complete, last_used, 0); 1037 1037 1038 - if (test_bit(ATC_IS_PAUSED, &atchan->status)) 1038 + if (atc_chan_is_paused(atchan)) 1039 1039 ret = DMA_PAUSED; 1040 1040 1041 1041 dev_vdbg(chan2dev(chan), "tx_status %d: cookie = %d (d%d, u%d)\n", ··· 1057 1057 dev_vdbg(chan2dev(chan), "issue_pending\n"); 1058 1058 1059 1059 /* Not needed for cyclic transfers */ 1060 - if (test_bit(ATC_IS_CYCLIC, &atchan->status)) 1060 + if (atc_chan_is_cyclic(atchan)) 1061 1061 return; 1062 1062 1063 1063 spin_lock_irqsave(&atchan->lock, flags); ··· 1395 1395 device_node) { 1396 1396 struct at_dma_chan *atchan = to_at_dma_chan(chan); 1397 1397 /* wait for transaction completion (except in cyclic case) */ 1398 - if (atc_chan_is_enabled(atchan) && 1399 - !test_bit(ATC_IS_CYCLIC, &atchan->status)) 1398 + if (atc_chan_is_enabled(atchan) && !atc_chan_is_cyclic(atchan)) 1400 1399 return -EAGAIN; 1401 1400 } 1402 1401 return 0; ··· 1407 1408 1408 1409 /* Channel should be paused by user 1409 1410 * do it anyway even if it is not done already */ 1410 - if (!test_bit(ATC_IS_PAUSED, &atchan->status)) { 1411 + if (!atc_chan_is_paused(atchan)) { 1411 1412 dev_warn(chan2dev(chan), 1412 1413 "cyclic channel not paused, should be done by channel user\n"); 1413 1414 atc_control(chan, DMA_PAUSE, 0); ··· 1431 1432 device_node) { 1432 1433 struct at_dma_chan *atchan = to_at_dma_chan(chan); 1433 1434 1434 - if (test_bit(ATC_IS_CYCLIC, &atchan->status)) 1435 + if (atc_chan_is_cyclic(atchan)) 1435 1436 atc_suspend_cyclic(atchan); 1436 1437 atchan->save_cfg = channel_readl(atchan, CFG); 1437 1438 } ··· 1483 1484 struct at_dma_chan *atchan = to_at_dma_chan(chan); 1484 1485 1485 1486 channel_writel(atchan, CFG, atchan->save_cfg); 1486 - if (test_bit(ATC_IS_CYCLIC, &atchan->status)) 1487 + if (atc_chan_is_cyclic(atchan)) 1487 1488 atc_resume_cyclic(atchan); 1488 1489 } 1489 1490 return 0;
+17
drivers/dma/at_hdmac_regs.h
··· 362 362 return !!(dma_readl(atdma, CHSR) & atchan->mask); 363 363 } 364 364 365 + /** 366 + * atc_chan_is_paused - test channel pause/resume status 367 + * @atchan: channel we want to test status 368 + */ 369 + static inline int atc_chan_is_paused(struct at_dma_chan *atchan) 370 + { 371 + return test_bit(ATC_IS_PAUSED, &atchan->status); 372 + } 373 + 374 + /** 375 + * atc_chan_is_cyclic - test if given channel has cyclic property set 376 + * @atchan: channel we want to test status 377 + */ 378 + static inline int atc_chan_is_cyclic(struct at_dma_chan *atchan) 379 + { 380 + return test_bit(ATC_IS_CYCLIC, &atchan->status); 381 + } 365 382 366 383 /** 367 384 * set_desc_eol - set end-of-link to descriptor so it will end transfer