Skip to content

Commit e404cac

Browse files
committed
firewire: ohci: minor code refactoring for self ID logging
Current implementation to log self ID sequence has the rest to be refactored; e.g. moving translation-unit level variables to the dependent block. This commit is for the purpose. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent 10f5aee commit e404cac

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

drivers/firewire/ohci.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -437,22 +437,21 @@ static void log_irqs(struct fw_ohci *ohci, u32 evt)
437437
? " ?" : "");
438438
}
439439

440-
static const char *speed[] = {
441-
[0] = "S100", [1] = "S200", [2] = "S400", [3] = "beta",
442-
};
443-
static const char *power[] = {
444-
[0] = "+0W", [1] = "+15W", [2] = "+30W", [3] = "+45W",
445-
[4] = "-3W", [5] = " ?W", [6] = "-3..-6W", [7] = "-3..-10W",
446-
};
447-
static const char port[] = { '.', '-', 'p', 'c', };
448-
449-
static char _p(u32 *s, int shift)
440+
static unsigned int _p(u32 *s, int shift)
450441
{
451-
return port[*s >> shift & 3];
442+
return *s >> shift & 3;
452443
}
453444

454445
static void log_selfids(struct fw_ohci *ohci, int generation, int self_id_count)
455446
{
447+
static const char *const speed[] = {
448+
[0] = "S100", [1] = "S200", [2] = "S400", [3] = "beta",
449+
};
450+
static const char *const power[] = {
451+
[0] = "+0W", [1] = "+15W", [2] = "+30W", [3] = "+45W",
452+
[4] = "-3W", [5] = " ?W", [6] = "-3..-6W", [7] = "-3..-10W",
453+
};
454+
static const char port[] = { '.', '-', 'p', 'c', };
456455
u32 *s;
457456

458457
if (likely(!(param_debug & OHCI_PARAM_DEBUG_SELFIDS)))
@@ -465,16 +464,25 @@ static void log_selfids(struct fw_ohci *ohci, int generation, int self_id_count)
465464
if ((*s & 1 << 23) == 0)
466465
ohci_notice(ohci,
467466
"selfID 0: %08x, phy %d [%c%c%c] %s gc=%d %s %s%s%s\n",
468-
*s, *s >> 24 & 63, _p(s, 6), _p(s, 4), _p(s, 2),
467+
*s, *s >> 24 & 63,
468+
port[_p(s, 6)],
469+
port[_p(s, 4)],
470+
port[_p(s, 2)],
469471
speed[*s >> 14 & 3], *s >> 16 & 63,
470472
power[*s >> 8 & 7], *s >> 22 & 1 ? "L" : "",
471473
*s >> 11 & 1 ? "c" : "", *s & 2 ? "i" : "");
472474
else
473475
ohci_notice(ohci,
474476
"selfID n: %08x, phy %d [%c%c%c%c%c%c%c%c]\n",
475477
*s, *s >> 24 & 63,
476-
_p(s, 16), _p(s, 14), _p(s, 12), _p(s, 10),
477-
_p(s, 8), _p(s, 6), _p(s, 4), _p(s, 2));
478+
port[_p(s, 16)],
479+
port[_p(s, 14)],
480+
port[_p(s, 12)],
481+
port[_p(s, 10)],
482+
port[_p(s, 8)],
483+
port[_p(s, 6)],
484+
port[_p(s, 4)],
485+
port[_p(s, 2)]);
478486
}
479487

480488
static const char *evts[] = {

0 commit comments

Comments
 (0)