| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License version 2 and |
|---|
| 6 | | - * only version 2 as published by the Free Software Foundation. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | | - * GNU General Public License for more details. |
|---|
| 12 | 4 | */ |
|---|
| 13 | 5 | |
|---|
| 14 | 6 | #include <linux/dmaengine.h> |
|---|
| .. | .. |
|---|
| 20 | 12 | { |
|---|
| 21 | 13 | int ret; |
|---|
| 22 | 14 | |
|---|
| 23 | | - dma->txchan = dma_request_slave_channel_reason(dev, "tx"); |
|---|
| 15 | + dma->txchan = dma_request_chan(dev, "tx"); |
|---|
| 24 | 16 | if (IS_ERR(dma->txchan)) |
|---|
| 25 | 17 | return PTR_ERR(dma->txchan); |
|---|
| 26 | 18 | |
|---|
| 27 | | - dma->rxchan = dma_request_slave_channel_reason(dev, "rx"); |
|---|
| 19 | + dma->rxchan = dma_request_chan(dev, "rx"); |
|---|
| 28 | 20 | if (IS_ERR(dma->rxchan)) { |
|---|
| 29 | 21 | ret = PTR_ERR(dma->rxchan); |
|---|
| 30 | 22 | goto error_rx; |
|---|
| .. | .. |
|---|
| 55 | 47 | } |
|---|
| 56 | 48 | |
|---|
| 57 | 49 | struct scatterlist * |
|---|
| 58 | | -qce_sgtable_add(struct sg_table *sgt, struct scatterlist *new_sgl) |
|---|
| 50 | +qce_sgtable_add(struct sg_table *sgt, struct scatterlist *new_sgl, |
|---|
| 51 | + unsigned int max_len) |
|---|
| 59 | 52 | { |
|---|
| 60 | 53 | struct scatterlist *sg = sgt->sgl, *sg_last = NULL; |
|---|
| 54 | + unsigned int new_len; |
|---|
| 61 | 55 | |
|---|
| 62 | 56 | while (sg) { |
|---|
| 63 | 57 | if (!sg_page(sg)) |
|---|
| .. | .. |
|---|
| 68 | 62 | if (!sg) |
|---|
| 69 | 63 | return ERR_PTR(-EINVAL); |
|---|
| 70 | 64 | |
|---|
| 71 | | - while (new_sgl && sg) { |
|---|
| 72 | | - sg_set_page(sg, sg_page(new_sgl), new_sgl->length, |
|---|
| 73 | | - new_sgl->offset); |
|---|
| 65 | + while (new_sgl && sg && max_len) { |
|---|
| 66 | + new_len = new_sgl->length > max_len ? max_len : new_sgl->length; |
|---|
| 67 | + sg_set_page(sg, sg_page(new_sgl), new_len, new_sgl->offset); |
|---|
| 74 | 68 | sg_last = sg; |
|---|
| 75 | 69 | sg = sg_next(sg); |
|---|
| 76 | 70 | new_sgl = sg_next(new_sgl); |
|---|
| 71 | + max_len -= new_len; |
|---|
| 77 | 72 | } |
|---|
| 78 | 73 | |
|---|
| 79 | 74 | return sg_last; |
|---|