hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/firewire/core-transaction.c
....@@ -1,21 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Core IEEE1394 transaction logic
34 *
45 * Copyright (C) 2004-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/bug.h>
....@@ -86,24 +73,25 @@
8673 static int close_transaction(struct fw_transaction *transaction,
8774 struct fw_card *card, int rcode)
8875 {
89
- struct fw_transaction *t;
76
+ struct fw_transaction *t = NULL, *iter;
9077 unsigned long flags;
9178
9279 spin_lock_irqsave(&card->lock, flags);
93
- list_for_each_entry(t, &card->transaction_list, link) {
94
- if (t == transaction) {
95
- if (!try_cancel_split_timeout(t)) {
80
+ list_for_each_entry(iter, &card->transaction_list, link) {
81
+ if (iter == transaction) {
82
+ if (!try_cancel_split_timeout(iter)) {
9683 spin_unlock_irqrestore(&card->lock, flags);
9784 goto timed_out;
9885 }
99
- list_del_init(&t->link);
100
- card->tlabel_mask &= ~(1ULL << t->tlabel);
86
+ list_del_init(&iter->link);
87
+ card->tlabel_mask &= ~(1ULL << iter->tlabel);
88
+ t = iter;
10189 break;
10290 }
10391 }
10492 spin_unlock_irqrestore(&card->lock, flags);
10593
106
- if (&t->link != &card->transaction_list) {
94
+ if (t) {
10795 t->callback(card, rcode, NULL, 0, t->callback_data);
10896 return 0;
10997 }
....@@ -410,6 +398,14 @@
410398
411399 /**
412400 * fw_run_transaction() - send request and sleep until transaction is completed
401
+ * @card: card interface for this request
402
+ * @tcode: transaction code
403
+ * @destination_id: destination node ID, consisting of bus_ID and phy_ID
404
+ * @generation: bus generation in which request and response are valid
405
+ * @speed: transmission speed
406
+ * @offset: 48bit wide offset into destination's address space
407
+ * @payload: data payload for the request subaction
408
+ * @length: length of the payload, in bytes
413409 *
414410 * Returns the RCODE. See fw_send_request() for parameter documentation.
415411 * Unlike fw_send_request(), @data points to the payload of the request or/and
....@@ -604,6 +600,7 @@
604600
605601 /**
606602 * fw_core_remove_address_handler() - unregister an address handler
603
+ * @handler: callback
607604 *
608605 * To be called in process context.
609606 *
....@@ -624,7 +621,7 @@
624621 u32 request_header[4];
625622 int ack;
626623 u32 length;
627
- u32 data[0];
624
+ u32 data[];
628625 };
629626
630627 static void free_response_callback(struct fw_packet *packet,
....@@ -828,6 +825,7 @@
828825
829826 /**
830827 * fw_get_request_speed() - returns speed at which the @request was received
828
+ * @request: firewire request data
831829 */
832830 int fw_get_request_speed(struct fw_request *request)
833831 {
....@@ -938,7 +936,7 @@
938936
939937 void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
940938 {
941
- struct fw_transaction *t;
939
+ struct fw_transaction *t = NULL, *iter;
942940 unsigned long flags;
943941 u32 *data;
944942 size_t data_length;
....@@ -950,20 +948,21 @@
950948 rcode = HEADER_GET_RCODE(p->header[1]);
951949
952950 spin_lock_irqsave(&card->lock, flags);
953
- list_for_each_entry(t, &card->transaction_list, link) {
954
- if (t->node_id == source && t->tlabel == tlabel) {
955
- if (!try_cancel_split_timeout(t)) {
951
+ list_for_each_entry(iter, &card->transaction_list, link) {
952
+ if (iter->node_id == source && iter->tlabel == tlabel) {
953
+ if (!try_cancel_split_timeout(iter)) {
956954 spin_unlock_irqrestore(&card->lock, flags);
957955 goto timed_out;
958956 }
959
- list_del_init(&t->link);
960
- card->tlabel_mask &= ~(1ULL << t->tlabel);
957
+ list_del_init(&iter->link);
958
+ card->tlabel_mask &= ~(1ULL << iter->tlabel);
959
+ t = iter;
961960 break;
962961 }
963962 }
964963 spin_unlock_irqrestore(&card->lock, flags);
965964
966
- if (&t->link == &card->transaction_list) {
965
+ if (!t) {
967966 timed_out:
968967 fw_notice(card, "unsolicited response (source %x, tlabel %x)\n",
969968 source, tlabel);
....@@ -1100,14 +1099,14 @@
11001099 rcode = RCODE_ADDRESS_ERROR;
11011100 break;
11021101 }
1103
- /* else fall through */
1102
+ fallthrough;
11041103
11051104 case CSR_NODE_IDS:
11061105 /*
11071106 * per IEEE 1394-2008 8.3.22.3, not IEEE 1394.1-2004 3.2.8
11081107 * and 9.6, but interoperable with IEEE 1394.1-2004 bridges
11091108 */
1110
- /* fall through */
1109
+ fallthrough;
11111110
11121111 case CSR_STATE_CLEAR:
11131112 case CSR_STATE_SET: