Skip to content

Commit c5deb01

Browse files
committed
firewire: core: obsolete tcode check macros with inline functions
This commit declares the helper functions to check tcode to obsolete the functional macros. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent 2a0b46a commit c5deb01

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

drivers/firewire/core-transaction.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ void fw_core_handle_request(struct fw_card *card, struct fw_packet *p)
972972
if (p->ack != ACK_PENDING && p->ack != ACK_COMPLETE)
973973
return;
974974

975-
if (TCODE_IS_LINK_INTERNAL(async_header_get_tcode(p->header))) {
975+
if (tcode_is_link_internal(async_header_get_tcode(p->header))) {
976976
fw_cdev_handle_phy_packet(card, p);
977977
return;
978978
}
@@ -1109,7 +1109,7 @@ static void handle_topology_map(struct fw_card *card, struct fw_request *request
11091109
{
11101110
int start;
11111111

1112-
if (!TCODE_IS_READ_REQUEST(tcode)) {
1112+
if (!tcode_is_read_request(tcode)) {
11131113
fw_send_response(card, request, RCODE_TYPE_ERROR);
11141114
return;
11151115
}

drivers/firewire/core.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,20 @@ static inline bool is_next_generation(int new_generation, int old_generation)
225225

226226
#define TCODE_LINK_INTERNAL 0xe
227227

228-
#define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4)
229-
#define TCODE_IS_BLOCK_PACKET(tcode) (((tcode) & 1) != 0)
230-
#define TCODE_IS_LINK_INTERNAL(tcode) ((tcode) == TCODE_LINK_INTERNAL)
231-
#define TCODE_IS_REQUEST(tcode) (((tcode) & 2) == 0)
232-
#define TCODE_IS_RESPONSE(tcode) (((tcode) & 2) != 0)
233-
#define TCODE_HAS_REQUEST_DATA(tcode) (((tcode) & 12) != 4)
234-
#define TCODE_HAS_RESPONSE_DATA(tcode) (((tcode) & 12) != 0)
228+
static inline bool tcode_is_read_request(unsigned int tcode)
229+
{
230+
return (tcode & ~1u) == 4u;
231+
}
232+
233+
static inline bool tcode_is_block_packet(unsigned int tcode)
234+
{
235+
return (tcode & 1u) != 0u;
236+
}
237+
238+
static inline bool tcode_is_link_internal(unsigned int tcode)
239+
{
240+
return (tcode == TCODE_LINK_INTERNAL);
241+
}
235242

236243
#define LOCAL_BUS 0xffc0
237244

drivers/firewire/ohci.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ static int at_context_queue_packet(struct context *ctx,
13821382
(packet->header[0] & 0xffff0000));
13831383
header[2] = cpu_to_le32(packet->header[2]);
13841384

1385-
if (TCODE_IS_BLOCK_PACKET(tcode))
1385+
if (tcode_is_block_packet(tcode))
13861386
header[3] = cpu_to_le32(packet->header[3]);
13871387
else
13881388
header[3] = (__force __le32) packet->header[3];
@@ -1570,7 +1570,7 @@ static void handle_local_rom(struct fw_ohci *ohci,
15701570
int tcode, length, i;
15711571

15721572
tcode = async_header_get_tcode(packet->header);
1573-
if (TCODE_IS_BLOCK_PACKET(tcode))
1573+
if (tcode_is_block_packet(tcode))
15741574
length = async_header_get_data_length(packet->header);
15751575
else
15761576
length = 4;
@@ -1579,7 +1579,7 @@ static void handle_local_rom(struct fw_ohci *ohci,
15791579
if (i + length > CONFIG_ROM_SIZE) {
15801580
fw_fill_response(&response, packet->header,
15811581
RCODE_ADDRESS_ERROR, NULL, 0);
1582-
} else if (!TCODE_IS_READ_REQUEST(tcode)) {
1582+
} else if (!tcode_is_read_request(tcode)) {
15831583
fw_fill_response(&response, packet->header,
15841584
RCODE_TYPE_ERROR, NULL, 0);
15851585
} else {

0 commit comments

Comments
 (0)