firewire: core: obsolete tcode check macros with inline functions
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 28 Apr 2024 07:13:44 +0000 (16:13 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 6 May 2024 02:06:05 +0000 (11:06 +0900)
This commit declares the helper functions to check tcode to obsolete
the functional macros.

Link: https://lore.kernel.org/r/20240428071347.409202-7-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
drivers/firewire/core-transaction.c
drivers/firewire/core.h
drivers/firewire/ohci.c

index a113f801cf33375ff15a5cb2089be46062af8581..45ea15342ab82978c8f638ed93cd4cce21d81f01 100644 (file)
@@ -972,7 +972,7 @@ void fw_core_handle_request(struct fw_card *card, struct fw_packet *p)
        if (p->ack != ACK_PENDING && p->ack != ACK_COMPLETE)
                return;
 
-       if (TCODE_IS_LINK_INTERNAL(async_header_get_tcode(p->header))) {
+       if (tcode_is_link_internal(async_header_get_tcode(p->header))) {
                fw_cdev_handle_phy_packet(card, p);
                return;
        }
@@ -1109,7 +1109,7 @@ static void handle_topology_map(struct fw_card *card, struct fw_request *request
 {
        int start;
 
-       if (!TCODE_IS_READ_REQUEST(tcode)) {
+       if (!tcode_is_read_request(tcode)) {
                fw_send_response(card, request, RCODE_TYPE_ERROR);
                return;
        }
index ff96e5456b5de7c30929259a4ef850b0cf66075f..5097c7a270b490dfd480f1e82a8320094ee9ec0e 100644 (file)
@@ -225,13 +225,20 @@ static inline bool is_next_generation(int new_generation, int old_generation)
 
 #define TCODE_LINK_INTERNAL            0xe
 
-#define TCODE_IS_READ_REQUEST(tcode)   (((tcode) & ~1) == 4)
-#define TCODE_IS_BLOCK_PACKET(tcode)   (((tcode) &  1) != 0)
-#define TCODE_IS_LINK_INTERNAL(tcode)  ((tcode) == TCODE_LINK_INTERNAL)
-#define TCODE_IS_REQUEST(tcode)                (((tcode) &  2) == 0)
-#define TCODE_IS_RESPONSE(tcode)       (((tcode) &  2) != 0)
-#define TCODE_HAS_REQUEST_DATA(tcode)  (((tcode) & 12) != 4)
-#define TCODE_HAS_RESPONSE_DATA(tcode) (((tcode) & 12) != 0)
+static inline bool tcode_is_read_request(unsigned int tcode)
+{
+       return (tcode & ~1u) == 4u;
+}
+
+static inline bool tcode_is_block_packet(unsigned int tcode)
+{
+       return (tcode & 1u) != 0u;
+}
+
+static inline bool tcode_is_link_internal(unsigned int tcode)
+{
+       return (tcode == TCODE_LINK_INTERNAL);
+}
 
 #define LOCAL_BUS 0xffc0
 
index c2d3dc7fbe6e28ed528a56dddd7edaf10f8ce2f3..c8891aa70a51eecb8567c9ee6dd6c3f76e7b999e 100644 (file)
@@ -1382,7 +1382,7 @@ static int at_context_queue_packet(struct context *ctx,
                                        (packet->header[0] & 0xffff0000));
                header[2] = cpu_to_le32(packet->header[2]);
 
-               if (TCODE_IS_BLOCK_PACKET(tcode))
+               if (tcode_is_block_packet(tcode))
                        header[3] = cpu_to_le32(packet->header[3]);
                else
                        header[3] = (__force __le32) packet->header[3];
@@ -1570,7 +1570,7 @@ static void handle_local_rom(struct fw_ohci *ohci,
        int tcode, length, i;
 
        tcode = async_header_get_tcode(packet->header);
-       if (TCODE_IS_BLOCK_PACKET(tcode))
+       if (tcode_is_block_packet(tcode))
                length = async_header_get_data_length(packet->header);
        else
                length = 4;
@@ -1579,7 +1579,7 @@ static void handle_local_rom(struct fw_ohci *ohci,
        if (i + length > CONFIG_ROM_SIZE) {
                fw_fill_response(&response, packet->header,
                                 RCODE_ADDRESS_ERROR, NULL, 0);
-       } else if (!TCODE_IS_READ_REQUEST(tcode)) {
+       } else if (!tcode_is_read_request(tcode)) {
                fw_fill_response(&response, packet->header,
                                 RCODE_TYPE_ERROR, NULL, 0);
        } else {