Skip to content

Commit

Permalink
swiotlb: clean up swiotlb_tbl_unmap_single
Browse files Browse the repository at this point in the history
Remove a layer of pointless indentation, replace a hard to follow
ternary expression with a plain if/else.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jianxiong Gao <jxgao@google.com>
Tested-by: Jianxiong Gao <jxgao@google.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Christoph Hellwig authored and Konrad Rzeszutek Wilk committed Feb 20, 2021
1 parent c32a77f commit ca10d0f
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions kernel/dma/swiotlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,28 +626,29 @@ void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr,
* with slots below and above the pool being returned.
*/
spin_lock_irqsave(&io_tlb_lock, flags);
{
count = ((index + nslots) < ALIGN(index + 1, IO_TLB_SEGSIZE) ?
io_tlb_list[index + nslots] : 0);
/*
* Step 1: return the slots to the free list, merging the
* slots with superceeding slots
*/
for (i = index + nslots - 1; i >= index; i--) {
io_tlb_list[i] = ++count;
io_tlb_orig_addr[i] = INVALID_PHYS_ADDR;
}
/*
* Step 2: merge the returned slots with the preceding slots,
* if available (non zero)
*/
for (i = index - 1;
io_tlb_offset(i) != IO_TLB_SEGSIZE - 1 &&
io_tlb_list[i]; i--)
io_tlb_list[i] = ++count;
if (index + nslots < ALIGN(index + 1, IO_TLB_SEGSIZE))
count = io_tlb_list[index + nslots];
else
count = 0;

io_tlb_used -= nslots;
/*
* Step 1: return the slots to the free list, merging the slots with
* superceeding slots
*/
for (i = index + nslots - 1; i >= index; i--) {
io_tlb_list[i] = ++count;
io_tlb_orig_addr[i] = INVALID_PHYS_ADDR;
}

/*
* Step 2: merge the returned slots with the preceding slots, if
* available (non zero)
*/
for (i = index - 1;
io_tlb_offset(i) != IO_TLB_SEGSIZE - 1 && io_tlb_list[i];
i--)
io_tlb_list[i] = ++count;
io_tlb_used -= nslots;
spin_unlock_irqrestore(&io_tlb_lock, flags);
}

Expand Down

0 comments on commit ca10d0f

Please sign in to comment.