Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

firewire: ohci: use helper functions for self ID sequence

This commit replaces the existing implementation with the helper
functions for self ID sequence.

Link: https://lore.kernel.org/r/20240605235155.116468-7-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

+49 -28
+49 -28
drivers/firewire/ohci.c
··· 41 41 #include "core.h" 42 42 #include "ohci.h" 43 43 #include "packet-header-definitions.h" 44 + #include "phy-packet-definitions.h" 44 45 45 46 #define ohci_info(ohci, f, args...) dev_info(ohci->card.device, f, ##args) 46 47 #define ohci_notice(ohci, f, args...) dev_notice(ohci->card.device, f, ##args) ··· 438 437 ? " ?" : ""); 439 438 } 440 439 441 - static unsigned int _p(u32 *s, int shift) 442 - { 443 - return *s >> shift & 3; 444 - } 445 - 446 440 static void log_selfids(struct fw_ohci *ohci, int generation, int self_id_count) 447 441 { 448 442 static const char *const speed[] = { ··· 447 451 [0] = "+0W", [1] = "+15W", [2] = "+30W", [3] = "+45W", 448 452 [4] = "-3W", [5] = " ?W", [6] = "-3..-6W", [7] = "-3..-10W", 449 453 }; 450 - static const char port[] = { '.', '-', 'p', 'c', }; 451 - u32 *s; 454 + static const char port[] = { 455 + [PHY_PACKET_SELF_ID_PORT_STATUS_NONE] = '.', 456 + [PHY_PACKET_SELF_ID_PORT_STATUS_NCONN] = '-', 457 + [PHY_PACKET_SELF_ID_PORT_STATUS_PARENT] = 'p', 458 + [PHY_PACKET_SELF_ID_PORT_STATUS_CHILD] = 'c', 459 + }; 460 + struct self_id_sequence_enumerator enumerator = { 461 + .cursor = ohci->self_id_buffer, 462 + .quadlet_count = self_id_count, 463 + }; 452 464 453 465 if (likely(!(param_debug & OHCI_PARAM_DEBUG_SELFIDS))) 454 466 return; ··· 464 460 ohci_notice(ohci, "%d selfIDs, generation %d, local node ID %04x\n", 465 461 self_id_count, generation, ohci->node_id); 466 462 467 - for (s = ohci->self_id_buffer; self_id_count--; ++s) 468 - if ((*s & 1 << 23) == 0) 469 - ohci_notice(ohci, 470 - "selfID 0: %08x, phy %d [%c%c%c] %s gc=%d %s %s%s%s\n", 471 - *s, *s >> 24 & 63, 472 - port[_p(s, 6)], 473 - port[_p(s, 4)], 474 - port[_p(s, 2)], 475 - speed[*s >> 14 & 3], *s >> 16 & 63, 476 - power[*s >> 8 & 7], *s >> 22 & 1 ? "L" : "", 477 - *s >> 11 & 1 ? "c" : "", *s & 2 ? "i" : ""); 478 - else 463 + while (enumerator.quadlet_count > 0) { 464 + unsigned int quadlet_count; 465 + unsigned int port_index; 466 + const u32 *s; 467 + int i; 468 + 469 + s = self_id_sequence_enumerator_next(&enumerator, &quadlet_count); 470 + if (IS_ERR(s)) 471 + break; 472 + 473 + ohci_notice(ohci, 474 + "selfID 0: %08x, phy %d [%c%c%c] %s gc=%d %s %s%s%s\n", 475 + *s, 476 + *s >> 24 & 63, 477 + port[self_id_sequence_get_port_status(s, quadlet_count, 0)], 478 + port[self_id_sequence_get_port_status(s, quadlet_count, 1)], 479 + port[self_id_sequence_get_port_status(s, quadlet_count, 2)], 480 + speed[*s >> 14 & 3], *s >> 16 & 63, 481 + power[*s >> 8 & 7], *s >> 22 & 1 ? "L" : "", 482 + *s >> 11 & 1 ? "c" : "", *s & 2 ? "i" : ""); 483 + 484 + port_index = 3; 485 + for (i = 1; i < quadlet_count; ++i) { 479 486 ohci_notice(ohci, 480 487 "selfID n: %08x, phy %d [%c%c%c%c%c%c%c%c]\n", 481 - *s, *s >> 24 & 63, 482 - port[_p(s, 16)], 483 - port[_p(s, 14)], 484 - port[_p(s, 12)], 485 - port[_p(s, 10)], 486 - port[_p(s, 8)], 487 - port[_p(s, 6)], 488 - port[_p(s, 4)], 489 - port[_p(s, 2)]); 488 + s[i], 489 + s[i] >> 24 & 63, 490 + port[self_id_sequence_get_port_status(s, quadlet_count, port_index)], 491 + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 1)], 492 + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 2)], 493 + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 3)], 494 + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 4)], 495 + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 5)], 496 + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 6)], 497 + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 7)] 498 + ); 499 + 500 + port_index += 8; 501 + } 502 + } 490 503 } 491 504 492 505 static const char *evts[] = {