hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/firewire/ohci.c
....@@ -1,21 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for OHCI 1394 controllers
34 *
45 * 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.
196 */
207
218 #include <linux/bitops.h>
....@@ -124,7 +111,7 @@
124111 dma_addr_t buffer_bus;
125112 size_t buffer_size;
126113 size_t used;
127
- struct descriptor buffer[0];
114
+ struct descriptor buffer[];
128115 };
129116
130117 struct context {
....@@ -687,17 +674,16 @@
687674
688675 static void ar_context_release(struct ar_context *ctx)
689676 {
677
+ struct device *dev = ctx->ohci->card.device;
690678 unsigned int i;
691679
692680 vunmap(ctx->buffer);
693681
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
+ }
701687 }
702688
703689 static void ar_context_abort(struct ar_context *ctx, const char *error_msg)
....@@ -983,6 +969,7 @@
983969 static int ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci,
984970 unsigned int descriptors_offset, u32 regs)
985971 {
972
+ struct device *dev = ohci->card.device;
986973 unsigned int i;
987974 dma_addr_t dma_addr;
988975 struct page *pages[AR_BUFFERS + AR_WRAPAROUND_PAGES];
....@@ -993,17 +980,13 @@
993980 tasklet_init(&ctx->tasklet, ar_context_tasklet, (unsigned long)ctx);
994981
995982 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);
997985 if (!ctx->pages[i])
998986 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
- }
1006987 set_page_private(ctx->pages[i], dma_addr);
988
+ dma_sync_single_for_device(dev, dma_addr, PAGE_SIZE,
989
+ DMA_FROM_DEVICE);
1007990 }
1008991
1009992 for (i = 0; i < AR_BUFFERS; i++)
....@@ -1112,7 +1095,7 @@
11121095 static int context_add_buffer(struct context *ctx)
11131096 {
11141097 struct descriptor_buffer *desc;
1115
- dma_addr_t uninitialized_var(bus_addr);
1098
+ dma_addr_t bus_addr;
11161099 int offset;
11171100
11181101 /*
....@@ -1302,7 +1285,7 @@
13021285 struct fw_packet *packet)
13031286 {
13041287 struct fw_ohci *ohci = ctx->ohci;
1305
- dma_addr_t d_bus, uninitialized_var(payload_bus);
1288
+ dma_addr_t d_bus, payload_bus;
13061289 struct driver_data *driver_data;
13071290 struct descriptor *d, *last;
13081291 __le32 *header;
....@@ -1508,7 +1491,7 @@
15081491 packet->ack = RCODE_GENERATION;
15091492 break;
15101493 }
1511
- /* fall through */
1494
+ fallthrough;
15121495
15131496 default:
15141497 packet->ack = RCODE_SEND_ERROR;
....@@ -1765,7 +1748,7 @@
17651748
17661749 if (unlikely(!ohci->bus_time_running)) {
17671750 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) |
17691752 (cycle_time_seconds & 0x40);
17701753 ohci->bus_time_running = true;
17711754 }
....@@ -2458,7 +2441,7 @@
24582441 {
24592442 struct fw_ohci *ohci;
24602443 __be32 *next_config_rom;
2461
- dma_addr_t uninitialized_var(next_config_rom_bus);
2444
+ dma_addr_t next_config_rom_bus;
24622445
24632446 ohci = fw_ohci(card);
24642447
....@@ -2939,7 +2922,6 @@
29392922 reg_write(ohci, OHCI1394_IRMultiChanMaskLoClear, ~lo);
29402923 reg_write(ohci, OHCI1394_IRMultiChanMaskHiSet, hi);
29412924 reg_write(ohci, OHCI1394_IRMultiChanMaskLoSet, lo);
2942
- mmiowb();
29432925 ohci->mc_channels = channels;
29442926 }
29452927
....@@ -2947,10 +2929,10 @@
29472929 int type, int channel, size_t header_size)
29482930 {
29492931 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;
29542936 int index, ret = -EBUSY;
29552937
29562938 spin_lock_irq(&ohci->lock);
....@@ -3068,7 +3050,7 @@
30683050
30693051 case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
30703052 control |= IR_CONTEXT_BUFFER_FILL|IR_CONTEXT_MULTI_CHANNEL_MODE;
3071
- /* fall through */
3053
+ fallthrough;
30723054 case FW_ISO_CONTEXT_RECEIVE:
30733055 index = ctx - ohci->ir_context_list;
30743056 match = (tags << 28) | (sync << 8) | ctx->base.channel;