Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp47832lqt; Wed, 5 Jun 2024 16:53:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXBLWXMekJc0DG1aYNESpqbKZtCmhlsxympuA8l/YGPcp3oxZQ6788lnLELNav0oydjK9hiBN3QV29rm7o1KVUAbLhWeFPC7WQWzsSGzQ== X-Google-Smtp-Source: AGHT+IFI/iS8yet8ba7BqDy137Gf7iQLNW8R7U/cn7fy6ZBIXuEikt1nXOtknLH0/1ntjfVavqRq X-Received: by 2002:a05:6e02:214d:b0:374:a422:b96 with SMTP id e9e14a558f8ab-374b1f4043amr43434815ab.23.1717631605497; Wed, 05 Jun 2024 16:53:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717631605; cv=pass; d=google.com; s=arc-20160816; b=EVCnXrJEibYKq6TvJi7GQFweIEwemqZGMHLq3T6Th0sEmny5xc43w54MUH0n7U3ILr J0h0s4C2A/yTrd5tD/SUvF0SutznRenbDW14qhlgNheEIPWvAtWWetLNDLSk4grpF25H oSLZbV4dnGqrcMtS4eC3uuixelBf3DXAdrSjMISepBFH712MoWIa9qzqvO1oHr1VniRv NEgg/Xo9D9aTEsBtdrWcDn9yP427u336Y3Z/e19K24Fuf2NKy8t9LH8tu8n6Jmw6juv/ nGwe4ZRvACEMXTJ1EJvlSyQvd7CwBhsu/gwhkwAHJDcUkeyX7uSWx9wZKo+s5p6ns9JO 77Bg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:feedback-id:dkim-signature:dkim-signature; bh=/hGv3vJEc747DzmJ/9VfAfyTUxjs3kdRF01FRUOE/pw=; fh=5EQyDiYgg+kua2A2AF9eJME8jasrrRA/Pgg86y+lzvY=; b=JENrzy7Bpnj/nDutnCrctN2PcOE+2T+uweZjSSYiV8M9cSpj1sikVOhCe30koQTp9X WA8LbzC4txguuTZLpK6pfFAIMLxKTaj+bl+kaiv+C0kParlF2wtzFW2eyXc/uD0ty408 WNJTl7iECAE2QQf9BcdQs1+b0KFT0Tk62oW+EWd9Y2uDnsn4WxUjO2n8dSYrFacBaOTA OO79C69Xh1pT7QMM7i9MZ9SXhaYRcyooW1ijLHkIiPFCGUcacHCYi9q8fTCYQEBX7Iym oTKQcOxedX9pm2pvwFYNZhZZ8rPi+Fh7Zg/40I1pXhdiLsyZ3VRLGOCoNtCjs0g2KClt C4AQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm1 header.b=OZ+9m358; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=QvEdmz6X; arc=pass (i=1 spf=pass spfdomain=sakamocchi.jp dkim=pass dkdomain=sakamocchi.jp dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=sakamocchi.jp); spf=pass (google.com: domain of linux-kernel+bounces-203427-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203427-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de29cb9be3si140129a12.770.2024.06.05.16.53.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:53:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203427-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm1 header.b=OZ+9m358; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=QvEdmz6X; arc=pass (i=1 spf=pass spfdomain=sakamocchi.jp dkim=pass dkdomain=sakamocchi.jp dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=sakamocchi.jp); spf=pass (google.com: domain of linux-kernel+bounces-203427-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203427-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CC54D283DFF for ; Wed, 5 Jun 2024 23:53:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D764416EC16; Wed, 5 Jun 2024 23:52:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="OZ+9m358"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QvEdmz6X" Received: from wfout2-smtp.messagingengine.com (wfout2-smtp.messagingengine.com [64.147.123.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E66E168C2E for ; Wed, 5 Jun 2024 23:52:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.145 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717631535; cv=none; b=FIOHGBDTEDZSKPp8lkgP4clB4vgOJMCGMRx0fjwEsaFowq9RnBHU7hjUl1aq+vfOt79VqyDPNR+WxaHU20bAn7jVjyT7iP8lUGf1Jcl9Tfh4Ezxg7dkgHQFuXtFm3BuGJDo3zNK2+aDrj+H9xe2rj8i8opiL5qNDahRXWj4h7wk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717631535; c=relaxed/simple; bh=j7AYul+E3SNchcFdpNyT4iDK9RXRnUgJ1OtxzdywbSk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VEv0MAZPCgTNqLG+wEiW85IVrai+ICki0IQGiDGDa/5gDjPHrIgjMNGkLzhTT77xYBd3crIGdaySsW1tR3SiS35KQFPOyiZogi28LhyRrLQOrG/1gc7ajL6wKRU81KnCD6Zff7H7yNsKCVw6QrmpN8iXfiVguBcHFilx/xHmXCk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=OZ+9m358; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QvEdmz6X; arc=none smtp.client-ip=64.147.123.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.west.internal (Postfix) with ESMTP id 44DD01C000F6; Wed, 5 Jun 2024 19:52:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 05 Jun 2024 19:52:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1717631532; x= 1717717932; bh=/hGv3vJEc747DzmJ/9VfAfyTUxjs3kdRF01FRUOE/pw=; b=O Z+9m358aGLTCduScfSN048PZa99HfCZyObOKRTIm6bTsz5tqCKkCprwsWt92n0AR jLzoKHDz9AemtWHL/yOZW1mXwu1KFK8Jm6fXIIWDsj7awY5OhKuCHfsTbiKB2CRZ vEx4kufoLuXxkM+EMhq2KsYR0nf8Qd/VExLSCU8jAY/10JQFctQPj8AienUWiaTn 6fsz2AXEFRvmukubJicnvdOL2glvlbJMdSK/Lr6kOad3vuPt4nCbO8Qh6488Tz7l tXVhSAUux5rdM6oNGnW+v9AAhY+YbmMpyGXF5v+eS2Yq1/FayJyoUakkWzQPn01p vzwamJr2olNffZCN7Z52A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1717631532; x= 1717717932; bh=/hGv3vJEc747DzmJ/9VfAfyTUxjs3kdRF01FRUOE/pw=; b=Q vEdmz6X+LcTYjqIsPVViaVBO7b4pvuydIcoggOLl6ZhdsWKTK06FlJ9NU9r2ojIO kvd+yMIOsyofVwv80xTWnawc2+NUr9TUgRDWDfx5JN04qnK4Z7PeOyr+4Na9q+x9 fhtKu0L2tnxHumMAufVoWcryamFqFnW3ZBqBF6wINKz8R6i59CndYwPbIoI9nU6M 5qJtFTFWrC8OC9jjb/g0kmhKYB9rcoXxC4O1gffBEhFmmVp9x8ctgAV/DXgwudTr sOXyHq1NHR5LTljUeKPoqOfRFJCPdlbfwV6XygRukbt3HqfLe/bttV33e4EaC36d lJKMTCiI0KCfoYZITgTxQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeljedgvdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 5 Jun 2024 19:52:11 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 06/11] firewire: ohci: use helper functions for self ID sequence Date: Thu, 6 Jun 2024 08:51:50 +0900 Message-ID: <20240605235155.116468-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605235155.116468-1-o-takashi@sakamocchi.jp> References: <20240605235155.116468-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This commit replaces the existing implementation with the helper functions for self ID sequence. Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 77 ++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 0ef76cf7b328..342407d8bc9b 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -41,6 +41,7 @@ #include "core.h" #include "ohci.h" #include "packet-header-definitions.h" +#include "phy-packet-definitions.h" #define ohci_info(ohci, f, args...) dev_info(ohci->card.device, f, ##args) #define ohci_notice(ohci, f, args...) dev_notice(ohci->card.device, f, ##args) @@ -437,11 +438,6 @@ static void log_irqs(struct fw_ohci *ohci, u32 evt) ? " ?" : ""); } -static unsigned int _p(u32 *s, int shift) -{ - return *s >> shift & 3; -} - static void log_selfids(struct fw_ohci *ohci, int generation, int self_id_count) { static const char *const speed[] = { @@ -451,8 +447,16 @@ static void log_selfids(struct fw_ohci *ohci, int generation, int self_id_count) [0] = "+0W", [1] = "+15W", [2] = "+30W", [3] = "+45W", [4] = "-3W", [5] = " ?W", [6] = "-3..-6W", [7] = "-3..-10W", }; - static const char port[] = { '.', '-', 'p', 'c', }; - u32 *s; + static const char port[] = { + [PHY_PACKET_SELF_ID_PORT_STATUS_NONE] = '.', + [PHY_PACKET_SELF_ID_PORT_STATUS_NCONN] = '-', + [PHY_PACKET_SELF_ID_PORT_STATUS_PARENT] = 'p', + [PHY_PACKET_SELF_ID_PORT_STATUS_CHILD] = 'c', + }; + struct self_id_sequence_enumerator enumerator = { + .cursor = ohci->self_id_buffer, + .quadlet_count = self_id_count, + }; if (likely(!(param_debug & OHCI_PARAM_DEBUG_SELFIDS))) return; @@ -460,29 +464,46 @@ static void log_selfids(struct fw_ohci *ohci, int generation, int self_id_count) ohci_notice(ohci, "%d selfIDs, generation %d, local node ID %04x\n", self_id_count, generation, ohci->node_id); - for (s = ohci->self_id_buffer; self_id_count--; ++s) - if ((*s & 1 << 23) == 0) - ohci_notice(ohci, - "selfID 0: %08x, phy %d [%c%c%c] %s gc=%d %s %s%s%s\n", - *s, *s >> 24 & 63, - port[_p(s, 6)], - port[_p(s, 4)], - port[_p(s, 2)], - speed[*s >> 14 & 3], *s >> 16 & 63, - power[*s >> 8 & 7], *s >> 22 & 1 ? "L" : "", - *s >> 11 & 1 ? "c" : "", *s & 2 ? "i" : ""); - else + while (enumerator.quadlet_count > 0) { + unsigned int quadlet_count; + unsigned int port_index; + const u32 *s; + int i; + + s = self_id_sequence_enumerator_next(&enumerator, &quadlet_count); + if (IS_ERR(s)) + break; + + ohci_notice(ohci, + "selfID 0: %08x, phy %d [%c%c%c] %s gc=%d %s %s%s%s\n", + *s, + *s >> 24 & 63, + port[self_id_sequence_get_port_status(s, quadlet_count, 0)], + port[self_id_sequence_get_port_status(s, quadlet_count, 1)], + port[self_id_sequence_get_port_status(s, quadlet_count, 2)], + speed[*s >> 14 & 3], *s >> 16 & 63, + power[*s >> 8 & 7], *s >> 22 & 1 ? "L" : "", + *s >> 11 & 1 ? "c" : "", *s & 2 ? "i" : ""); + + port_index = 3; + for (i = 1; i < quadlet_count; ++i) { ohci_notice(ohci, "selfID n: %08x, phy %d [%c%c%c%c%c%c%c%c]\n", - *s, *s >> 24 & 63, - port[_p(s, 16)], - port[_p(s, 14)], - port[_p(s, 12)], - port[_p(s, 10)], - port[_p(s, 8)], - port[_p(s, 6)], - port[_p(s, 4)], - port[_p(s, 2)]); + s[i], + s[i] >> 24 & 63, + port[self_id_sequence_get_port_status(s, quadlet_count, port_index)], + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 1)], + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 2)], + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 3)], + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 4)], + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 5)], + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 6)], + port[self_id_sequence_get_port_status(s, quadlet_count, port_index + 7)] + ); + + port_index += 8; + } + } } static const char *evts[] = { -- 2.43.0