| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2013-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 | | - * |
|---|
| 13 | 4 | */ |
|---|
| 14 | 5 | /* |
|---|
| 15 | 6 | * QCOM BAM DMA engine driver |
|---|
| .. | .. |
|---|
| 83 | 74 | struct list_head desc_node; |
|---|
| 84 | 75 | enum dma_transfer_direction dir; |
|---|
| 85 | 76 | size_t length; |
|---|
| 86 | | - struct bam_desc_hw desc[0]; |
|---|
| 77 | + struct bam_desc_hw desc[]; |
|---|
| 87 | 78 | }; |
|---|
| 88 | 79 | |
|---|
| 89 | 80 | enum bam_reg { |
|---|
| .. | .. |
|---|
| 390 | 381 | void __iomem *regs; |
|---|
| 391 | 382 | struct device *dev; |
|---|
| 392 | 383 | struct dma_device common; |
|---|
| 393 | | - struct device_dma_parameters dma_parms; |
|---|
| 394 | 384 | struct bam_chan *channels; |
|---|
| 395 | 385 | u32 num_channels; |
|---|
| 396 | 386 | u32 num_ees; |
|---|
| .. | .. |
|---|
| 636 | 626 | num_alloc += DIV_ROUND_UP(sg_dma_len(sg), BAM_FIFO_SIZE); |
|---|
| 637 | 627 | |
|---|
| 638 | 628 | /* allocate enough room to accomodate the number of entries */ |
|---|
| 639 | | - async_desc = kzalloc(sizeof(*async_desc) + |
|---|
| 640 | | - (num_alloc * sizeof(struct bam_desc_hw)), GFP_NOWAIT); |
|---|
| 629 | + async_desc = kzalloc(struct_size(async_desc, desc, num_alloc), |
|---|
| 630 | + GFP_NOWAIT); |
|---|
| 641 | 631 | |
|---|
| 642 | 632 | if (!async_desc) |
|---|
| 643 | 633 | goto err_out; |
|---|
| .. | .. |
|---|
| 1080 | 1070 | |
|---|
| 1081 | 1071 | /** |
|---|
| 1082 | 1072 | * dma_tasklet - DMA IRQ tasklet |
|---|
| 1083 | | - * @data: tasklet argument (bam controller structure) |
|---|
| 1073 | + * @t: tasklet argument (bam controller structure) |
|---|
| 1084 | 1074 | * |
|---|
| 1085 | 1075 | * Sets up next DMA operation and then processes all completed transactions |
|---|
| 1086 | 1076 | */ |
|---|
| 1087 | | -static void dma_tasklet(unsigned long data) |
|---|
| 1077 | +static void dma_tasklet(struct tasklet_struct *t) |
|---|
| 1088 | 1078 | { |
|---|
| 1089 | | - struct bam_device *bdev = (struct bam_device *)data; |
|---|
| 1079 | + struct bam_device *bdev = from_tasklet(bdev, t, task); |
|---|
| 1090 | 1080 | struct bam_chan *bchan; |
|---|
| 1091 | 1081 | unsigned long flags; |
|---|
| 1092 | 1082 | unsigned int i; |
|---|
| .. | .. |
|---|
| 1302 | 1292 | if (ret) |
|---|
| 1303 | 1293 | goto err_disable_clk; |
|---|
| 1304 | 1294 | |
|---|
| 1305 | | - tasklet_init(&bdev->task, dma_tasklet, (unsigned long)bdev); |
|---|
| 1295 | + tasklet_setup(&bdev->task, dma_tasklet); |
|---|
| 1306 | 1296 | |
|---|
| 1307 | 1297 | bdev->channels = devm_kcalloc(bdev->dev, bdev->num_channels, |
|---|
| 1308 | 1298 | sizeof(*bdev->channels), GFP_KERNEL); |
|---|
| .. | .. |
|---|
| 1325 | 1315 | |
|---|
| 1326 | 1316 | /* set max dma segment size */ |
|---|
| 1327 | 1317 | bdev->common.dev = bdev->dev; |
|---|
| 1328 | | - bdev->common.dev->dma_parms = &bdev->dma_parms; |
|---|
| 1329 | 1318 | ret = dma_set_max_seg_size(bdev->common.dev, BAM_FIFO_SIZE); |
|---|
| 1330 | 1319 | if (ret) { |
|---|
| 1331 | 1320 | dev_err(bdev->dev, "cannot set maximum segment size\n"); |
|---|