Received: by 2002:a05:7412:8d08:b0:f9:2d0a:d759 with SMTP id bj8csp68129rdb; Sun, 17 Dec 2023 02:32:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFE7p1Hvg7ckpFA0/AqLWyBOy04MJz82mNSVaAWv1mWY8iOMjru4PBppavGR9YITNrPcvS4 X-Received: by 2002:a05:6214:20a6:b0:67a:1d4d:2c0c with SMTP id 6-20020a05621420a600b0067a1d4d2c0cmr24673463qvd.24.1702809146278; Sun, 17 Dec 2023 02:32:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702809146; cv=none; d=google.com; s=arc-20160816; b=O454Ocmf0kAwAvc64hNxmlIxyu+N0uaEZRqjAQks+7SGJ1kDoZKU/6FYu6SiEmTfv5 e3zfchAKbZHN7KPkO53YAAGYUIZ1rsmgcvg6zLvue6cKTXcdr+EVYEfPIXrZoqjAEk9b Ii/MCr6C/EnKPO9towEAAr8Pue+zXwEn2YnP/mgnF8RrWg+75jRUcprNwuNMCU02cNu8 Tkn5A0hqf8qno6hoaJA9yru7AMLIlah0dfP+qFriBiZ9Dje2Ta8zddLXQ5j6y7L7ly56 cj47wVA8bZ1+mIwv289LIxREBxVKz0m5o5G8cLXuczsm8JG4uT/ohHevA7gWFGFSXxq4 m9IQ== ARC-Message-Signature: i=1; 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=z73jY6BHHBYZhY9lJ5vLyunAPVGK9kE6VxjU8LqOq38=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=jAEEJxzSOMZx6Jg63PGi03w3flHJKWepWUR7ddQgbtHny9PZTKxV8Gu+N6ktddiquB WeU5yw6ruPSbmZZzUAh+O1Zl3QfbfAnc8R7y2SaBoCtvgZkkKIPl0VHeRqBIw2Cpa/C5 nkzL/g2JhSce5qII/O0HimkaNNNJqb9MzISpJOgn+mRuzwJtaR5tFR9U9hMsAz+KHZ+M /eLRrk18dNN0qjg6tFUBOEl+1zGoL5ifDb4CxqkMnnqQ4xjIPvYCbgFgPYe669ZCXY59 zYvmEW/bopQijA8NtIb2IyxjnajsIw5873jzO+XIMq5MR8u6sZ+1bioyQSC1qlqVCsCd WZig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=QxVvzmHN; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=rIq1W5qf; spf=pass (google.com: domain of linux-kernel+bounces-2532-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2532-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g3-20020a05620a40c300b00775787784bfsi23013101qko.67.2023.12.17.02.32.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 02:32:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2532-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=QxVvzmHN; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=rIq1W5qf; spf=pass (google.com: domain of linux-kernel+bounces-2532-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2532-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0E6C91C21176 for ; Sun, 17 Dec 2023 10:32:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4FB611CBF; Sun, 17 Dec 2023 10:30:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="QxVvzmHN"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="rIq1W5qf" X-Original-To: linux-kernel@vger.kernel.org Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 324B310974 for ; Sun, 17 Dec 2023 10:30:28 +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 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 4CBB55C0126; Sun, 17 Dec 2023 05:30:28 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 17 Dec 2023 05:30:28 -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=1702809028; x= 1702895428; bh=z73jY6BHHBYZhY9lJ5vLyunAPVGK9kE6VxjU8LqOq38=; b=Q xVvzmHNtLvMdgHrGxjwkBlFWXsuhhYJZaIIFCaKiGA/TzDXFuymTP2S+TDIKVNzz vPVa+UR4Ey13PcFMasMPcvpggQDTI33dlZfhQ0xVC8vsYlcQnF11gxVNTZUCiIyG 7KmHgE3cu52fn0rl8M/7th2ESS4oOJgrjyakhb1naFZKD9Fuor868jUJTxRTaNQ2 MYtwfXl3jmAe3xJ3vrtnDGfdx/yDkb1Y7PJhKJI1sCJWR+T63Gin9LplhXW8jzBH wPyI/eKYTT4xzkxDQOdmq/MwwmojxzCUDVybBCkz7x+94MC5tRWcTLx4K4J0DL9d dgpUZfYXy6/wWAA0tthxA== 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=1702809028; x= 1702895428; bh=z73jY6BHHBYZhY9lJ5vLyunAPVGK9kE6VxjU8LqOq38=; b=r Iq1W5qfdH6+UiUFI6R6DIKEGU/rj7RiVJTS54GjkUqBl/rk9gsj3rBGqNJspMuVQ LJgHTfX23ssDoh/H9C+zpNsRDN4l49ncGyDNRInA/AcTIbsnf6aiM5BFZTJUjKWT iwOHEbv52l+k3Z2Qz95eovnI9DkwVyN82Nw+JK4MsD+yDA/PibvBymA/LKMYq5BK Vg1fdjZc4PJrMSGrbA/ylZZNu/rCibyx7lyPJN3PW0JcEfmLZ5kLB848qJIk9Kzn CMc3LAkmU8dTpOLAu5DacPCYS5yAvL1+aVtbxAdQdqqXzeMR6BMOVQ0aar5LwD9J Zp27HMvM6fKt+7TfYxdyw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:26 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 7/8] firewire: core: detect model name for legacy layout of configuration ROM Date: Sun, 17 Dec 2023 19:30:10 +0900 Message-Id: <20231217103012.41273-8-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231217103012.41273-1-o-takashi@sakamocchi.jp> References: <20231217103012.41273-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 As the part of support for legacy layout of configuration ROM, this commit traverse 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 | 23 ++++++++++++++++------- drivers/firewire/csr-api-test.c | 5 +++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index dad5c9937b78..f7a11004f972 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -315,17 +315,25 @@ static ssize_t show_text_leaf(struct device *dev, { struct config_rom_attribute *attr = container_of(dattr, struct config_rom_attribute, attr); - const u32 *dir; + const u32 *directories[] = {NULL, NULL}; size_t bufsize; char dummy_buf[2]; - int ret; + int i, ret; down_read(&fw_device_rwsem); - if (is_fw_unit(dev)) - dir = fw_unit(dev)->directory; - else - dir = fw_device(dev)->config_rom + ROOT_DIR_OFFSET; + if (is_fw_unit(dev)) { + directories[0] = fw_unit(dev)->directory; + } else { + const u32 *root_directory = fw_device(dev)->config_rom + ROOT_DIR_OFFSET; + + directories[0] = root_directory; + + // 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[1] = search_directory(root_directory, CSR_VENDOR); + } if (buf) { bufsize = PAGE_SIZE - 1; @@ -334,7 +342,8 @@ static ssize_t show_text_leaf(struct device *dev, bufsize = 1; } - ret = fw_csr_string(dir, attr->key, buf, bufsize); + for (i = 0; i < ARRAY_SIZE(directories) && directories[i]; ++i) + ret = fw_csr_string(directories[i], attr->key, buf, bufsize); if (ret >= 0) { /* Strip trailing whitespace and add newline. */ diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-test.c index 7278e7b927a8..779146d0cfba 100644 --- a/drivers/firewire/csr-api-test.c +++ b/drivers/firewire/csr-api-test.c @@ -206,8 +206,9 @@ static void csr_api_legacy_avc_device(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); - // 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"); // For entries in unit 0 directory. -- 2.39.2