From nobody Fri Dec 19 08:18:28 2025 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (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 367E365197 for ; Thu, 21 Dec 2023 13:48:54 +0000 (UTC) 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="XczRfcSE"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="IqRp/tCq" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 3484E5C0114; Thu, 21 Dec 2023 08:48:54 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 21 Dec 2023 08:48:54 -0500 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=fm2; t=1703166534; x= 1703252934; bh=pMmsyjj7nl7WSS15wYh422IW+VbkrnpbXUDIHZjOSwQ=; b=X czRfcSEBVlloJN/YhhcuwM+UlSYI5kpcd/1kDb/B9uf3DwnnTlzSSFAWJTEFTanw J5GY7lkfQQ0lNsdPFt3McVMRqPP7yVAs8w6QXl7x3QxTkS6WttSMSG07mK4eOUnT VfJw35KyE242ByG3KG2lrscv2TBwVdCrjImV8mU5zG4cV+iYlafWSOjddlNV1PIM amkg18/kitraeT6Tvcj9QWnrbomgKbfCmvY2h38w6Z1RmpaQmfNiHBjP62RlL4Oa of0EFVa1H3KYjGnRwU0a1ztg3XEVmxpFH9hPHO9jzADMqMIoeEe/N3vLy9x2zRgo Su0DXnNRLo7TruwLdaiAw== 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=fm2; t=1703166534; x= 1703252934; bh=pMmsyjj7nl7WSS15wYh422IW+VbkrnpbXUDIHZjOSwQ=; b=I qRp/tCqosguPNNDC3p+wLS8QYcc/DWxOEKRO93JCCM5CmpwdBy5vmMUc8iFqYe5i EgjaWj0e8698yCDelUAwjbm7v6NoNQ7+jSr6MdTtRd5yCNGx8QzjpyziPQDd7UOd HC0kQmLKZOr8hZkmHeeH2cKjYxhk3CZ2s7l7L5rHFU91Tu1IiCAgWFnOH7gHZMzp /5rrcu60diGNaa7BhRHwEqlc+S4856CNHD09+LbLYodF3HbPDcZ8NApj8JLB8OuN ebSLy/x3TwXLcFhkaYYnbScmaL0RrMDP8MVWPPuRBkt37E+e5bkZcu75UyYpTWSF cjpr8VC/eZFw9EZ5Jk5WQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduhedgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Dec 2023 08:48:52 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH v2 1/8] firewire: core: adds constant qualifier for local helper functions Date: Thu, 21 Dec 2023 22:48:42 +0900 Message-Id: <20231221134849.603857-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221134849.603857-1-o-takashi@sakamocchi.jp> References: <20231221134849.603857-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: quoted-printable Content-Type: text/plain; charset="utf-8" Some local functions just handles given argument as mutable, thus it is preferable to add constant qualifier to them. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index eeda7cc59e27..96b0b43da863 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -171,7 +171,7 @@ static const struct ieee1394_device_id *unit_match(stru= ct device *dev, return NULL; } =20 -static bool is_fw_unit(struct device *dev); +static bool is_fw_unit(const struct device *dev); =20 static int fw_unit_match(struct device *dev, struct device_driver *drv) { @@ -679,7 +679,7 @@ static struct device_type fw_unit_type =3D { .release =3D fw_unit_release, }; =20 -static bool is_fw_unit(struct device *dev) +static bool is_fw_unit(const struct device *dev) { return dev->type =3D=3D &fw_unit_type; } @@ -838,7 +838,7 @@ static struct device_type fw_device_type =3D { .release =3D fw_device_release, }; =20 -static bool is_fw_device(struct device *dev) +static bool is_fw_device(const struct device *dev) { return dev->type =3D=3D &fw_device_type; } --=20 2.39.2 From nobody Fri Dec 19 08:18:28 2025 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (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 A560E6D6CC for ; Thu, 21 Dec 2023 13:48:56 +0000 (UTC) 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="HIuDvn01"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="FoavjJCi" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id BBDAC5C0293; Thu, 21 Dec 2023 08:48:55 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 21 Dec 2023 08:48:55 -0500 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=fm2; t=1703166535; x= 1703252935; bh=PBp/kI0n0J8XwNjRh8pLSTFV6N9OxHCw9BU3vtXvG80=; b=H IuDvn01LqcWi0C3Hd7AERs4UJmkkz+qSxPdbfFy7Cj4V3gRtcWHb/QU57t50cLFa mKT32d7aPDy8Zxhs1kk1+MkieEyOHMe780GJKhvjNMPY5aeWelWt9RxRe4JuW02m 9kv5SVizWuW5IcspWKH/lnUCLSvoeaG2o+gQRjIRGcceEnzzsCmuY84ZQtjrSlwj lANPEMs2c+6fL3LDLsQMXDHG8AqcxZRQZWgMAr9ZWpMBLPfk5PfdJsEHWklW3QKw 6ymO9Y7gPlymj6K9/JVFImx5Tn+yGzyV2l9RLsPYt8eGM0x+sCnxt8qliRG7mqv9 7o5YzaXnM5zC58bizd+sg== 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=fm2; t=1703166535; x= 1703252935; bh=PBp/kI0n0J8XwNjRh8pLSTFV6N9OxHCw9BU3vtXvG80=; b=F oavjJCir1WITV2vHJtlHCl8BENh1qh45/7Ja8Sbi4sntAGLcuUcnmP9zVb0yGfHW EFBBooPISK45ABDBJDmn1nV4asER9rWWZzFM5UH/scwEKZnXTlM2oewfOQduUWuC P7JZaX7RnVoqGRzuFWTVXHlIthlSwMUWkwG4P3oVTgvZ1ncjXXVYW/2cHLEwIxgW qYfbwGpy7O9a9U0Q1KY1eADu12Ic6pcL/q+WU/+Hsx1ikOYulE/hVxwQOVbtBADv RSDAJyK7tatHn+fN1acHwuzcZudsdFd3XSXiUgd0xRPkrToh88ZSmi1nQV+NkAha ncTx2C29nfs8m0r3tfZKQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduhedgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Dec 2023 08:48:54 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH v2 2/8] firewire: core: replace magic number with macro Date: Thu, 21 Dec 2023 22:48:43 +0900 Message-Id: <20231221134849.603857-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221134849.603857-1-o-takashi@sakamocchi.jp> References: <20231221134849.603857-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: quoted-printable Content-Type: text/plain; charset="utf-8" In IEEE 1394 specification, the size of bus information block of configuration ROM is fixed to 5, thus the offset of root directory is 5. Current implementation to handle device structures has the hard-coded offset. This commit replaces the offset with macro. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 96b0b43da863..315a2fe41643 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -31,6 +31,8 @@ =20 #include "core.h" =20 +#define ROOT_DIR_OFFSET 5 + void fw_csr_iterator_init(struct fw_csr_iterator *ci, const u32 *p) { ci->p =3D p + 1; @@ -135,7 +137,7 @@ static void get_ids(const u32 *directory, int *id) =20 static void get_modalias_ids(const struct fw_unit *unit, int *id) { - get_ids(&fw_parent_device(unit)->config_rom[5], id); + get_ids(&fw_parent_device(unit)->config_rom[ROOT_DIR_OFFSET], id); get_ids(unit->directory, id); } =20 @@ -259,7 +261,7 @@ static ssize_t show_immediate(struct device *dev, if (is_fw_unit(dev)) dir =3D fw_unit(dev)->directory; else - dir =3D fw_device(dev)->config_rom + 5; + dir =3D fw_device(dev)->config_rom + ROOT_DIR_OFFSET; =20 fw_csr_iterator_init(&ci, dir); while (fw_csr_iterator_next(&ci, &key, &value)) @@ -292,7 +294,7 @@ static ssize_t show_text_leaf(struct device *dev, if (is_fw_unit(dev)) dir =3D fw_unit(dev)->directory; else - dir =3D fw_device(dev)->config_rom + 5; + dir =3D fw_device(dev)->config_rom + ROOT_DIR_OFFSET; =20 if (buf) { bufsize =3D PAGE_SIZE - 1; @@ -446,7 +448,7 @@ static ssize_t units_show(struct device *dev, int key, value, i =3D 0; =20 down_read(&fw_device_rwsem); - fw_csr_iterator_init(&ci, &device->config_rom[5]); + fw_csr_iterator_init(&ci, &device->config_rom[ROOT_DIR_OFFSET]); while (fw_csr_iterator_next(&ci, &key, &value)) { if (key !=3D (CSR_UNIT | CSR_DIRECTORY)) continue; @@ -691,7 +693,7 @@ static void create_units(struct fw_device *device) int key, value, i; =20 i =3D 0; - fw_csr_iterator_init(&ci, &device->config_rom[5]); + fw_csr_iterator_init(&ci, &device->config_rom[ROOT_DIR_OFFSET]); while (fw_csr_iterator_next(&ci, &key, &value)) { if (key !=3D (CSR_UNIT | CSR_DIRECTORY)) continue; --=20 2.39.2 From nobody Fri Dec 19 08:18:28 2025 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (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 1F0176D6F2 for ; Thu, 21 Dec 2023 13:48:57 +0000 (UTC) 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="BfOvB/bc"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fBRpnMnc" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 375655C014E; Thu, 21 Dec 2023 08:48:57 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 21 Dec 2023 08:48:57 -0500 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=fm2; t=1703166537; x= 1703252937; bh=ALyVWm7/dGT5KixYxR7NqL6VJqyaNldFMTquZW7hL6k=; b=B fOvB/bcjpVh9NapV+lTT63YGhg5xcUFI7RTheTspm8D3vY5nA6n/avarYfBPrmRD r9eCvk+DPJ0n/zl3YrMozcalpCexqptYCMf/z79tv96Jk3fZx8WKsuZrbrJ7daTD j1pi2rwEinkD6m5B3p5jojV2bQxTTqRy0ppydD6oX27C2qHaVvsOYRV9G2TMI4Uo fVJIvmgqHFE+NKQa2JDHj+AZU7i92eVOFWEoUNvpCqPMpDOJNatdDdhluquWW6sm cGE/PbuwTGytUrS69JT6DD4dxQky8BNlb70WOSjl7ZpdJwwEvIRKT0lDHj2q8PyA eBvGpqyZEtyncCxczSCAQ== 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=fm2; t=1703166537; x= 1703252937; bh=ALyVWm7/dGT5KixYxR7NqL6VJqyaNldFMTquZW7hL6k=; b=f BRpnMncBb1krTat9dI8YIVk3rdL5SFSMzlBSBDGuj1u+rcL9n5ApgIpTZ0gcKevl kE+UiiLL5ciovqJMpg5N2b/c44dijGRZpw8wD+Fq8IaHr+TMKSO0zV359T2jbJE6 HT+/ddI9mkPEtszTLWnKtWjNdHsyZwyAFKGjoU+7p61Ylk2mrthcRcHEdkNhDkQc vkGaGd9wHTWKQuK+hVYs63ohsTDRhBVUDw+Gt5f5POPHvKbdKv2Y5OB9s2lY9SqR fOPa9/xNok21/03lz0oy4nmkAk4e/M75TUFFc8YAn6RTvH+TxpHBGlz73qxtt33Z dQ7qdekXjT9mlU0Op6GVQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduhedgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeeugfevtd efhfeffeeuudduhfekhffgveejfeeiiefftdethfduudevjeekveffleenucffohhmrghi nhepthgvshhtrghnhihthhhinhhgrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhi rdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Dec 2023 08:48:55 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH v2 3/8] firewire: test: add KUnit test for device attributes Date: Thu, 21 Dec 2023 22:48:44 +0900 Message-Id: <20231221134849.603857-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221134849.603857-1-o-takashi@sakamocchi.jp> References: <20231221134849.603857-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: quoted-printable Content-Type: text/plain; charset="utf-8" The traverse over CSR space results in attributes of node and unit devices. Any test of the traverse is useful. This commit adds a skeleton of KUnit test for the purpose. Signed-off-by: Takashi Sakamoto --- drivers/firewire/.kunitconfig | 1 + drivers/firewire/Kconfig | 16 ++++++++++++++++ drivers/firewire/core-device.c | 4 ++++ drivers/firewire/device-attribute-test.c | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 drivers/firewire/device-attribute-test.c diff --git a/drivers/firewire/.kunitconfig b/drivers/firewire/.kunitconfig index 1599e069395f..76444a2d5e12 100644 --- a/drivers/firewire/.kunitconfig +++ b/drivers/firewire/.kunitconfig @@ -2,3 +2,4 @@ CONFIG_KUNIT=3Dy CONFIG_PCI=3Dy CONFIG_FIREWIRE=3Dy CONFIG_FIREWIRE_KUNIT_UAPI_TEST=3Dy +CONFIG_FIREWIRE_KUNIT_DEVICE_ATTRIBUTE_TEST=3Dy diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig index 0a6596b027db..552a39df8cbd 100644 --- a/drivers/firewire/Kconfig +++ b/drivers/firewire/Kconfig @@ -34,6 +34,22 @@ config FIREWIRE_KUNIT_UAPI_TEST For more information on KUnit and unit tests in general, refer to the KUnit documentation in Documentation/dev-tools/kunit/. =20 +config FIREWIRE_KUNIT_DEVICE_ATTRIBUTE_TEST + tristate "KUnit tests for device attributes" if !KUNIT_ALL_TESTS + depends on FIREWIRE && KUNIT + default KUNIT_ALL_TESTS + help + This builds the KUnit tests for device attribute for node and + unit. + + KUnit tests run during boot and output the results to the debug + log in TAP format (https://testanything.org/). Only useful for + kernel devs running KUnit test harness and are not for inclusion + into a production build. + + For more information on KUnit and unit tests in general, refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + config FIREWIRE_OHCI tristate "OHCI-1394 controllers" depends on PCI && FIREWIRE && MMU diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 315a2fe41643..fe1e64df476c 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -1313,3 +1313,7 @@ void fw_node_event(struct fw_card *card, struct fw_no= de *node, int event) break; } } + +#ifdef CONFIG_FIREWIRE_KUNIT_DEVICE_ATTRIBUTE_TEST +#include "device-attribute-test.c" +#endif diff --git a/drivers/firewire/device-attribute-test.c b/drivers/firewire/de= vice-attribute-test.c new file mode 100644 index 000000000000..87cfdf97c898 --- /dev/null +++ b/drivers/firewire/device-attribute-test.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// device-attribute-test.c - An application of Kunit to test implementatio= n for device attributes. +// +// Copyright (c) 2023 Takashi Sakamoto +// +// This file can not be built independently since it is intentionally incl= uded in core-device.c. + +#include + +static struct kunit_case device_attr_test_cases[] =3D { + {} +}; + +static struct kunit_suite device_attr_test_suite =3D { + .name =3D "firewire-device-attribute", + .test_cases =3D device_attr_test_cases, +}; +kunit_test_suite(device_attr_test_suite); --=20 2.39.2 From nobody Fri Dec 19 08:18:28 2025 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (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 7F0CA6D6DB for ; Thu, 21 Dec 2023 13:48:59 +0000 (UTC) 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="aOkLT8HO"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="vuRwiGJJ" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id C1EB65C01C6; Thu, 21 Dec 2023 08:48:58 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 21 Dec 2023 08:48:58 -0500 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=fm2; t=1703166538; x= 1703252938; bh=+JyhqIbPXo2UEHWmNxjsb67UTphTfDWfW8T3FHbJGc8=; b=a OkLT8HOT6saWUEYTMJoBoiA05Vk3PToNiVUlO62CPJWY3KMl/M1e1RKCJ5GrUywD Q6BJgqB8EadsVCvtuiR15IAqyD0DynsUHmwgL0qGA81KKmVDOjd9BLvSujMN8eJA gCqg22XlJKnKOo3iGc3VpLgdeUD+efertJ/7MahCHFMSdWjk3mgfgHYq8EfQPhFP B4dL+Os+cSiZmNToMds3b5wUVHk51SVEHuyUkVg1no7DYeR2fpE+zymAJav0tNw/ XAgAKQ1eOQ+oon39BarmJmWdEB2ntepgr2JZW+9RfumuBqO5DrLjMF2Q5bs5c+GE VvMwnRjszI99/HKDgh0Tw== 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=fm2; t=1703166538; x= 1703252938; bh=+JyhqIbPXo2UEHWmNxjsb67UTphTfDWfW8T3FHbJGc8=; b=v uRwiGJJphym6HWt6l4pGqun/Rq4sdKohTa7NY5h1Vnqw2tKyNzeXacrQeOkxhVRl gV6i0e2S+qCilKTDzx04BnDUhAC3diM1otte4d4SloGxWAtB4Ca75Zn/LtnviJsA VI7y6KkppikcJYXvxSfv3moM37iO9Sx+TBR+m/d+odcdGBtNPINxcgRneaGs5SpD CL/dhYU4wMighlTx0ZNMlZxWqdH3Ez6w9EOW9naqRTW86y8y2XKp9ec3l3ByLIkJ HVplTvGV0hQsJuJnTAZ6EpHnek1pIbpnBYCKADelBTWAvBmEAxMQ1BT55DZBpopC de42qNk8dHm/2e2bXJrkg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduhedgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeffvefhff dugeetkeektdegheejheegteegffeihfevvefggfeuueekvdeffeehfeenucffohhmrghi nhepkhgvrhhnvghlrdhorhhgpdguvghvihgtvgdrughirhgvtghtohhrhienucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhi sehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Dec 2023 08:48:57 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH v2 4/8] firewire: test: add test of device attributes for simple AV/C device Date: Thu, 21 Dec 2023 22:48:45 +0900 Message-Id: <20231221134849.603857-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221134849.603857-1-o-takashi@sakamocchi.jp> References: <20231221134849.603857-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: quoted-printable Content-Type: text/plain; charset="utf-8" At present, core function can handle node which has configuration ROM similar to standard AV/C device somehow. The standard layout of configuration ROM is described in the following document. - Configuration ROM for AV/C Devices 1.0 (Dec. 12, 2000, 1394 Trading Association) This commit adds a KUnit test for the above case. The following output is the parse result for the hard-coded data, by config-rom-pretty-printer in linux-firewire-utils (https://git.kernel.org/pub/scm/utils/ieee1394/linux-firewire-utils.git/). $ config-rom-pretty-printer < /tmp/rom.img ROM header and bus information block ------------------------------------------------------------= ----- 1024 0404eabf bus_info_length 4, crc_length 4, crc 60095 1028 31333934 bus_name "1394" 1032 e0646102 irmc 1, cmc 1, isc 1, bmc 0, cyc_clk_acc 100, max_rec 6 (12= 8) 1036 ffffffff company_id ffffff | 1040 ffffffff device_id 1099511627775 | EUI-64 18446744073709551615 root directory ------------------------------------------------------------= ----- 1044 00063287 directory_length 6, crc 12935 1048 03ffffff vendor 1052 8100000a --> descriptor leaf at 1092 1056 17ffffff model 1060 8100000e --> descriptor leaf at 1116 1064 0c0083c0 node capabilities: per IEEE 1394 1068 d1000001 --> unit directory at 1072 unit directory at 1072 ------------------------------------------------------------= ----- 1072 0004442d directory_length 4, crc 17453 1076 1200a02d specifier id 1080 13010001 version 1084 17ffffff model 1088 81000007 --> descriptor leaf at 1116 descriptor leaf at 1092 ------------------------------------------------------------= ----- 1092 0005c915 leaf_length 5, crc 51477 1096 00000000 textual descriptor 1100 00000000 minimal ASCII 1104 56656e64 "Vend" 1108 6f72204e "or N" 1112 616d6500 "ame" descriptor leaf at 1116 ------------------------------------------------------------= ----- 1116 00057f16 leaf_length 5, crc 32534 1120 00000000 textual descriptor 1124 00000000 minimal ASCII 1128 4d6f6465 "Mode" 1132 6c204e61 "l Na" 1136 6d650000 "me" Signed-off-by: Takashi Sakamoto --- drivers/firewire/device-attribute-test.c | 119 +++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/drivers/firewire/device-attribute-test.c b/drivers/firewire/de= vice-attribute-test.c index 87cfdf97c898..e2c5587d0757 100644 --- a/drivers/firewire/device-attribute-test.c +++ b/drivers/firewire/device-attribute-test.c @@ -8,7 +8,126 @@ =20 #include =20 +// Configuration ROM for AV/C Devices 1.0 (Dec. 12, 2000, 1394 Trading Ass= ociation) +// Annex C:Configuration ROM example(informative) +// C.1 Simple AV/C device +// +// Copied from the documentation. +static const u32 simple_avc_config_rom[] =3D { + 0x0404eabf, + 0x31333934, + 0xe0646102, + 0xffffffff, + 0xffffffff, + 0x00063287, // root directory. + 0x03ffffff, + 0x8100000a, + 0x17ffffff, + 0x8100000e, + 0x0c0083c0, + 0xd1000001, + 0x0004442d, // unit 0 directory. + 0x1200a02d, + 0x13010001, + 0x17ffffff, + 0x81000007, + 0x0005c915, // leaf for textual descriptor. + 0x00000000, + 0x00000000, + 0x56656e64, + 0x6f72204e, + 0x616d6500, + 0x00057f16, // leaf for textual descriptor. + 0x00000000, + 0x00000000, + 0x4d6f6465, + 0x6c204e61, + 0x6d650000, +}; + +static void device_attr_simple_avc(struct kunit *test) +{ + static const struct fw_device node =3D { + .device =3D { + .type =3D &fw_device_type, + }, + .config_rom =3D simple_avc_config_rom, + .config_rom_length =3D sizeof(simple_avc_config_rom), + }; + static const struct fw_unit unit0 =3D { + .device =3D { + .type =3D &fw_unit_type, + .parent =3D (struct device *)&node.device, + }, + .directory =3D &simple_avc_config_rom[12], + }; + struct device *node_dev =3D (struct device *)&node.device; + struct device *unit0_dev =3D (struct device *)&unit0.device; + static const int unit0_expected_ids[] =3D {0x00ffffff, 0x00ffffff, 0x0000= a02d, 0x00010001}; + char *buf =3D kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL); + int ids[4] =3D {0, 0, 0, 0}; + + // Ensure associations for node and unit devices. + + KUNIT_ASSERT_TRUE(test, is_fw_device(node_dev)); + KUNIT_ASSERT_FALSE(test, is_fw_unit(node_dev)); + KUNIT_ASSERT_PTR_EQ(test, fw_device(node_dev), &node); + + KUNIT_ASSERT_FALSE(test, is_fw_device(unit0_dev)); + KUNIT_ASSERT_TRUE(test, is_fw_unit(unit0_dev)); + KUNIT_ASSERT_PTR_EQ(test, fw_parent_device((&unit0)), &node); + KUNIT_ASSERT_PTR_EQ(test, fw_unit(unit0_dev), &unit0); + + // For entries in root directory. + + // Vendor immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(node_dev, &config_rom_attributes[0].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0xffffff\n"); + + // Model immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(node_dev, &config_rom_attributes[4].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0xffffff\n"); + + // Descriptor leaf entry for vendor is found. + KUNIT_EXPECT_GT(test, show_text_leaf(node_dev, &config_rom_attributes[5].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "Vendor Name\n"); + + // Descriptor leaf entry for model is found. + KUNIT_EXPECT_GT(test, show_text_leaf(node_dev, &config_rom_attributes[6].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "Model Name\n"); + + // For entries in unit 0 directory. + + // Vendor immediate entry is not found. + KUNIT_EXPECT_LT(test, show_immediate(unit0_dev, &config_rom_attributes[0]= .attr, buf), 0); + + // Model immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(unit0_dev, &config_rom_attributes[4]= .attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0xffffff\n"); + + // Descriptor leaf entry for vendor is not found. + KUNIT_EXPECT_LT(test, show_text_leaf(unit0_dev, &config_rom_attributes[5]= .attr, buf), 0); + + // Descriptor leaf entry for model is found. + KUNIT_EXPECT_GT(test, show_text_leaf(unit0_dev, &config_rom_attributes[6]= .attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "Model Name\n"); + + // Specifier_ID immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(unit0_dev, &config_rom_attributes[2]= .attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0x00a02d\n"); + + // Version immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(unit0_dev, &config_rom_attributes[3]= .attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0x010001\n"); + + kunit_kfree(test, buf); + + get_modalias_ids(&unit0, ids); + KUNIT_EXPECT_MEMEQ(test, ids, unit0_expected_ids, sizeof(ids)); +} + static struct kunit_case device_attr_test_cases[] =3D { + KUNIT_CASE(device_attr_simple_avc), {} }; =20 --=20 2.39.2 From nobody Fri Dec 19 08:18:28 2025 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (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 3BA9E651BA for ; Thu, 21 Dec 2023 13:49:01 +0000 (UTC) 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="jteC3Olc"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QBJ6jDRJ" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 5160C5C0297; Thu, 21 Dec 2023 08:49:00 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 21 Dec 2023 08:49:00 -0500 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=fm2; t=1703166540; x= 1703252940; bh=3EzlJFfSkML/ta9lyeEKf9o6eumBFTgrZNdRmkxbQEo=; b=j teC3OlcSZp7DWYnmvMUCzJwViMIdUt3B3DUSCxyYV67REqbtnOCO59oXKeRY9eOv 1Rd13daI+weZgSYaGRSJyzAyNzkhek6IO7aeNZtfqZEDUq/yTqJRUSsLv3fsEFzR bkefIBGHZGc2/ucszO2VR79N1zduZqbCIwCYFquIjlu/kFi4nOWNHcG9v+dag3Nn +i+2AuugkFpGE663kN7+wDcYhMYF22uisgPI04IsgRcPkOtK1JDuaXyBN3pQ/o+S Zl3gJpSkH/OuUKq+CVmddr7ecd+u7tG9YNcwpLB2Mft38F3lvAVh7p/hFRsHgWtB UrImDIl2t0rSj/LCj1t3A== 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=fm2; t=1703166540; x= 1703252940; bh=3EzlJFfSkML/ta9lyeEKf9o6eumBFTgrZNdRmkxbQEo=; b=Q BJ6jDRJjAe1xJnUsI6aHfSY728ddOMU1uynIMQ3B7kE91HH1bHOc1P4ub9ayNIY7 xa10ThrpFJz3o1hSPJDpM3avU4bymJD4NFQyvohIae1jEbOOS+NGzb3kt6HJ2/ud /3rnFlDs+xS70YVJ8ONu6Ce/JPKtQ3AsqCAr4oEhAbXVqYAXbkw6m5UdTmdepBAn Vvd6+X5GFEI3qF1MqeDo9WdT7v/cJF9zzQZjtK7VyIZFB0X+R8dom8PJl+KHdEV1 7CIHs8B1RgwG+bov2Y1lS7JLDj9YEJll4puFam9mglmn8rxIEGj7mYjOzL7c4xHC pCluntaoKTDcr6ZC1wxYw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduhedgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeffvefhff dugeetkeektdegheejheegteegffeihfevvefggfeuueekvdeffeehfeenucffohhmrghi nhepkhgvrhhnvghlrdhorhhgpdguvghvihgtvgdrughirhgvtghtohhrhienucevlhhush htvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhi sehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Dec 2023 08:48:58 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH v2 5/8] firewire: test: add test of device attributes for legacy AV/C device Date: Thu, 21 Dec 2023 22:48:46 +0900 Message-Id: <20231221134849.603857-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221134849.603857-1-o-takashi@sakamocchi.jp> References: <20231221134849.603857-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: quoted-printable Content-Type: text/plain; charset="utf-8" Some legacy devices have configuration ROM against standard AV/C device. They have vendor directory to store model identifier. It is described in annex of the following document. - Configuration ROM for AV/C Devices 1.0 (Dec. 12, 2000, 1394 Trading Association) In the case, current implementation of core function does not detect the model identifier, thus device attributes and modalias of unit have lack of it. Another KUnit test is required for the case, and this commit is for the purpose. The following output is the parse result for the hard-coded data, by config-rom-pretty-printer in linux-firewire-utils (https://git.kernel.org/pub/scm/utils/ieee1394/linux-firewire-utils.git/). The data is written by my hand. $ config-rom-pretty-printer < /tmp/rom.img ROM header and bus information block ------------------------------------------------------------= ----- 1024 04199fe7 bus_info_length 4, crc_length 25, crc 40935 1028 31333934 bus_name "1394" 1032 e0644000 irmc 1, cmc 1, isc 1, bmc 0, cyc_clk_acc 100, max_rec 4 (32) 1036 00112233 company_id 001122 | 1040 44556677 device_id 220189779575 | EUI-64 4822678189205111 root directory ------------------------------------------------------------= ----- 1044 0005dace directory_length 5, crc 56014 1048 03012345 vendor 1052 0c0083c0 node capabilities: per IEEE 1394 1056 8d000009 --> eui-64 leaf at 1092 1060 d1000002 --> unit directory at 1068 1064 c3000004 --> vendor directory at 1080 unit directory at 1068 ------------------------------------------------------------= ----- 1068 0002e107 directory_length 2, crc 57607 1072 12abcdef specifier id 1076 13543210 version vendor directory at 1080 ------------------------------------------------------------= ----- 1080 0002cb73 directory_length 2, crc 52083 1084 17fedcba model 1088 81000004 --> descriptor leaf at 1104 eui-64 leaf at 1092 ------------------------------------------------------------= ----- 1092 00026dc1 leaf_length 2, crc 28097 1096 00112233 company_id 001122 | 1100 44556677 device_id 220189779575 | EUI-64 4822678189205111 descriptor leaf at 1104 ------------------------------------------------------------= ----- 1104 00050e84 leaf_length 5, crc 3716 1108 00000000 textual descriptor 1112 00000000 minimal ASCII 1116 41424344 "ABCD" 1120 45464748 "EFGH" 1124 494a0000 "IJ" Signed-off-by: Takashi Sakamoto --- drivers/firewire/device-attribute-test.c | 111 +++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/drivers/firewire/device-attribute-test.c b/drivers/firewire/de= vice-attribute-test.c index e2c5587d0757..495af65c33b5 100644 --- a/drivers/firewire/device-attribute-test.c +++ b/drivers/firewire/device-attribute-test.c @@ -45,6 +45,40 @@ static const u32 simple_avc_config_rom[] =3D { 0x6d650000, }; =20 +// Ibid. +// Annex A:Consideration for configuration ROM reader design (informative) +// A.1 Vendor directory +// +// Written by hand. +static const u32 legacy_avc_config_rom[] =3D { + 0x04199fe7, + 0x31333934, + 0xe0644000, + 0x00112233, + 0x44556677, + 0x0005dace, // root directory. + 0x03012345, + 0x0c0083c0, + 0x8d000009, + 0xd1000002, + 0xc3000004, + 0x0002e107, // unit 0 directory. + 0x12abcdef, + 0x13543210, + 0x0002cb73, // vendor directory. + 0x17fedcba, + 0x81000004, + 0x00026dc1, // leaf for EUI-64. + 0x00112233, + 0x44556677, + 0x00050e84, // leaf for textual descriptor. + 0x00000000, + 0x00000000, + 0x41424344, + 0x45464748, + 0x494a0000, +}; + static void device_attr_simple_avc(struct kunit *test) { static const struct fw_device node =3D { @@ -126,8 +160,85 @@ static void device_attr_simple_avc(struct kunit *test) KUNIT_EXPECT_MEMEQ(test, ids, unit0_expected_ids, sizeof(ids)); } =20 +static void device_attr_legacy_avc(struct kunit *test) +{ + static const struct fw_device node =3D { + .device =3D { + .type =3D &fw_device_type, + }, + .config_rom =3D legacy_avc_config_rom, + .config_rom_length =3D sizeof(legacy_avc_config_rom), + }; + static const struct fw_unit unit0 =3D { + .device =3D { + .type =3D &fw_unit_type, + .parent =3D (struct device *)&node.device, + }, + .directory =3D &legacy_avc_config_rom[11], + }; + struct device *node_dev =3D (struct device *)&node.device; + struct device *unit0_dev =3D (struct device *)&unit0.device; + static const int unit0_expected_ids[] =3D {0x00012345, 0x00000000, 0x00ab= cdef, 0x00543210}; + char *buf =3D kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL); + int ids[4] =3D {0, 0, 0, 0}; + + // Ensure associations for node and unit devices. + + KUNIT_ASSERT_TRUE(test, is_fw_device(node_dev)); + KUNIT_ASSERT_FALSE(test, is_fw_unit(node_dev)); + KUNIT_ASSERT_PTR_EQ(test, fw_device((node_dev)), &node); + + KUNIT_ASSERT_FALSE(test, is_fw_device(unit0_dev)); + KUNIT_ASSERT_TRUE(test, is_fw_unit(unit0_dev)); + KUNIT_ASSERT_PTR_EQ(test, fw_parent_device((&unit0)), &node); + KUNIT_ASSERT_PTR_EQ(test, fw_unit(unit0_dev), &unit0); + + // For entries in root directory. + + // Vendor immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(node_dev, &config_rom_attributes[0].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0x012345\n"); + + // Model immediate entry is not found. + KUNIT_EXPECT_LT(test, show_immediate(node_dev, &config_rom_attributes[4].= attr, buf), 0); + + // Descriptor leaf entry for vendor is not found. + KUNIT_EXPECT_LT(test, show_text_leaf(node_dev, &config_rom_attributes[5].= attr, buf), 0); + + // Descriptor leaf entry for model is not found. + KUNIT_EXPECT_LT(test, show_text_leaf(node_dev, &config_rom_attributes[6].= attr, buf), 0); + + // For entries in unit 0 directory. + + // Vendor immediate entry is not found. + KUNIT_EXPECT_LT(test, show_immediate(unit0_dev, &config_rom_attributes[0]= .attr, buf), 0); + + // Model immediate entry is not found. + KUNIT_EXPECT_LT(test, show_immediate(unit0_dev, &config_rom_attributes[4]= .attr, buf), 0); + + // Descriptor leaf entry for vendor is not found. + KUNIT_EXPECT_LT(test, show_text_leaf(unit0_dev, &config_rom_attributes[5]= .attr, buf), 0); + + // Descriptor leaf entry for model is not found. + KUNIT_EXPECT_LT(test, show_text_leaf(unit0_dev, &config_rom_attributes[6]= .attr, buf), 0); + + // Specifier_ID immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(unit0_dev, &config_rom_attributes[2]= .attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0xabcdef\n"); + + // Version immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(unit0_dev, &config_rom_attributes[3]= .attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0x543210\n"); + + kunit_kfree(test, buf); + + get_modalias_ids(&unit0, ids); + KUNIT_EXPECT_MEMEQ(test, ids, unit0_expected_ids, sizeof(ids)); +} + static struct kunit_case device_attr_test_cases[] =3D { KUNIT_CASE(device_attr_simple_avc), + KUNIT_CASE(device_attr_legacy_avc), {} }; =20 --=20 2.39.2 From nobody Fri Dec 19 08:18:28 2025 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (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 F0437760AF for ; Thu, 21 Dec 2023 13:49:02 +0000 (UTC) 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="QpEWwwjU"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Ku4pvmAk" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id DFA2C5C029C; Thu, 21 Dec 2023 08:49:01 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 21 Dec 2023 08:49:01 -0500 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=fm2; t=1703166541; x= 1703252941; bh=c3+SGtxjfpRsQL1FjnGhoxDOzKY9TE2Qa/7LRiK0mv4=; b=Q pEWwwjUClDCY/mWlyTEgqpG6Wf5JltVWpF8igK0t7Z4LKpcg3imHYwTToEWhd3M7 TsITVqpcN7OpphkT6BPvGZbpeMkCOOUXqJfmoI+uwGdyS4FYCVnfS86WKCONWhTM YSD/Pj4O9oRndtoI38IChTb9CagMRsC6H/W+Pa3OZeUvKL3gfPy8J5emy7Fgw23S I9OFGUVxCThayWyLPf3KxiHqM8YrQIBmpbHsyZZzkJ+35nGPGF2a93BDt1R2zUOb L9lmeHcnARon2pS0KGM/mTYK5QxoYsEYCflsgpFRDA+E3QvznGr8tZ7TDNMBJcEi XQMNfJJJmpKzSfWAzbMnA== 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=fm2; t=1703166541; x= 1703252941; bh=c3+SGtxjfpRsQL1FjnGhoxDOzKY9TE2Qa/7LRiK0mv4=; b=K u4pvmAkydzmWA/OxvIpM6OcpgNLH7BRhnHT6568EL13zTbQmLc6/gHvEROrINTvf /wyV9JYIq2OPPy/xkaGrBUbIypf1gHYem4tTTYPA9pnU+05LUKDpDZkfCTgl7grL WQuJRBamWtrJlF1YqNILHo2yIY7ZFGR9Toy3683+Py53EIUIFZAZBz5w89N/JIQc w03YvFGUpicqF2rOThgrZYSjhkqSaMjQX3hie+SASE1A/4EIg7Q7HYZSEChL8O6o /J03huKfvbHbiWl1//4ILmzwjifcqXMRLSPS+zsp5n2qFCLDaVWuTBixhx6Ccg2A a1RrXpT0/PqdfsQhwB8bQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduhedgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Dec 2023 08:49:00 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH v2 6/8] firewire: core: detect numeric model identifier for legacy layout of configuration ROM Date: Thu, 21 Dec 2023 22:48:47 +0900 Message-Id: <20231221134849.603857-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221134849.603857-1-o-takashi@sakamocchi.jp> References: <20231221134849.603857-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: quoted-printable Content-Type: text/plain; charset="utf-8" As the part of support for legacy layout of configuration ROM, this commit traverses vendor directory as well as root directory when showing device attribute for node device. This change expects 'model' attribute appears in node device, however it is probable to see the other types of immediate values if the vendor directory includes. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 59 ++++++++++++++++++------ drivers/firewire/device-attribute-test.c | 5 +- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index fe1e64df476c..d0ce583b93c4 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -49,6 +49,22 @@ int fw_csr_iterator_next(struct fw_csr_iterator *ci, int= *key, int *value) } EXPORT_SYMBOL(fw_csr_iterator_next); =20 +static const u32 *search_directory(const u32 *directory, int search_key) +{ + struct fw_csr_iterator ci; + int key, value; + + search_key |=3D CSR_DIRECTORY; + + fw_csr_iterator_init(&ci, directory); + while (fw_csr_iterator_next(&ci, &key, &value)) { + if (key =3D=3D search_key) + return ci.p - 1 + value; + } + + return NULL; +} + static const u32 *search_leaf(const u32 *directory, int search_key) { struct fw_csr_iterator ci; @@ -253,27 +269,44 @@ static ssize_t show_immediate(struct device *dev, struct config_rom_attribute *attr =3D container_of(dattr, struct config_rom_attribute, attr); struct fw_csr_iterator ci; - const u32 *dir; - int key, value, ret =3D -ENOENT; + const u32 *directories[] =3D {NULL, NULL}; + int i, value =3D -1; =20 down_read(&fw_device_rwsem); =20 - if (is_fw_unit(dev)) - dir =3D fw_unit(dev)->directory; - else - dir =3D fw_device(dev)->config_rom + ROOT_DIR_OFFSET; + if (is_fw_unit(dev)) { + directories[0] =3D fw_unit(dev)->directory; + } else { + const u32 *root_directory =3D fw_device(dev)->config_rom + ROOT_DIR_OFFS= ET; + const u32 *vendor_directory =3D search_directory(root_directory, CSR_VEN= DOR); =20 - fw_csr_iterator_init(&ci, dir); - while (fw_csr_iterator_next(&ci, &key, &value)) - if (attr->key =3D=3D key) { - ret =3D snprintf(buf, buf ? PAGE_SIZE : 0, - "0x%06x\n", value); - break; + if (!vendor_directory) { + directories[0] =3D root_directory; + } else { + // Legacy layout of configuration ROM described in Annex 1 of + // 'Configuration ROM for AV/C Devices 1.0 (December 12, 2000, 1394 Tra= ding + // Association, TA Document 1999027)'. + directories[0] =3D vendor_directory; + directories[1] =3D root_directory; + } + } + + for (i =3D 0; i < ARRAY_SIZE(directories) && !!directories[i]; ++i) { + int key, val; + + fw_csr_iterator_init(&ci, directories[i]); + while (fw_csr_iterator_next(&ci, &key, &val)) { + if (attr->key =3D=3D key) + value =3D val; } + } =20 up_read(&fw_device_rwsem); =20 - return ret; + if (value < 0) + return -ENOENT; + + return snprintf(buf, buf ? PAGE_SIZE : 0, "0x%06x\n", value); } =20 #define IMMEDIATE_ATTR(name, key) \ diff --git a/drivers/firewire/device-attribute-test.c b/drivers/firewire/de= vice-attribute-test.c index 495af65c33b5..689115433425 100644 --- a/drivers/firewire/device-attribute-test.c +++ b/drivers/firewire/device-attribute-test.c @@ -199,8 +199,9 @@ static void device_attr_legacy_avc(struct kunit *test) KUNIT_EXPECT_GT(test, show_immediate(node_dev, &config_rom_attributes[0].= attr, buf), 0); KUNIT_EXPECT_STREQ(test, buf, "0x012345\n"); =20 - // Model immediate entry is not found. - KUNIT_EXPECT_LT(test, show_immediate(node_dev, &config_rom_attributes[4].= attr, buf), 0); + // Model immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(node_dev, &config_rom_attributes[4].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0xfedcba\n"); =20 // Descriptor leaf entry for vendor is not found. KUNIT_EXPECT_LT(test, show_text_leaf(node_dev, &config_rom_attributes[5].= attr, buf), 0); --=20 2.39.2 From nobody Fri Dec 19 08:18:28 2025 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (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 435897765B for ; Thu, 21 Dec 2023 13:49:03 +0000 (UTC) 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="gn9/+T1z"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nbXav1BG" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 4C9E65C029E; Thu, 21 Dec 2023 08:49:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 21 Dec 2023 08:49:03 -0500 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=fm2; t=1703166543; x= 1703252943; bh=yHE5zsgLceNpgxeFsHAo6tPr0eHvDlNHIX4N5QhXKMY=; b=g n9/+T1zm0r7rE6Wj3SfL8zPH8MMsqPXuA8ftkHIqPT6T0OFnuhh/znjP8H6a0ZcC +BMmB+zsl0VRM+tsmd8H67kbT/O69QWyMkUkJREyXbt2Pe7vAAEELZLYh6vF9oQb 3/d9jRrz8fd49YP4FTFFPyVOvp3LNL5//UQtTE6ZxVEQyh9viAvl7Cp2R8eQsy9g 6+QYe/hG/A4M4QeMYOU7yWtX7ICKyryAd/+GHcvtAK0sL9rDzHl2o8cchAbFARKj Je062iCyzPj8+a8OpdfIo/J8nOCY5FvgyiuBiqVe78pU+9+jPKzU/cxJXsF1GyeL yUsG/zUEMtL1CnSgTjhlQ== 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=fm2; t=1703166543; x= 1703252943; bh=yHE5zsgLceNpgxeFsHAo6tPr0eHvDlNHIX4N5QhXKMY=; b=n bXav1BGEfSrsh2PhdbzbS5sPp2C04K6cvOj+fyfrPHImsvK5bPWFA0ln5oqvjNKJ zYtFeAFBlC3lyJbGLUV2mD4ohwKIu6jaGsvpSlZbhNrn7GclxrY8j9/gWxRXJdtA wBlrLeIENDDG408cjEQWMnNM9F3IeQI9KNfYBtelj5AFV32tPntUGx5PsCwWydKz oNyMBVEYMCaQLpdkVoWOaEhE0pQFkU7ZJ+V7bBf5Ly0fYGv2LcdJFaWXmKP7c81k QuqNkqVqpJOdRqr4DGCEmGeM+WeKnV4cD9gQbQyD6dpkDr2WjhC/eL1ganptIrRk 7JU59jmz918sWTIwZ/BjQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduhedgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Dec 2023 08:49:02 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH v2 7/8] firewire: core: detect model name for legacy layout of configuration ROM Date: Thu, 21 Dec 2023 22:48:48 +0900 Message-Id: <20231221134849.603857-8-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221134849.603857-1-o-takashi@sakamocchi.jp> References: <20231221134849.603857-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: quoted-printable Content-Type: text/plain; charset="utf-8" As the part of support for legacy layout of configuration ROM, this commit traverses vendor directory as well as root directory when showing device attribute for node device. This change expects 'model_name' attribute appears in node device, however it is probable to see the other types of descriptor leaf if the vendor directory includes. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 31 ++++++++++++++++++------ drivers/firewire/device-attribute-test.c | 5 ++-- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index d0ce583b93c4..029ba0ff7083 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -317,17 +317,29 @@ static ssize_t show_text_leaf(struct device *dev, { struct config_rom_attribute *attr =3D container_of(dattr, struct config_rom_attribute, attr); - const u32 *dir; + const u32 *directories[] =3D {NULL, NULL}; size_t bufsize; char dummy_buf[2]; - int ret; + int i, ret =3D -ENOENT; =20 down_read(&fw_device_rwsem); =20 - if (is_fw_unit(dev)) - dir =3D fw_unit(dev)->directory; - else - dir =3D fw_device(dev)->config_rom + ROOT_DIR_OFFSET; + if (is_fw_unit(dev)) { + directories[0] =3D fw_unit(dev)->directory; + } else { + const u32 *root_directory =3D fw_device(dev)->config_rom + ROOT_DIR_OFFS= ET; + const u32 *vendor_directory =3D search_directory(root_directory, CSR_VEN= DOR); + + if (!vendor_directory) { + directories[0] =3D root_directory; + } else { + // Legacy layout of configuration ROM described in Annex 1 of + // 'Configuration ROM for AV/C Devices 1.0 (December 12, 2000, 1394 + // Trading Association, TA Document 1999027)'. + directories[0] =3D root_directory; + directories[1] =3D vendor_directory; + } + } =20 if (buf) { bufsize =3D PAGE_SIZE - 1; @@ -336,7 +348,12 @@ static ssize_t show_text_leaf(struct device *dev, bufsize =3D 1; } =20 - ret =3D fw_csr_string(dir, attr->key, buf, bufsize); + for (i =3D 0; i < ARRAY_SIZE(directories) && !!directories[i]; ++i) { + int result =3D fw_csr_string(directories[i], attr->key, buf, bufsize); + // Detected. + if (result >=3D 0) + ret =3D result; + } =20 if (ret >=3D 0) { /* Strip trailing whitespace and add newline. */ diff --git a/drivers/firewire/device-attribute-test.c b/drivers/firewire/de= vice-attribute-test.c index 689115433425..da2a4a09bf84 100644 --- a/drivers/firewire/device-attribute-test.c +++ b/drivers/firewire/device-attribute-test.c @@ -206,8 +206,9 @@ static void device_attr_legacy_avc(struct kunit *test) // Descriptor leaf entry for vendor is not found. KUNIT_EXPECT_LT(test, show_text_leaf(node_dev, &config_rom_attributes[5].= attr, buf), 0); =20 - // Descriptor leaf entry for model is not found. - KUNIT_EXPECT_LT(test, show_text_leaf(node_dev, &config_rom_attributes[6].= attr, buf), 0); + // Descriptor leaf entry for model is found. + KUNIT_EXPECT_GT(test, show_text_leaf(node_dev, &config_rom_attributes[6].= attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "ABCDEFGHIJ\n"); =20 // For entries in unit 0 directory. =20 --=20 2.39.2 From nobody Fri Dec 19 08:18:28 2025 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (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 CE64B77F0D for ; Thu, 21 Dec 2023 13:49:05 +0000 (UTC) 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="RUZiik/+"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="cgD2IAt6" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id D11055C0245; Thu, 21 Dec 2023 08:49:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 21 Dec 2023 08:49:04 -0500 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=fm2; t=1703166544; x= 1703252944; bh=W8++sea8gpKHCOGyelCyTGYcLj9Ir33YrV0oYJ5xXSE=; b=R UZiik/+ck8ZzHIB7lL6s21SNYE+Ngd+LozderYS/PIpndT4Toj5lx6jIWExBXw6I 1gp4PXOFkXTAn/ZKeMZM56exWQaXTh3OPBKw3r/NlGJqB3KPHtgNGH8EXL84wUkd 5JmEdRkL2BAY+ceAk92FQXDC+4Gc1qMhqbFMqE6eSXa5Lbn0NTckb5e1Ty7Szvxf 6VzVSO7KjmNEmIuHjY4Kkbv2It9XZUmaugEvfL7ehyS/i5W49xcUiozEtg+yafqg vNInN8l8o0D6c1h2ePTOtPY3EYI6siRLp7Y2bMTmF5L6id2tQTmxKZmq+pF3jkNg ntiUFvfzg7uZBI6k2wxrA== 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=fm2; t=1703166544; x= 1703252944; bh=W8++sea8gpKHCOGyelCyTGYcLj9Ir33YrV0oYJ5xXSE=; b=c gD2IAt6c6aWChOdUR0j84/+MaaKxq/URdhAfpe7raKyD9zzFhcmZiR3CrTI7NrUJ d2AXmpsmXfR7YV5MgWUNY2u/rJwmN2sYM/cbsdDJ1VbLnqDFx9udTEIdZk4maSHq gIpdg9yFwOecJHo95kgcPVELLRr8aD7d+fFQV9aM2/FbRI2VghojS3R8lrl71wR1 frXnSggDSKe/83GC4gE8wR7AiYrACmVVQ9f7Bw/7eBH6snrhDUFBhn1fx9aQdjUS zE7OYbjZI00Yo1Ybf1Y2ZCJa86WKjfku07xCWeY903Vu3G/SEebH2A/3Z13S/FyJ F3P1Ys8mCCX2lHP4N12ig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduhedgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Dec 2023 08:49:03 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH v2 8/8] firewire: core: change modalias of unit device with backward incompatibility Date: Thu, 21 Dec 2023 22:48:49 +0900 Message-Id: <20231221134849.603857-9-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221134849.603857-1-o-takashi@sakamocchi.jp> References: <20231221134849.603857-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: quoted-printable Content-Type: text/plain; charset="utf-8" As the last part of support for legacy layout of configuration ROM, this commit traverses vendor directory as well as root directory when constructing modalias for unit device. The change brings loss of backward compatibility since it can fill model field ('mo') which is 0 at current implementation in the case. However, we can be optimistic against regression for unit drivers in kernel, due to some points: 1. ALSA drivers for audio and music units use the model fields to match device, however all of supported devices does not have such legacy layout. 2. the other unit drivers (e.g. sbp2) does not use the model field to match device. The rest of concern is user space application. The most of applications just take care of node device and does not use the modalias of unit device, thus the change does not affect to them. But systemd project is known to get affects from the change since it includes hwdb to take udev to configure fw character device conveniently. I have a plan to work for systemd so that the access permission of character device could be kept across the change. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 21 +++++++++++++++++++-- drivers/firewire/device-attribute-test.c | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 029ba0ff7083..829b3d590ccd 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -153,8 +153,25 @@ static void get_ids(const u32 *directory, int *id) =20 static void get_modalias_ids(const struct fw_unit *unit, int *id) { - get_ids(&fw_parent_device(unit)->config_rom[ROOT_DIR_OFFSET], id); - get_ids(unit->directory, id); + const u32 *root_directory =3D &fw_parent_device(unit)->config_rom[ROOT_DI= R_OFFSET]; + const u32 *directories[] =3D {NULL, NULL, NULL}; + const u32 *vendor_directory; + int i; + + directories[0] =3D root_directory; + + // Legacy layout of configuration ROM described in Annex 1 of 'Configurat= ion ROM for AV/C + // Devices 1.0 (December 12, 2000, 1394 Trading Association, TA Document = 1999027)'. + vendor_directory =3D search_directory(root_directory, CSR_VENDOR); + if (!vendor_directory) { + directories[1] =3D unit->directory; + } else { + directories[1] =3D vendor_directory; + directories[2] =3D unit->directory; + } + + for (i =3D 0; i < ARRAY_SIZE(directories) && !!directories[i]; ++i) + get_ids(directories[i], id); } =20 static bool match_ids(const struct ieee1394_device_id *id_table, int *id) diff --git a/drivers/firewire/device-attribute-test.c b/drivers/firewire/de= vice-attribute-test.c index da2a4a09bf84..2f123c6b0a16 100644 --- a/drivers/firewire/device-attribute-test.c +++ b/drivers/firewire/device-attribute-test.c @@ -178,7 +178,7 @@ static void device_attr_legacy_avc(struct kunit *test) }; struct device *node_dev =3D (struct device *)&node.device; struct device *unit0_dev =3D (struct device *)&unit0.device; - static const int unit0_expected_ids[] =3D {0x00012345, 0x00000000, 0x00ab= cdef, 0x00543210}; + static const int unit0_expected_ids[] =3D {0x00012345, 0x00fedcba, 0x00ab= cdef, 0x00543210}; char *buf =3D kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL); int ids[4] =3D {0, 0, 0, 0}; =20 --=20 2.39.2