From patchwork Sun Dec 17 10:30:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 179979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp639921dyi; Sun, 17 Dec 2023 02:31:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxrrgDKT34e+gpGuPNALNvNYM3qZZpgwYugbc4Zrp1voTkjNwYpHNLIkgU3ZCO8Q8PdGn3 X-Received: by 2002:a05:6e02:1649:b0:35d:59a2:2b2 with SMTP id v9-20020a056e02164900b0035d59a202b2mr23630366ilu.82.1702809099691; Sun, 17 Dec 2023 02:31:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702809099; cv=none; d=google.com; s=arc-20160816; b=pLQoxcNRXRt3D/5PE6x+bBW1xuUznNbbfMWy6gjbIT0vTc+Rivn4RBZqhIpEvg2WMd wd6g+PqP5Lv4hMff2E1GUFmutJIki0D9iPZm8xpjfZhITQ+TF1L0tZN8A5snQ5d/QH+P 8xDtFAuBuSjsViMxyjz4ML1m4KiWnDOvSk7cnOLeQXC72sGo0GUlgqiwHYzohZF5leQt KfhVZDYMkS+ST3Ceu9dLq4YE/qu00Af91MeU4NPapD1vTdLZzSEe/RU5xd/27CsJ1ODM xVGJ3hdCiZknNL8irEhwVS/qCbVzuJUb/eXRUaJvDbTTeJAHKIWbtp3MwaQMR1At2jVA oA7w== 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=1pTTxU/VbzAm0lsOewvACvD5yOw657Fm5X2fzaBqO2I=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=Pc93eAd8JIgqe8jCVs/0dvsmHwLuTvSltboQpCaBdAGgZJAOajwckSUZxvVhq7rsfx c0aw/qcRr5JV4xj+nZVghKZonJVYnSPV7eWn8dzRqNwAJh6I/dsFZuA+xYUQqQs73lu4 p3GisbLoedRpENRF9ZDw+QEbLKM7+gZI2g81uhOOT3JETlZl1lgWHIoYnDGY7Rfujivm yfdhmlEoOic6Y90YERs+j7kFGbNkV4/BzM4AB0yKBwpoZw9l/Yujw66zf38LOghveFYv bL2TkLiHeZwOU7BxcMJdZPrsJFL+07YtLcoDAEvFPv0iXN1YWukV5xNckO+kBn2gdXfx SdEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=svQuyeIP; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=GcoZR86Y; spf=pass (google.com: domain of linux-kernel+bounces-2526-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2526-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 4-20020a631544000000b005ac2af99d30si16045763pgv.705.2023.12.17.02.31.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 02:31:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2526-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=svQuyeIP; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=GcoZR86Y; spf=pass (google.com: domain of linux-kernel+bounces-2526-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2526-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 37039B2218E for ; Sun, 17 Dec 2023 10:31:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 662C2F9EE; Sun, 17 Dec 2023 10:30:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="svQuyeIP"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="GcoZR86Y" 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 22FAE63DA for ; Sun, 17 Dec 2023 10:30:19 +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 E569F5C00C7; Sun, 17 Dec 2023 05:30:18 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 17 Dec 2023 05:30:18 -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=1702809018; x= 1702895418; bh=1pTTxU/VbzAm0lsOewvACvD5yOw657Fm5X2fzaBqO2I=; b=s vQuyeIPK92jI1h59xHID4x1M1mY9Jc9uN0hTwfyXRUs9hkZgsDQVl7oA/tkOjAKA sxrTf4XLGx685gMpiAhLuzex0rCYuZX7VLq5hSnZzEfVmS08XfqjYQHS/hLg2Vm7 zISRUal77Dkt8EWpYbv7vdXTcOiqfalyXJytI+Wc79QcE1LK9gJUa+3NJg6DzXPG IDiuZ8MX3h2O+gCGr2nKou3fkfgwmiwJyLEWvxSWO7PIXBeUZMmXs7LoX94OCRN+ GIqp+tHB8l4Rq1FLwEL7yEtruY3K+S3a2fNlop2qQ0HLtjK0mACpszPPrU7MlG4e jBf/Y+mpKmzf/qaAQOatg== 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=1702809018; x= 1702895418; bh=1pTTxU/VbzAm0lsOewvACvD5yOw657Fm5X2fzaBqO2I=; b=G coZR86YNxYWIDNJxbKMR78//htusgLWPBhH6Iyg+Mgmiewk/fie4rsvi6EzOalW1 e+agUOJdeRXHoLQI9oclEVAzDmsxcc9g77+WbdQfj2vK6PcINGXVNFpeEarGRJmT 9TZID/PR++LQXVDbWlQqoYq2M/xp06aKbRmyrKvqDX5zJ0eXvAOtLI26FSyNj4M1 4qln2tEtaou5MCTD7tcVvzpBUZem0icJvXX4pyxT7rv3pCC3U6jMtFfwWJi4Rd1m Nnoeln/N1M5oPf8JWmh4AL535/mLXExobh7sFXoEqS2pkbQYs41qgycjoGhfEcBa WF0htMEfEZNzAHGMyaEdg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:17 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 1/8] firewire: core: adds constant qualifier for local helper functions Date: Sun, 17 Dec 2023 19:30:04 +0900 Message-Id: <20231217103012.41273-2-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785524754594870941 X-GMAIL-MSGID: 1785524754594870941 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 aa597cda0d88..16c32cb38f0f 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(struct device *dev, return NULL; } -static bool is_fw_unit(struct device *dev); +static bool is_fw_unit(const struct device *dev); static int fw_unit_match(struct device *dev, struct device_driver *drv) { @@ -679,7 +679,7 @@ static struct device_type fw_unit_type = { .release = fw_unit_release, }; -static bool is_fw_unit(struct device *dev) +static bool is_fw_unit(const struct device *dev) { return dev->type == &fw_unit_type; } @@ -838,7 +838,7 @@ static struct device_type fw_device_type = { .release = fw_device_release, }; -static bool is_fw_device(struct device *dev) +static bool is_fw_device(const struct device *dev) { return dev->type == &fw_device_type; } From patchwork Sun Dec 17 10:30:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 179981 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp640001dyi; Sun, 17 Dec 2023 02:31:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUaWshiSPzFh5tjQAms4/l7Cv7OAjll8ADdT3wtycgmiISFhGtH6vC/gfpAq5cczgckIil X-Received: by 2002:a05:6870:638b:b0:203:38e3:f890 with SMTP id t11-20020a056870638b00b0020338e3f890mr7937732oap.1.1702809116784; Sun, 17 Dec 2023 02:31:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702809116; cv=none; d=google.com; s=arc-20160816; b=tccNv/V/Dvq30paBwvH4gdfSiCiY70ACXR2jHVqG7Fv3JZ/4JRVnox4La+0XvmHXho ZAuK9UW738bW5sXyzB1dikYpwKm7gtfuB1+ATEw/ScwlUQ9XxX1NxzY/PhXSSA65pJvr k2VXTl7190s3c3Rd8E3ygwjQhLDmhWgVpEJ1cVdxhwm4l3fDb5rgqCmjroRJvXdd9wWm YQBrieWkpGmb/ZxtM2OTY0gnd36u6CniH6Fqx/QIaZwu+HgdMLF+yg6lUWHwt+ZWBFM1 EkI4XckRKjbOH2kLw9rIByUMJlKwaXw0JvFjjcQ+Vg7MRcsM/hMLrCC9IAOynKWyzomS /7Dg== 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=/6Ta9woOfTDpfu4hjdamNnLTts8ODMKhVhLZw/OsZHE=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=Lha3q9CVnqbA7wL+lviV9Fm1jyIg/jFEfhMgrFJSHa9oR3wiDhfcN8njRIJFaKKaU1 bB0p6q5GhOa9XJZh0pXAV++jx+2d4+LuuDd+CtZE3vcREIBrd5LSKOYLcS9+CvvYu0W6 8bniL3g7/YhaYadB5GG+FH6JxHBJxmYdeGpzTQupP+OTMNrElqoegANr5l9dq/LJ7KtU 4lV4dRexEaxQOCltU+GuyNA4l/cqbX/yCyd76emBrgju50nUjAYdulY45cIWNtXi5mCr /V3kXrSNX/SFPge3RjycFPKgzMT5IXUgqMO9nMGNuY8uOIdrS5AayyvpZ/i0SHtCJjIA 0Uug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=udElJpNm; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=0iS9cBa2; spf=pass (google.com: domain of linux-kernel+bounces-2527-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2527-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z4-20020a656644000000b005c1faa82c06si15683806pgv.470.2023.12.17.02.31.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 02:31:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2527-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=udElJpNm; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=0iS9cBa2; spf=pass (google.com: domain of linux-kernel+bounces-2527-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2527-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 11F28B2219B for ; Sun, 17 Dec 2023 10:31:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 323DD7483; Sun, 17 Dec 2023 10:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="udElJpNm"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="0iS9cBa2" 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 AF2E2613C for ; Sun, 17 Dec 2023 10:30:21 +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 compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id 83F015C0113; Sun, 17 Dec 2023 05:30:20 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sun, 17 Dec 2023 05:30:20 -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=1702809020; x= 1702895420; bh=/6Ta9woOfTDpfu4hjdamNnLTts8ODMKhVhLZw/OsZHE=; b=u dElJpNmM8IX4CREWPjR1PnG8MwDSKDRHAVTZrKhneacCnqx+wKR/qZqdl+JoBY5C nJA8uoI+3jxPH+rJht0btFRsEz5/DutSaYyXc/G739V3sQtqOa0s/a/wvDfclrGr L4uzK3Zefs9hZysyXzwfDMloUVQgxakrFq6NkPWLThL0m3hjfdWDm5pQmwzRoZFL TrtcYg7rqP09g7UiQdQ41oxkzu2KSVb9cUg+Oh/FTNZtbaPcb+CtgRxoLC6XjgAr QsNuYq8UgAvS/a7tIoBqUcesbo+v2Ns/aVtQ+b9YmoYr5abr5O9g1Vv56uoswlPl 158mjO6lsRK8VSDjUz/cA== 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=1702809020; x= 1702895420; bh=/6Ta9woOfTDpfu4hjdamNnLTts8ODMKhVhLZw/OsZHE=; b=0 iS9cBa2rjrrEO2hdjyh2xoBiMgmTZSLtPXEhg4/HDC5Fq3vXbQm5PIJlHS+XL5B1 x//TzfsE+P17ep6LzDmddcNm50cIwZsqWqzlXJRrd1oF1GbYLfFSU9m47YlpGsVN grQMOcp9umLrx9K2RDcN+W587+WpcT1ItRYbYNuSMVwQNW9gfJTQvhE+spMAMfW/ wDQBpLL3euQFDxc4OJS+qgs8YcCLymq0bSW6AgIqf2wtVyofSkWYiNQnmuPRCxOu DVUhSj91sYTb9zRXuWDjNVgcFVaxNhsapciEIpgqQE6YxbzyNDdIoYAtbg6UhN6g y3ko9UNv4buPzrKMj0F7w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:19 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 2/8] firewire: core: replace magic number with macro Date: Sun, 17 Dec 2023 19:30:05 +0900 Message-Id: <20231217103012.41273-3-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785524772585972576 X-GMAIL-MSGID: 1785524772585972576 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 16c32cb38f0f..137001f8a695 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -31,6 +31,8 @@ #include "core.h" +#define ROOT_DIR_OFFSET 5 + void fw_csr_iterator_init(struct fw_csr_iterator *ci, const u32 *p) { ci->p = p + 1; @@ -135,7 +137,7 @@ static void get_ids(const u32 *directory, int *id) 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); } @@ -259,7 +261,7 @@ static ssize_t show_immediate(struct device *dev, if (is_fw_unit(dev)) dir = fw_unit(dev)->directory; else - dir = fw_device(dev)->config_rom + 5; + dir = fw_device(dev)->config_rom + ROOT_DIR_OFFSET; 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 = fw_unit(dev)->directory; else - dir = fw_device(dev)->config_rom + 5; + dir = fw_device(dev)->config_rom + ROOT_DIR_OFFSET; if (buf) { bufsize = PAGE_SIZE - 1; @@ -446,7 +448,7 @@ static ssize_t units_show(struct device *dev, int key, value, i = 0; 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 != (CSR_UNIT | CSR_DIRECTORY)) continue; @@ -691,7 +693,7 @@ static void create_units(struct fw_device *device) int key, value, i; i = 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 != (CSR_UNIT | CSR_DIRECTORY)) continue; From patchwork Sun Dec 17 10:30:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 179980 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp639943dyi; Sun, 17 Dec 2023 02:31:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3SxgroGWTkpENIu8TZHZRuAz+tdyL9L1eI/k6/lKZgUjO4L6yCJRXlzomB+6cT7nX9P5Q X-Received: by 2002:a05:622a:148a:b0:425:4043:1d81 with SMTP id t10-20020a05622a148a00b0042540431d81mr19249082qtx.84.1702809106037; Sun, 17 Dec 2023 02:31:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702809106; cv=none; d=google.com; s=arc-20160816; b=UMRw/l6UHLWiMGGuGVdpAuZudBy5ESFRk4w6bGyhc/ZVFI69D4ZcFJ1lLeFubafSzI lVxT7Tz7lN+/e72E4ZgOSusdmIqLx8t0/UWbDkTdLDcN7jJhxUt853xVRo9KBIzq8JIN AfS5NYxNtg/WlKXPyZGfzpZ3KlwbwyZD6zVUjn+9HxdfPeYyA1YpYmp4lr4CvBfmfZnd TPEPmrJG0TxkwDDBhSwZCmDj9kVaXTsklXySSbpVyx6b17ehQCLDdbKVm8kkIc3Xsm8N xBS0DKIE/kw3O2w2VeVXInUZHBiWWhZ8kiSlhihsO+p23GrzbwK7d9N2vX9Q12FHEu0A s6gg== 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=zuT1CkGiLdT6oVSTIHR17WNH4PptubpxnOyzoYj857U=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=YQTLT+/wpa6j0DdwD4gAiGl1mOBHW3/5/lR7pm0RTyhdFFWpNlXRx6cH8JAOOnL6Bh IeZUDXAaBmQjtOdTTRFiMWai3UFohwsV+k80skkmRYJVvSN6bTmr1FzNP+5zCEzTVxej 7wQ1+kQuMMF3MP2ZplBGO4afeDCU7qM/DZfeZd7Lgoib2OohRCdrZl6nF73WgDv4rmM0 1wxPqwrE6mfgTuzgZulk0K2MgLT0+IV+APel19+5vi5mSxIjUJdav/NWdzcGLSQFyDkp NIPxP+oa1uXhQdIeeLv2950u1IZsvDNJ0SmQ/8Ajd/GFWa4+TlKy/IaQYVeOIGCbTIX5 LgEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=WBo7FkL2; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=jkJryLQ0; spf=pass (google.com: domain of linux-kernel+bounces-2528-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2528-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ca17-20020a05622a1f1100b004238e29de8asi22792057qtb.557.2023.12.17.02.31.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 02:31:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2528-ouuuleilei=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=WBo7FkL2; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=jkJryLQ0; spf=pass (google.com: domain of linux-kernel+bounces-2528-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2528-ouuuleilei=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 C3A2D1C2106D for ; Sun, 17 Dec 2023 10:31:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC6A11096C; Sun, 17 Dec 2023 10:30:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="WBo7FkL2"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="jkJryLQ0" 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 0B3976FBB for ; Sun, 17 Dec 2023 10:30:22 +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 16B1F5C011D; Sun, 17 Dec 2023 05:30:22 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 17 Dec 2023 05:30:22 -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=1702809022; x= 1702895422; bh=zuT1CkGiLdT6oVSTIHR17WNH4PptubpxnOyzoYj857U=; b=W Bo7FkL2AwPXvHa40KrLdpILElFQK7ysX5Rdd9C+ESvBqiQH0UM1VRVNmlfbPYT+r V2rMkimslZnvyUC2FSuXbBV6J+UggE3/Tw6VSN7z2KUera1x63QbT1x/MT7NWA1U +VSADRs8M1sR40ezaePmu2xGXsS3JfTduykhMZ+6FJbO4K06GxLREb2K3dtCC8sw frB11UCPtc296UaFJ0qkRrW45/kYT3xqhYp6d1b2JITIOf3KYPOvvp4yYfi7xXXV epdjiYHxBWml0eJeyX5vWlo+B3Jc/SgUCSf2UqaV1jjeh84JF6BO/hwQWCZbXNvc LcO6pheSLyrIzZZgIG2oQ== 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=1702809022; x= 1702895422; bh=zuT1CkGiLdT6oVSTIHR17WNH4PptubpxnOyzoYj857U=; b=j kJryLQ0fhJvwgnsAkGHT8zFdqlgWmpOozHDyK5JIeC1YOrGOfmi1KnRhGp8AMXRP U8hLKw+TIayJYkYCaspdZl0XR31wl+Z91TUf7COrbnSfCcovfcqHZSAaSVQcg3qt Va2FFmPJUCD3A+GbrShHMdgU3GGbmqaMcHb0TdDkUpiEju9uBRTuOgkZ3WnA4sN1 LCIUMiaethl7HL1S3fZ7ll+3qxLgvnLmpr+VOVS5I/GdkvY7i0i05d6jazN5ylUI dseAo6fbbL1pgQu2QohhUy0jJDkNMSiRK/R0IwYyOt4HPP9znOavhEvV08edbZuK +HheYbfvtbxB9vwBI8CBQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeeugfevtd efhfeffeeuudduhfekhffgveejfeeiiefftdethfduudevjeekveffleenucffohhmrghi nhepthgvshhtrghnhihthhhinhhgrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhi rdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:20 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 3/8] firewire: test: add KUnit test for internal CSR API Date: Sun, 17 Dec 2023 19:30:06 +0900 Message-Id: <20231217103012.41273-4-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785524761533665471 X-GMAIL-MSGID: 1785524761533665471 The operation over CSR space is important since it is related to detection of nodes and units, addition of system devices. Any test of the operation is enough 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/csr-api-test.c | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 drivers/firewire/csr-api-test.c diff --git a/drivers/firewire/.kunitconfig b/drivers/firewire/.kunitconfig index 1599e069395f..03104cdd06eb 100644 --- a/drivers/firewire/.kunitconfig +++ b/drivers/firewire/.kunitconfig @@ -2,3 +2,4 @@ CONFIG_KUNIT=y CONFIG_PCI=y CONFIG_FIREWIRE=y CONFIG_FIREWIRE_KUNIT_UAPI_TEST=y +CONFIG_FIREWIRE_KUNIT_CSR_API_TEST=y diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig index 0a6596b027db..184906fdb77a 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/. +config FIREWIRE_KUNIT_CSR_API_TEST + tristate "KUnit tests for internal CSR API" if !KUNIT_ALL_TESTS + depends on FIREWIRE && KUNIT + default KUNIT_ALL_TESTS + help + This builds the KUnit tests for internal API for Control and + Status Registers. + + 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 137001f8a695..14c7461c05f6 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_node *node, int event) break; } } + +#ifdef CONFIG_FIREWIRE_KUNIT_CSR_API_TEST +#include "csr-api-test.c" +#endif diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-test.c new file mode 100644 index 000000000000..a76d767373e9 --- /dev/null +++ b/drivers/firewire/csr-api-test.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// csr-api-test.c - An application of Kunit to test implementation for CSR operation. +// +// Copyright (c) 2023 Takashi Sakamoto +// +// This file can not be built independently since it is intentionally included in core-device.c. + +#include + +static struct kunit_case csr_api_test_cases[] = { + {} +}; + +static struct kunit_suite csr_api_test_suite = { + .name = "firewire-csr-api", + .test_cases = csr_api_test_cases, +}; +kunit_test_suite(csr_api_test_suite); From patchwork Sun Dec 17 10:30:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 179982 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp640057dyi; Sun, 17 Dec 2023 02:32:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBm2fBm/2HCxN05tVMVrPu/geO9K+STEW1KvP7wR2feIJ4jzrncR/ihF5zxApkRw0U1YKU X-Received: by 2002:a05:6871:4408:b0:203:e8e:b384 with SMTP id nd8-20020a056871440800b002030e8eb384mr13167003oab.85.1702809127662; Sun, 17 Dec 2023 02:32:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702809127; cv=none; d=google.com; s=arc-20160816; b=jT+rOzaz7mqIMhah9WmprxsVm/5mrihKa60kMCdI48t3RsgxEt3M5rnS3FpkBWS3Xr GyZXrFJr/SSm3burU454MwFdSPks0rZPj4Rs3gp0tDOvI86+TLeFeQje9pXupA7E9gi+ frZzUD33dvBkBOUchLpAv7Mq+i6vrT21NuC261b14nuI6EFAG8CynS0a0Jd9TeQ7lIAq XnX3MDmWf7w+OUz10dnjefwxfph62CgPQQnRZzqSjpy0RfE5mtNpi398ff42Q4xGurxM sfFiWx3Rsj7/2CePluA4h+ke8GMjYgqLQJdIFeC6caltSW2fsKpTcMwoQ29roBbPilP9 /phA== 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=T7D+9jTfh4ZrMx7I02CJXosQOWU8TluFcGjtBl8VhDs=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=NRjN2ZiaeLM8rUiwv0TRR7SDCZgAJ9VBdreX+jHi2flqIYjNaX5/JFZkmdogHrgMKY aLSPFSGcxRFCZ1Y5RpsZ098JeWETpsQbXgXTGCvvEw+VcF7cRcaKIZhVVUl/2vRlr0cI 97qjPrjKkmGGOVkgfaBP/4CDJpv8LIL6vEuI889WEIOj5jTXjxxoXXU0fmLZ5fxHAqpU WKZ/EE3VZ/anAElzO5frRpX6cOtkdpM0fCuHID1CvaOJmu0+ox4weMWT7FLJQmhb6qSq DUv/O/gPbPc8OOy6PfhZxcpSd0VwOERff2iC1z1zZpzvY+5WO6qrrf0VEBxLzQfIr0bm CFAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=KvG2nBiK; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=c85hszWK; spf=pass (google.com: domain of linux-kernel+bounces-2529-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2529-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c22-20020a63da16000000b005c1b2d6aa3esi15741641pgh.355.2023.12.17.02.32.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 02:32:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2529-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=KvG2nBiK; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=c85hszWK; spf=pass (google.com: domain of linux-kernel+bounces-2529-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2529-ouuuleilei=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 6317A282F14 for ; Sun, 17 Dec 2023 10:32:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DCD1311198; Sun, 17 Dec 2023 10:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="KvG2nBiK"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="c85hszWK" 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 5CFDF79FE for ; Sun, 17 Dec 2023 10:30:24 +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 9ED9D5C00C6; Sun, 17 Dec 2023 05:30:23 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 17 Dec 2023 05:30:23 -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=1702809023; x= 1702895423; bh=T7D+9jTfh4ZrMx7I02CJXosQOWU8TluFcGjtBl8VhDs=; b=K vG2nBiKk2O9qeipWIanfaFHA65T25As644TAUB71MEr76M3ki+M9mqVfYo40vL+9 DU/al48z3VKklj/mLtcn6D9Fb7gqRuaFpV/aQejkR4U8Yql0NIZhLhly2UOw9Z10 V54QAcbPCJtEgvp07jvnS+Jkk3ceOzf9pLAUTWWjrMM4YMUFgYVzqkGnr3q4jM7M faK0/SwJsnwz5wz6eunimhRkVFYRfLy4dKzXK3pVQAU8ELq5asJzi7oo7obGJVP/ KirHXtG5uDD1Pgfk3dVF985vrJCgz792IJu02Xvj6AHMRt8ZndcF32xZWbmwTDb2 2Dap6MrM1i9Y9qrEvvGBw== 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=1702809023; x= 1702895423; bh=T7D+9jTfh4ZrMx7I02CJXosQOWU8TluFcGjtBl8VhDs=; b=c 85hszWKzviDPrRcb3vbezT6Uxt5adx534SWWdRDtBqISCPloy2A3l8GZQbF9mA0m EFXLuv+lJhX4qEZ+2Rw4/jnsC59pDGFocbt7CNvKtsg33fd3Q15CBShiaKT9aSeq bNSSM4XS7tE4KS//Haca4hAJZ0KLHul4/NiOL9rpwHYoMwUSwRWm1SzSof1dO0JF rTthzPjaHNkiOVx01815koz5pfmH+zME1X+yumSBE9ZZiPy47soJ0iwAxP1o+WzM Esw3UXGQzwPbt78BDjcoN8lzvjmpzzY/3077Jw2XsDyNvadgMJQ/hg3WV9RG7sus LygReovFILCiGRscwGjeA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeffvefhff dugeetkeektdegheejheegteegffeihfevvefggfeuueekvdeffeehfeenucffohhmrghi nhepkhgvrhhnvghlrdhorhhgpdguvghvihgtvgdrughirhgvtghtohhrhienucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhi sehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:22 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 4/8] firewire: test: add test of CSR API for simple AV/C device Date: Sun, 17 Dec 2023 19:30:07 +0900 Message-Id: <20231217103012.41273-5-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785524783601841482 X-GMAIL-MSGID: 1785524783601841482 At present, core function can handle node which has configuration ROM similar to AV/C device somehow. The standard layout of configuration ROM for AV/C device 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 this case. The following output is the parse result 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 (128) 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/csr-api-test.c | 119 ++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-test.c index a76d767373e9..d91852825efc 100644 --- a/drivers/firewire/csr-api-test.c +++ b/drivers/firewire/csr-api-test.c @@ -8,7 +8,126 @@ #include +// Configuration ROM for AV/C Devices 1.0 (Dec. 12, 2000, 1394 Trading Association) +// Annex C:Configuration ROM example(informative) +// C.1 Simple AV/C device +// +// Copied from the documentation. +static const u32 simple_avc_device[] = { + 0x0404eabf, + 0x31333934, + 0xe0646102, + 0xffffffff, + 0xffffffff, + 0x00063287, // root directory. + 0x03ffffff, + 0x8100000a, + 0x17ffffff, + 0x8100000e, + 0x0c0083c0, + 0xd1000001, + 0x0004442d, // unit 0 directory. + 0x1200a02d, + 0x13010001, + 0x17ffffff, + 0x81000007, + 0x0005c915, // leaf. + 0x00000000, + 0x00000000, + 0x56656e64, + 0x6f72204e, + 0x616d6500, + 0x00057f16, // leaf. + 0x00000000, + 0x00000000, + 0x4d6f6465, + 0x6c204e61, + 0x6d650000, +}; + +static void csr_api_simple_avc_device(struct kunit *test) +{ + static const struct fw_device node = { + .device = { + .type = &fw_device_type, + }, + .config_rom = simple_avc_device, + .config_rom_length = sizeof(simple_avc_device), + }; + static const struct fw_unit unit0 = { + .device = { + .type = &fw_unit_type, + .parent = (struct device *)&node.device, + }, + .directory = &simple_avc_device[12], + }; + struct device *node_dev = (struct device *)&node.device; + struct device *unit0_dev = (struct device *)&unit0.device; + static const int unit_expected_ids[] = {0x00ffffff, 0x00ffffff, 0x0000a02d, 0x00010001}; + char *buf = kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL); + int ids[4] = {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 not 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, unit_expected_ids, sizeof(ids)); +} + static struct kunit_case csr_api_test_cases[] = { + KUNIT_CASE(csr_api_simple_avc_device), {} }; From patchwork Sun Dec 17 10:30:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 179984 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp640342dyi; Sun, 17 Dec 2023 02:33:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHAi5ffCj5bDqFqUNNPayCtDfpGn/gCsvhX2ni4w5psn1/R9xsxmffSrzbmIGOHk0WUYDkP X-Received: by 2002:a17:902:b595:b0:1d3:8e5d:ecf4 with SMTP id a21-20020a170902b59500b001d38e5decf4mr3658304pls.56.1702809197139; Sun, 17 Dec 2023 02:33:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702809197; cv=none; d=google.com; s=arc-20160816; b=sPwQ1SEweDMj2KOTAi4NX7dP2LObO9q7BHcRlt2kgFO6XFSFE2B4LiamD4rc4YUfvs yLuGsWvi8jWaOLE6sWoyy2CTrPeoVUHjllsAB+nln5pXfqEBpWxeOBnVYgekfYrOoHIK dWM+J1ecHEis35Q9OpB4H+WOUheQ0Km/wrzEo8PjGtvKAUyJJKUsOFgfwlFf5QMJafs4 0VKE9znyTNMf5UHwo28DjlLV1sxBKwoywhpZGXXrfIANcEy7QKh9OiioUYnQIRKmQNti 51VdrJw82Oepz1IXDCyixZWn56vdw6yjSWpUrr6r6BnEob9DUxzmF2RzqLNvezDc+Zch OekQ== 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=My9Ypl5CIcGspchG4H7P6FMpwoU6YQCrhQk5UHWKnjE=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=m6BcEDYkbJoA+UOZ2C4lH+adMwffrALc/fmt9J1oQ0Z8XD03wfmO3y582ZnSIHG0Ht 9IT33L3gDnoLAO0NVWAF+zLB0Oc7S/fbI56Irg31aoOngHRJUlGB6cBPZFrvR1peQSle LldW2rRiSPxR5DPPKQnIoVYrk6lDuf6jLp4ei9RXt4aOGdzy3kxSe7nzhTYo345dhV+N G08kc6abjxGZfeFWaBKtQpsAN2UXxnoolJHgVKomX+W7A96e6bd9cszDOnmcZt0OOG/v 9uyNwWTgckGG4AmVIGvuLkyWpfaykbZaHFrakpsg8zJkkmpW2bnbP/1bMbpW3RgPTrlH Umdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=wXQiiYFv; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Ot6ilm+J; spf=pass (google.com: domain of linux-kernel+bounces-2530-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2530-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s13-20020a170902a50d00b001d07b6a0ae9si15867256plq.203.2023.12.17.02.33.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 02:33:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2530-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=wXQiiYFv; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Ot6ilm+J; spf=pass (google.com: domain of linux-kernel+bounces-2530-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2530-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7EA60B2275C for ; Sun, 17 Dec 2023 10:32:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00E33125A6; Sun, 17 Dec 2023 10:30:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="wXQiiYFv"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Ot6ilm+J" 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 35EB0F51E for ; Sun, 17 Dec 2023 10:30:25 +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 31C4F5C0071; Sun, 17 Dec 2023 05:30:25 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 17 Dec 2023 05:30:25 -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=1702809025; x= 1702895425; bh=My9Ypl5CIcGspchG4H7P6FMpwoU6YQCrhQk5UHWKnjE=; b=w XQiiYFvR2H5rNzMCTbrunsykEWX3RX+445TfUYsvesPMVvJEKvWda8AmpVhzf5bk ZiKmhe2tXhH6i8z1lrrHxZTn5EPhTB61OnTZAeNlsfXrxJ/6kvnMX9suqu2OD+la BEYwua7f6qon9xelq3SqOwMlZeyAJrespoeftaaalMuDfgw6YhtM4ZrTtp/hS9fz gBXlUiN4iXI/m5Q3wtnDZX0hCQ2VarpxGHlQZWB/22LWTORP6/FWcijNUoav9+Zy lg5H21E2Azh5qx8PBOM09UP44kssEZtXhEtQQ08e9Sc72deCXj/jM1ezOu7PxHlH ICj4lRdbrG3txv3t3T/vw== 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=1702809025; x= 1702895425; bh=My9Ypl5CIcGspchG4H7P6FMpwoU6YQCrhQk5UHWKnjE=; b=O t6ilm+Jcwqoz72Z8EAXdnw8YbtsLmgJCRBp1QayC+B8FdlbxPGvEozKPGz4hL0va fuVx3E3nsxf9ITGOWM3TYGWJO6kPUfZ0nZgoULN99sIRkSFO0rJhxdNIJKzKKGzn a8Bl1hub3FFMbQJQWsH/6tNYqXdbjyxvzFNc8IwL26Dpz4xcVOwHgT09NDDe39+2 27cGp5SMe+xHr8CiohbHfuoUYatJw/DuRo3vzJVYRVlZQ65gVE1aE+kYWr42y+AE Fdn3+/OnEVTVEdFAltfkdtm85BMheZb4ym2uf//RcpUMVV8yOzD38mtBySISIxo5 XOUe9GiqdnDWgnpn1ccSg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeffvefhff dugeetkeektdegheejheegteegffeihfevvefggfeuueekvdeffeehfeenucffohhmrghi nhepkhgvrhhnvghlrdhorhhgpdguvghvihgtvgdrughirhgvtghtohhrhienucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhi sehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:23 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 5/8] firewire: test: add test of CSR API for legacy AV/C device Date: Sun, 17 Dec 2023 19:30:08 +0900 Message-Id: <20231217103012.41273-6-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785524856901547601 X-GMAIL-MSGID: 1785524856901547601 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. The following output is the parse result by config-rom-pretty-printer in linux-firewire-utils (https://git.kernel.org/pub/scm/utils/ieee1394/linux-firewire-utils.git/). The content of image 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/csr-api-test.c | 111 ++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-test.c index d91852825efc..2430891c5dcb 100644 --- a/drivers/firewire/csr-api-test.c +++ b/drivers/firewire/csr-api-test.c @@ -45,6 +45,40 @@ static const u32 simple_avc_device[] = { 0x6d650000, }; +// Ibid. +// Annex A:Consideration for configuration ROM reader design (informative) +// A.1 Vendor directory +// +// Written by hand. +static const u32 legacy_avc_device[] = { + 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 text descriptor. + 0x00000000, + 0x00000000, + 0x41424344, + 0x45464748, + 0x494a0000, +}; + static void csr_api_simple_avc_device(struct kunit *test) { static const struct fw_device node = { @@ -126,8 +160,85 @@ static void csr_api_simple_avc_device(struct kunit *test) KUNIT_EXPECT_MEMEQ(test, ids, unit_expected_ids, sizeof(ids)); } +static void csr_api_legacy_avc_device(struct kunit *test) +{ + static const struct fw_device node = { + .device = { + .type = &fw_device_type, + }, + .config_rom = legacy_avc_device, + .config_rom_length = sizeof(legacy_avc_device), + }; + static const struct fw_unit unit0 = { + .device = { + .type = &fw_unit_type, + .parent = (struct device *)&node.device, + }, + .directory = &legacy_avc_device[11], + }; + struct device *node_dev = (struct device *)&node.device; + struct device *unit0_dev = (struct device *)&unit0.device; + static const int unit_expected_ids[] = {0x00012345, 0x00000000, 0x00abcdef, 0x00543210}; + char *buf = kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL); + int ids[4] = {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, unit_expected_ids, sizeof(ids)); +} + static struct kunit_case csr_api_test_cases[] = { KUNIT_CASE(csr_api_simple_avc_device), + KUNIT_CASE(csr_api_legacy_avc_device), {} }; From patchwork Sun Dec 17 10:30:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 179983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp640222dyi; Sun, 17 Dec 2023 02:32:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPC1eBSbjdR92wYJxHmoChRKCoifUWLj+3kpQxzmTvZLAonOgpZgvWrNbjo+t4wfajLKo/ X-Received: by 2002:a0c:be89:0:b0:67a:a721:7850 with SMTP id n9-20020a0cbe89000000b0067aa7217850mr14100658qvi.117.1702809168740; Sun, 17 Dec 2023 02:32:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702809168; cv=none; d=google.com; s=arc-20160816; b=ycQOBXELRJuVWMTx62i2TMmSg/Uxjty2pKZOTc6hSJJKrE0+w3KavTc+krd9SjYDS6 nq+iOJuQYMflS6e8fJnyUfXDYc8OgpPsEXgbQC3Q7J823FMp3CLYLYI4NUsAJ8fj/AiT 0WuF+8JzpXKDWhe7l8TF4uoch3OvR79Ox2dmyP2Oetn9wkVxRKdb5wgEMLHFNDgwQqON nNq1lC9VyZnxcSHcLtCxdUUsTRxxCsn2Scc/96oKn2bPQbhaqzN4I9N/SpQEhbjTHrzj ZKkL0xG+sm6CDdTo0nqrEcG1CaODZtRwpjwaNFpalDDq4Xobq9jpbat0AFb74uPxs04N Zn4A== 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=tlbzFSAVTLU8/7G01uILlJQsR6kJ19oJ8HcV/Gzb9L4=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=E7aD72OAynD7ttV5Lfm3vkL5OVgi6lV/if7cMM0ik65buZ4M/CXO4ZqmGyjDyAEAcQ dLq0/cAfW4WavKzDE564I67Gl6ta8HumNQiQm2C5A2UDqTySFdZ/D+NsK80XJPMfd373 BFLngYknHprjdHpiP388GVBiIDNJOU6ApOT6gmhLou2MYx51CjKvRbjjyjZ6QJM1xxfp PR7YGPg3CN2x1REFabgu9Z/TCk47NWXL8OWAcYXG/D26ckkf0IXSpS4fJaQQ3iWDwk5t i9eGMM0xNvYQYt09tphXNEfgvhf0KaSHu/ZzF+n8SKB+SJtHkPGB4lp04fslOoN52PGv fkZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=Rk1TfrRj; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=YAHuSqyy; spf=pass (google.com: domain of linux-kernel+bounces-2531-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2531-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g6-20020a0cf086000000b0067f2193a916si4306948qvk.413.2023.12.17.02.32.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 02:32:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2531-ouuuleilei=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=Rk1TfrRj; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=YAHuSqyy; spf=pass (google.com: domain of linux-kernel+bounces-2531-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2531-ouuuleilei=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 7216C1C21183 for ; Sun, 17 Dec 2023 10:32:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D05C12B6F; Sun, 17 Dec 2023 10:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="Rk1TfrRj"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YAHuSqyy" 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 71D9410780 for ; Sun, 17 Dec 2023 10:30:27 +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 AEBD45C0121; Sun, 17 Dec 2023 05:30:26 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 17 Dec 2023 05:30:26 -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=1702809026; x= 1702895426; bh=tlbzFSAVTLU8/7G01uILlJQsR6kJ19oJ8HcV/Gzb9L4=; b=R k1TfrRj48BMz1MjS4u8ALG0bH6VytvO3Ks+uyTt3tysT/qxD/F7+qn8ntX0/idLs qifyXWL5c7Ub3mTI6lkCsY0tz+XnWhnnz3JsXdqr6u5yXgJfnUwQ+nkRuxmhSQoy mfGpFgzEuwDHFfekEH3E8H0jtWBOejhWOrUgaVr29ZoCkILA3WJGgejGdZoa+JEh f4lf3Oat5d7R6jvypX5OsPNzgv8l5zCGLS1TU+Q2cpB2hgeTMs0fCNzdK9vZzbUS wh9o67eblJ/PUXZKPCnw5VsLHkGmVUqunTb3WUr6/kWe8CzYkuqglYk3Gb3W9Foo dGK+xCww6cfdoXmbezmBQ== 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=1702809026; x= 1702895426; bh=tlbzFSAVTLU8/7G01uILlJQsR6kJ19oJ8HcV/Gzb9L4=; b=Y AHuSqyylVf0N9ClmS5/VH/M860iogNWeUBXk+e91Mg5z+IXU8tbtQ0hRkc5MlCIk PTRb0qRp0lE+FuQXv1na0aTpKnvWwEViovUFXXIrUGCEABk3ZqTWFb3OjMz2wuWA 2rPuUaN1DB0XiGO9Jimm/9oPbGiLYXRZsYJCy5f1mIYqheAdP5jZm2JBTPD9UzdA 8YGg4e0LnkgUZfnrhlyOyEEeE2GCBPaeylY8OLQ7XXnBz0LOdrs2b/1Sqfb7a1xV qxVobTdUe1R2nTSaedwU1M8KxG2TGtj+jq0MoiGOqeW4MKnXOEP+xAeyuEXdmya6 i+b7Ntj+VlQpjUeIgzNiw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:25 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 6/8] firewire: core: detect numeric model identifier for legacy layout of configuration ROM Date: Sun, 17 Dec 2023 19:30:09 +0900 Message-Id: <20231217103012.41273-7-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785524826935740927 X-GMAIL-MSGID: 1785524826935740927 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' 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 | 57 +++++++++++++++++++++++++-------- drivers/firewire/csr-api-test.c | 5 +-- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 14c7461c05f6..dad5c9937b78 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); +static const u32 *search_directory(const u32 *directory, int search_key) +{ + struct fw_csr_iterator ci; + int key, value; + + search_key |= CSR_DIRECTORY; + + fw_csr_iterator_init(&ci, directory); + while (fw_csr_iterator_next(&ci, &key, &value)) { + if (key == 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,42 @@ static ssize_t show_immediate(struct device *dev, struct config_rom_attribute *attr = container_of(dattr, struct config_rom_attribute, attr); struct fw_csr_iterator ci; - const u32 *dir; - int key, value, ret = -ENOENT; + const u32 *directories[] = {NULL, NULL}; + int i, value = -1; 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; - fw_csr_iterator_init(&ci, dir); - while (fw_csr_iterator_next(&ci, &key, &value)) - if (attr->key == key) { - ret = snprintf(buf, buf ? PAGE_SIZE : 0, - "0x%06x\n", value); - break; + 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); + } + + for (i = 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 == key) { + value = val; + break; + } } + } up_read(&fw_device_rwsem); - return ret; + if (value < 0) + return -ENOENT; + + return snprintf(buf, buf ? PAGE_SIZE : 0, "0x%06x\n", value); } #define IMMEDIATE_ATTR(name, key) \ diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-test.c index 2430891c5dcb..7278e7b927a8 100644 --- a/drivers/firewire/csr-api-test.c +++ b/drivers/firewire/csr-api-test.c @@ -199,8 +199,9 @@ static void csr_api_legacy_avc_device(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"); - // 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"); // Descriptor leaf entry for vendor is not found. KUNIT_EXPECT_LT(test, show_text_leaf(node_dev, &config_rom_attributes[5].attr, buf), 0); From patchwork Sun Dec 17 10:30:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 179987 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp640559dyi; Sun, 17 Dec 2023 02:34:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPeMlvYRafbSxb4mHh0InGrwhCkR7Gi1s2bMBB3d34fwbocRgdvCR2pIpmSE9elXP8mfbb X-Received: by 2002:a05:6a21:6209:b0:190:199:ba05 with SMTP id wm9-20020a056a21620900b001900199ba05mr14291934pzb.60.1702809252036; Sun, 17 Dec 2023 02:34:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702809252; cv=none; d=google.com; s=arc-20160816; b=qUfSKU/7CgX05MhP2C3KuyFanTLDDCR3/1crsI+4hRNYYVJT+a2fmIv6+GbQXeMOQF vciZAoyP6UVj2oat6wu+ijm85kf5f+q3zBdZ/oT7vjryLDRPXui/UpzYlonLLW0X08ds y+ZLaey1Ry99oLxLeXqBOna7LYCDuzVfMNLKeuF6dXPIqNZXjkqWLIfiPrLrNSlmaSWz sBSKGon3hykbw3SEhJ7lrj1t/+M6AReZ0fWvxw0AZtqJZTeU5gNh+3jticXoksTb5gSM rz4+K5HQVHeLyAfIKmtzKILwHXzHxCh0Dg1ZDDWNoJeDxHGkVqZjjmUy5p1j80IfxwqK HmxA== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2532-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z14-20020a63c04e000000b005c6b4e4abe2si16252806pgi.169.2023.12.17.02.34.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 02:34:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2532-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2532-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6DBF7B2255D for ; Sun, 17 Dec 2023 10:33:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8470A5684; Sun, 17 Dec 2023 10:30:35 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785524914174126973 X-GMAIL-MSGID: 1785524914174126973 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. From patchwork Sun Dec 17 10:30:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 179985 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp640360dyi; Sun, 17 Dec 2023 02:33:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDUqRczTSZLakpAuq66tFf+Bg+6duwa+zcypyO7FfDOis2r1gSEt5iUdR+yUq8L8Lg4v5a X-Received: by 2002:a05:620a:26a4:b0:77f:4c3a:ac24 with SMTP id c36-20020a05620a26a400b0077f4c3aac24mr17491422qkp.37.1702809200721; Sun, 17 Dec 2023 02:33:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702809200; cv=none; d=google.com; s=arc-20160816; b=0nKQjoWRDkuIIAnTrFoEr+bnOjPrkS3loqzENdea6UxYwhBExKMx7oaJdCv2p7BqTM kNgxqScZZVkRdo0tkwjh82YVjsQHRctRWVxed1F++FQy5L+jSO18BLXG4BON2AodGCLk t7NS9NA661MGyHuQYypidZUrbCN3JnUh4lRDPZokNc0xSXpUFz8w2YZ+YrhNXwpgsP9u /2VOvxBWap7UWQYf3Ngsm5oXGcpIXjz7Ky+7e+5ddQhCzI9TlZQFH7QkF5XeusxRLztt L0Je2zKr2Bm6bWXbS9bnhicXXRTja395tH3yZ7X76Fjg7/5IFuNH2ZRaGbceQl6ZgXYn b44w== 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=GNxJtnuCREIc3LKzjvgp8+1jNOAQR7t6+8ZOIjGQVww=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=y7N1hTvsTPjuAm/7mDu9PBz5TpEfk5TrePHoaO8KZhj6bC0YdjoG5Xfb2Ls8v4vlSo lN7GbV2wUd/tvDtmR8rRSH+5Q/WZF5eG9EoTBvGF5obYkjs+IywZLRe7Hfm0Rvvd5c9U qJrcAjqv3SX6Qh1ULJdygdE529I0DHQITyxHxpkeRHCojWK+6kRblIbprUnrFsIQcXKZ gZiH2JGbe61mal7hBYckCWN7PshOiRcZ/X11B7rp2HkiojjaW9rIonXhZCFnyfBG+RuW 0JdBYZxXVWKkj1kMV1Ylp6on6WAqinkXAoBQ1sBql+lS1yF4WX0vQ/+kd7H0w1hziEks rjYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=EO4DA1b2; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=yWh4dFAt; spf=pass (google.com: domain of linux-kernel+bounces-2533-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2533-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q9-20020a05620a0d8900b0077f911c7b00si11399360qkl.189.2023.12.17.02.33.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 02:33:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2533-ouuuleilei=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=EO4DA1b2; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=yWh4dFAt; spf=pass (google.com: domain of linux-kernel+bounces-2533-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2533-ouuuleilei=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 7AF741C212B2 for ; Sun, 17 Dec 2023 10:33:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF1381401E; Sun, 17 Dec 2023 10:30:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="EO4DA1b2"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="yWh4dFAt" 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 D731E1118B for ; Sun, 17 Dec 2023 10:30:30 +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 compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id DDB6B5C0124; Sun, 17 Dec 2023 05:30:29 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 17 Dec 2023 05:30:29 -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=1702809029; x= 1702895429; bh=GNxJtnuCREIc3LKzjvgp8+1jNOAQR7t6+8ZOIjGQVww=; b=E O4DA1b28hTv8vuM4/sfmjKgMAmMuWZrqriu/6NQl9JMM5QC+Aszgzs6m+lldEYBx m5jUtQBlX109BSNbB2vKL8PWSpRoKc/QdtFNNl3P1SatbZaiAB7d9/eTejJr54WT ZHlYcCt265eUmfwTSELEDlx3qqe55yBfmEnoqNSu/QM3j5Ix24G7iFo1XKOTIO1R +FVRGBCpbT3PU7d2SwY+FNQKzYOd1uh35SQ3UGnJ8TAtA1h0P8nvo7HksbY3VpTi 5w3L1BGaWu4sevgVW7nF4/kT/fKhGkHuhHxwgu5oNvAWhyWRzVx8MddzAwhkEfJf xuqq+ugOhciCWpdsF3xaQ== 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=1702809029; x= 1702895429; bh=GNxJtnuCREIc3LKzjvgp8+1jNOAQR7t6+8ZOIjGQVww=; b=y Wh4dFAtNDIymNi8RauPDjeCH6rnCALqBmJE+ydH7D4LPZuQuI/OD3Yhqrjs9afSd 2h+XE9SxC51Yr1HUomOrvTquFKawgjzrfZyh5qmfNzFG+ZqHQ06ciPZw/uXwT47B tso1Oyx6oHJlvi2WvgzmioryQwpADJCiM1xiG3h7W03iVZC8LWEb5qFKSj58aJ4C wbSrdX/g8GWwcA82ekzIx/NP5idKnXgQB6q9ILS2WBDOH1CYoGh6X6Ddfu1DK70u X16wb4jiQjA9mf0p1/Q9dzEeJjS/rHZeSEkQfW9UM/OEjhZsNtXdymqtJrw6pHWI 0wWbP73aIo57hGQcgbK+Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 05:30:28 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [RFC PATCH 8/8] firewire: core: change modalias of unit device and loss of backward compatibility Date: Sun, 17 Dec 2023 19:30:11 +0900 Message-Id: <20231217103012.41273-9-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785524860861908735 X-GMAIL-MSGID: 1785524860861908735 As the last part of support for legacy layout of configuration ROM, this commit traverse vendor directory as well as root directory when constructing modalias for unit device. The change brings loss of backward compatibility since it can fill 'mo' field 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 uses Model fields to match device, however all of supported devices does not have such legacy layout. 2. the other unit drivers does not use Model field to match device. The rest of concern is user space application. The most of application just take care of node device and does not use the modalias of unit device, thus the change does not affect to them. Although, systemd project gets affects since it includes hwdb to take udev to configure fw character device conveniently. I have a plan to work systemd so that the access permission of character device is kept for the previous and next version of Linux kernel. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 21 +++++++++++++++++++-- drivers/firewire/csr-api-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 f7a11004f972..e04486c5e0eb 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) 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 = &fw_parent_device(unit)->config_rom[ROOT_DIR_OFFSET]; + const u32 *directories[] = {NULL, NULL, NULL}; + const u32 *vendor_directory; + int i; + + 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)'. + vendor_directory = search_directory(root_directory, CSR_DIRECTORY | CSR_VENDOR); + if (!vendor_directory) { + directories[1] = unit->directory; + } else { + directories[1] = vendor_directory; + directories[2] = unit->directory; + } + + for (i = 0; i < ARRAY_SIZE(directories) && directories[i]; ++i) + get_ids(directories[i], id); } static bool match_ids(const struct ieee1394_device_id *id_table, int *id) diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-test.c index 779146d0cfba..753d8e83b8c2 100644 --- a/drivers/firewire/csr-api-test.c +++ b/drivers/firewire/csr-api-test.c @@ -178,7 +178,7 @@ static void csr_api_legacy_avc_device(struct kunit *test) }; struct device *node_dev = (struct device *)&node.device; struct device *unit0_dev = (struct device *)&unit0.device; - static const int unit_expected_ids[] = {0x00012345, 0x00000000, 0x00abcdef, 0x00543210}; + static const int unit_expected_ids[] = {0x00012345, 0x00fedcba, 0x00abcdef, 0x00543210}; char *buf = kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL); int ids[4] = {0, 0, 0, 0};