.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Driver for OHCI 1394 controllers |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2003-2006 Kristian Hoegsberg <krh@bitplanet.net> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
9 | | - * (at your option) any later version. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope that it will be useful, |
---|
12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | | - * GNU General Public License for more details. |
---|
15 | | - * |
---|
16 | | - * You should have received a copy of the GNU General Public License |
---|
17 | | - * along with this program; if not, write to the Free Software Foundation, |
---|
18 | | - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | 6 | */ |
---|
20 | 7 | |
---|
21 | 8 | #include <linux/bitops.h> |
---|
.. | .. |
---|
124 | 111 | dma_addr_t buffer_bus; |
---|
125 | 112 | size_t buffer_size; |
---|
126 | 113 | size_t used; |
---|
127 | | - struct descriptor buffer[0]; |
---|
| 114 | + struct descriptor buffer[]; |
---|
128 | 115 | }; |
---|
129 | 116 | |
---|
130 | 117 | struct context { |
---|
.. | .. |
---|
687 | 674 | |
---|
688 | 675 | static void ar_context_release(struct ar_context *ctx) |
---|
689 | 676 | { |
---|
| 677 | + struct device *dev = ctx->ohci->card.device; |
---|
690 | 678 | unsigned int i; |
---|
691 | 679 | |
---|
692 | 680 | vunmap(ctx->buffer); |
---|
693 | 681 | |
---|
694 | | - for (i = 0; i < AR_BUFFERS; i++) |
---|
695 | | - if (ctx->pages[i]) { |
---|
696 | | - dma_unmap_page(ctx->ohci->card.device, |
---|
697 | | - ar_buffer_bus(ctx, i), |
---|
698 | | - PAGE_SIZE, DMA_FROM_DEVICE); |
---|
699 | | - __free_page(ctx->pages[i]); |
---|
700 | | - } |
---|
| 682 | + for (i = 0; i < AR_BUFFERS; i++) { |
---|
| 683 | + if (ctx->pages[i]) |
---|
| 684 | + dma_free_pages(dev, PAGE_SIZE, ctx->pages[i], |
---|
| 685 | + ar_buffer_bus(ctx, i), DMA_FROM_DEVICE); |
---|
| 686 | + } |
---|
701 | 687 | } |
---|
702 | 688 | |
---|
703 | 689 | static void ar_context_abort(struct ar_context *ctx, const char *error_msg) |
---|
.. | .. |
---|
983 | 969 | static int ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci, |
---|
984 | 970 | unsigned int descriptors_offset, u32 regs) |
---|
985 | 971 | { |
---|
| 972 | + struct device *dev = ohci->card.device; |
---|
986 | 973 | unsigned int i; |
---|
987 | 974 | dma_addr_t dma_addr; |
---|
988 | 975 | struct page *pages[AR_BUFFERS + AR_WRAPAROUND_PAGES]; |
---|
.. | .. |
---|
993 | 980 | tasklet_init(&ctx->tasklet, ar_context_tasklet, (unsigned long)ctx); |
---|
994 | 981 | |
---|
995 | 982 | for (i = 0; i < AR_BUFFERS; i++) { |
---|
996 | | - ctx->pages[i] = alloc_page(GFP_KERNEL | GFP_DMA32); |
---|
| 983 | + ctx->pages[i] = dma_alloc_pages(dev, PAGE_SIZE, &dma_addr, |
---|
| 984 | + DMA_FROM_DEVICE, GFP_KERNEL); |
---|
997 | 985 | if (!ctx->pages[i]) |
---|
998 | 986 | goto out_of_memory; |
---|
999 | | - dma_addr = dma_map_page(ohci->card.device, ctx->pages[i], |
---|
1000 | | - 0, PAGE_SIZE, DMA_FROM_DEVICE); |
---|
1001 | | - if (dma_mapping_error(ohci->card.device, dma_addr)) { |
---|
1002 | | - __free_page(ctx->pages[i]); |
---|
1003 | | - ctx->pages[i] = NULL; |
---|
1004 | | - goto out_of_memory; |
---|
1005 | | - } |
---|
1006 | 987 | set_page_private(ctx->pages[i], dma_addr); |
---|
| 988 | + dma_sync_single_for_device(dev, dma_addr, PAGE_SIZE, |
---|
| 989 | + DMA_FROM_DEVICE); |
---|
1007 | 990 | } |
---|
1008 | 991 | |
---|
1009 | 992 | for (i = 0; i < AR_BUFFERS; i++) |
---|
.. | .. |
---|
1112 | 1095 | static int context_add_buffer(struct context *ctx) |
---|
1113 | 1096 | { |
---|
1114 | 1097 | struct descriptor_buffer *desc; |
---|
1115 | | - dma_addr_t uninitialized_var(bus_addr); |
---|
| 1098 | + dma_addr_t bus_addr; |
---|
1116 | 1099 | int offset; |
---|
1117 | 1100 | |
---|
1118 | 1101 | /* |
---|
.. | .. |
---|
1302 | 1285 | struct fw_packet *packet) |
---|
1303 | 1286 | { |
---|
1304 | 1287 | struct fw_ohci *ohci = ctx->ohci; |
---|
1305 | | - dma_addr_t d_bus, uninitialized_var(payload_bus); |
---|
| 1288 | + dma_addr_t d_bus, payload_bus; |
---|
1306 | 1289 | struct driver_data *driver_data; |
---|
1307 | 1290 | struct descriptor *d, *last; |
---|
1308 | 1291 | __le32 *header; |
---|
.. | .. |
---|
1508 | 1491 | packet->ack = RCODE_GENERATION; |
---|
1509 | 1492 | break; |
---|
1510 | 1493 | } |
---|
1511 | | - /* fall through */ |
---|
| 1494 | + fallthrough; |
---|
1512 | 1495 | |
---|
1513 | 1496 | default: |
---|
1514 | 1497 | packet->ack = RCODE_SEND_ERROR; |
---|
.. | .. |
---|
1765 | 1748 | |
---|
1766 | 1749 | if (unlikely(!ohci->bus_time_running)) { |
---|
1767 | 1750 | reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_cycle64Seconds); |
---|
1768 | | - ohci->bus_time = (lower_32_bits(get_seconds()) & ~0x7f) | |
---|
| 1751 | + ohci->bus_time = (lower_32_bits(ktime_get_seconds()) & ~0x7f) | |
---|
1769 | 1752 | (cycle_time_seconds & 0x40); |
---|
1770 | 1753 | ohci->bus_time_running = true; |
---|
1771 | 1754 | } |
---|
.. | .. |
---|
2458 | 2441 | { |
---|
2459 | 2442 | struct fw_ohci *ohci; |
---|
2460 | 2443 | __be32 *next_config_rom; |
---|
2461 | | - dma_addr_t uninitialized_var(next_config_rom_bus); |
---|
| 2444 | + dma_addr_t next_config_rom_bus; |
---|
2462 | 2445 | |
---|
2463 | 2446 | ohci = fw_ohci(card); |
---|
2464 | 2447 | |
---|
.. | .. |
---|
2939 | 2922 | reg_write(ohci, OHCI1394_IRMultiChanMaskLoClear, ~lo); |
---|
2940 | 2923 | reg_write(ohci, OHCI1394_IRMultiChanMaskHiSet, hi); |
---|
2941 | 2924 | reg_write(ohci, OHCI1394_IRMultiChanMaskLoSet, lo); |
---|
2942 | | - mmiowb(); |
---|
2943 | 2925 | ohci->mc_channels = channels; |
---|
2944 | 2926 | } |
---|
2945 | 2927 | |
---|
.. | .. |
---|
2947 | 2929 | int type, int channel, size_t header_size) |
---|
2948 | 2930 | { |
---|
2949 | 2931 | struct fw_ohci *ohci = fw_ohci(card); |
---|
2950 | | - struct iso_context *uninitialized_var(ctx); |
---|
2951 | | - descriptor_callback_t uninitialized_var(callback); |
---|
2952 | | - u64 *uninitialized_var(channels); |
---|
2953 | | - u32 *uninitialized_var(mask), uninitialized_var(regs); |
---|
| 2932 | + struct iso_context *ctx; |
---|
| 2933 | + descriptor_callback_t callback; |
---|
| 2934 | + u64 *channels; |
---|
| 2935 | + u32 *mask, regs; |
---|
2954 | 2936 | int index, ret = -EBUSY; |
---|
2955 | 2937 | |
---|
2956 | 2938 | spin_lock_irq(&ohci->lock); |
---|
.. | .. |
---|
3068 | 3050 | |
---|
3069 | 3051 | case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL: |
---|
3070 | 3052 | control |= IR_CONTEXT_BUFFER_FILL|IR_CONTEXT_MULTI_CHANNEL_MODE; |
---|
3071 | | - /* fall through */ |
---|
| 3053 | + fallthrough; |
---|
3072 | 3054 | case FW_ISO_CONTEXT_RECEIVE: |
---|
3073 | 3055 | index = ctx - ohci->ir_context_list; |
---|
3074 | 3056 | match = (tags << 28) | (sync << 8) | ctx->base.channel; |
---|