From patchwork Wed Dec 20 04:17:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 181442 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2408955dyi; Tue, 19 Dec 2023 20:18:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpys9NOGFBoyVB9I7u0cRd3nPn8fgGSZwGyaRNUft7/nfzXATCeL1WUYF556YtjokgvSQr X-Received: by 2002:a05:6a21:7895:b0:194:cbb0:1cc with SMTP id bf21-20020a056a21789500b00194cbb001ccmr754084pzc.9.1703045926723; Tue, 19 Dec 2023 20:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703045926; cv=none; d=google.com; s=arc-20160816; b=MMBjipyvOb10pAxX7HuyDKGDSzDlmQluwpghWyLe/s7BYlh+WSkoabBT/JwmC2m+Rr vBY7jhLrI4caVcIHVUh2TZmvYK+oX9SE1IBBvhf26Y5aBytXmtJn1z0RiTxWAlzxKzn7 xQgb4aRw6AjlLuRHds2IRjS+C7djg3UyAuu0i6f3NSGrOINXkOB05ibMZJInS9sGiMBS 68Cy8KFgxFYyNwfz1BoWi/Sdly08F7RbEVZZccAdADOLP09MeUX4Yu8Xb2hKdnPPYDdv I+TWqdw+qdp/+2bB3qbRIFe/dPzodkEXPg4BTzmsqmzNOYh/3LBP/5LO3R9oeMPjM+r2 Z5RQ== 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=pMmsyjj7nl7WSS15wYh422IW+VbkrnpbXUDIHZjOSwQ=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=NpuEzPNN60sY/6k9Vv2xG5+0zETDWVWvXITRVvG5po1RretuqrrW1aiWME8LFAcXVt Z4/PVRxICAA8+3AWw+4DrW+6BAk2igGDNo4nbs4q6bmXWkZfwBAUaReaeKVm9BaooWeX 36rZtmPu19vzlPZTIEmhGxn+0/Sa+OrXjwZMNxAp5UiGeRDg1i5j6S4CQ959oO7Pe6nD vr65SgfN1Kcgk2Zpju8d4WgPzQRFFWY4DYlUCB+6Fb8ittqGkOT7CBqYJxri0oS7Ajxj HueZc25MrpVfk1Z/UEkisUGn+pR/Z+wF8dMNF3ZFvUzH7tyNuCt9AgkKv3lpvZTpHREq yHsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=GYjGfUJI; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="ZGQp/efh"; spf=pass (google.com: domain of linux-kernel+bounces-6353-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6353-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. [139.178.88.99]) by mx.google.com with ESMTPS id t21-20020a056a00139500b006d63a90cf66si5543491pfg.383.2023.12.19.20.18.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 20:18:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6353-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=GYjGfUJI; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="ZGQp/efh"; spf=pass (google.com: domain of linux-kernel+bounces-6353-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6353-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 DA007288784 for ; Wed, 20 Dec 2023 04:18:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 971AA11CAB; Wed, 20 Dec 2023 04:18:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="GYjGfUJI"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ZGQp/efh" X-Original-To: linux-kernel@vger.kernel.org Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (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 571581D696 for ; Wed, 20 Dec 2023 04:18:16 +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.west.internal (Postfix) with ESMTP id 589803200A34; Tue, 19 Dec 2023 23:18:15 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 19 Dec 2023 23:18:15 -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=1703045894; x= 1703132294; bh=pMmsyjj7nl7WSS15wYh422IW+VbkrnpbXUDIHZjOSwQ=; b=G YjGfUJIhOJwkHSqDxieXHzEPhT+uOTQscQGYgEka7MhjZppnj5HTzRFUOEtxHHVe be6F3CP0puIHkQJL7AxFJ7k3tIiIrCuNpz2nXkcgYFdWnDGNTlc99zDL8WDW0R3Y zLzfzudvUwIhKXolc2SdhFTo9pOlviU3C9wY1pjM017YBCdfosCqv1/y2OTQ73ex GQuCz7+cmyKT8/3v0KaH5BPifs15G+nvCbR+IGMTLzMd2XKSDa4krTqD4CzuX+Oy fQtmQUfnlSZsrfsBgxGtrPNDOu59gaax6rqlT4ROjYCVE7+O1IHgoL5LbZg2NKOt IazKAUfpulyKJC11yNBMQ== 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=1703045894; x= 1703132294; bh=pMmsyjj7nl7WSS15wYh422IW+VbkrnpbXUDIHZjOSwQ=; b=Z GQp/efhkgdyUbPGQOWeMq/CEghPDvKbrA5QSoFY4y8psrSDskmRRkrmO1Sx7o5Vs rtVwgYP6XB45uqk9P8lF00uBonBewbb3weHmmYwHcx3DNj3d80FU8WiOMPHuqnMM 18PMtwCZ4L+cXqdwZGiostS3JNTWyWB08u+Tds6kuIMpjeyCwO2Gw0epAdaLDHjh hZyAKG2gTHSkF5wi1G7cfqILuaR2qztr532y4oIfiUh8FKNHUpz3RY7Xu2hQjiOt YCRMcwIxaG7AyGXgbtYHm6zXjNS8ULErNWrf4OcR+K98AP3FY+veRc/JE8b5K3L3 +0rAQgpjitcwQakQIzGoQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduuddgieekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Dec 2023 23:18:13 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH 1/8] firewire: core: adds constant qualifier for local helper functions Date: Wed, 20 Dec 2023 13:17:59 +0900 Message-Id: <20231220041806.39816-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231220041806.39816-1-o-takashi@sakamocchi.jp> References: <20231220041806.39816-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: 1785773085515482620 X-GMAIL-MSGID: 1785773085515482620 Some local functions just handles given argument as mutable, thus it is preferable to add constant qualifier to them. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index eeda7cc59e27..96b0b43da863 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -171,7 +171,7 @@ static const struct ieee1394_device_id *unit_match(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 Wed Dec 20 04:18:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 181443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2409012dyi; Tue, 19 Dec 2023 20:19:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGClNcOkauamTNGcLBbP89XVkmfA37q7mZ9pwzhAZYLrBoeEjLKcCDQOLuwcTpAqAU7fMPp X-Received: by 2002:a05:620a:1465:b0:77e:fba3:a774 with SMTP id j5-20020a05620a146500b0077efba3a774mr13936119qkl.82.1703045939860; Tue, 19 Dec 2023 20:18:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703045939; cv=none; d=google.com; s=arc-20160816; b=UCwUbdG/QdNaBm433yplCfiCVLQj7EjvBdYQK81EhVPK43WtXqZW+V5N8qKe5ZApDE ftep8iqIERxtIInHpm7dOiWPtxKamKK0+1FwXPcRRHL6bsbFs96RF3Ewen8+DIwtv3Ne s5Wi3076Ctpfb5wHb2+exVavPGBpMiCUZ55o6OBdTGhSdIRseBJhgQe7DdoiEw8ZmjSu rSaX0CDVI2HP8cSjR/TZmfcR8l6+TZ+OkwdYWylXpVTiHMRAH8IyWRyYpZbJXUGyXtxH h5Vtxq4Tls6LmVhovQ02vJjWXB1reJoKS7rsswPVAWroSab7vkybdtdz5H6PmWCRFboW RhBA== 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=PBp/kI0n0J8XwNjRh8pLSTFV6N9OxHCw9BU3vtXvG80=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=vlRY7kNWCqM0TkQhVQaWz4AU28ts1lMRduf7TpJmh6Ln7tdQDxUkKCmN20tUkRfDpG m1qZSP5mMBOj+0GomqHrXVbwcYviw6o/5VBpkomR17jx8eKPvc854L3KeXKRhf/Q2fsI pI8fAMbrSCSXGKMsxa+mYlPJIukR4TYCB0TkX3fN7bzfQgHFuIBI3RbQrMdZCI/lm7/P FjD4XlYTV9zQ1ocP4mkMBzgUEvMl++dfVIjGAjAFVaZkX2MqPa/pNX1J7LCJLF0Lzr7O fG9ct9qxAa+oDVpiBatDUEvSJu9ke6B9t18XeGLHkb52MViaRP9tCfJHA1QK0lzxzN/W K/UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=fY40KPok; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Dpy34s+f; spf=pass (google.com: domain of linux-kernel+bounces-6354-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6354-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. [147.75.199.223]) by mx.google.com with ESMTPS id u15-20020a05620a430f00b0077f76453bcesi23275643qko.30.2023.12.19.20.18.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 20:18:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6354-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=fY40KPok; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Dpy34s+f; spf=pass (google.com: domain of linux-kernel+bounces-6354-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6354-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 A3B241C254F8 for ; Wed, 20 Dec 2023 04:18:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F35114F7F; Wed, 20 Dec 2023 04:18:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="fY40KPok"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Dpy34s+f" X-Original-To: linux-kernel@vger.kernel.org Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (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 51B3CC8CE for ; Wed, 20 Dec 2023 04:18: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.west.internal (Postfix) with ESMTP id 2A3373200A09; Tue, 19 Dec 2023 23:18:18 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 19 Dec 2023 23:18: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=1703045897; x= 1703132297; bh=PBp/kI0n0J8XwNjRh8pLSTFV6N9OxHCw9BU3vtXvG80=; b=f Y40KPokZAY6J+ufOGjMPW2NLsBhIO/1jaJFshHolkz0OSX2yqX+5V2cEq+LTfvri q/6QMA+2R1dr8gbFO5/TATROjSnXZfC9XL3ceJIEK/VB1Mg9SFVIpqoX1fw+Njpx MbBwGYEUvSUyytGhSO0hdBiz1EikSymd0rKVZ9rF1R1VMpmiwYgjiSsVGpUenf7V bMRlDmXq7PGLeQJHLvhtzh0z2eJGa9ZMvhE8KbeDBqNvKJRmBLWC1G6JKIlkfPAo blSR6nbbH97y2+FSg4ixguyjS+B/LRJ9daQc1j5kDxAK8mnF76Fn+kpcBWLVt73Y sw8ppfGhQSrEQzvqcMq9g== 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=1703045897; x= 1703132297; bh=PBp/kI0n0J8XwNjRh8pLSTFV6N9OxHCw9BU3vtXvG80=; b=D py34s+f+qgQJ0jRSDUaGmewcd6Io0FZd252UL5qJt/8nnksY/cZm4OkRxEdMQCPu AmtlXSgV8MsqFa9grb5opBseDrCKpn1/1u9+wT1KYHcUv75GSc17GKN2GyptCz/h WhBrGFzXAloTxlzBLGXLYHtXMPvGpKVemovfSJDsSCnTjhDDk9tm8gpPegcdPRPn OrpOeABiCZS5Rcrs6k2BxJ7Mlpgwqqgk1lRYb8CFP/mf3LVqErCJwC4TfqtDI+9Z 3i2CMU8eYRm2fQI42d2BLyzNegSbq6sas5pySOjGtwal5oNHZTV/97UhFBFoIhnL bFjXVLF0Gn/goXi1lpZHg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduuddgieekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Dec 2023 23:18:16 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH 2/8] firewire: core: replace magic number with macro Date: Wed, 20 Dec 2023 13:18:00 +0900 Message-Id: <20231220041806.39816-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231220041806.39816-1-o-takashi@sakamocchi.jp> References: <20231220041806.39816-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: 1785773099355592687 X-GMAIL-MSGID: 1785773099355592687 In IEEE 1394 specification, the size of bus information block of configuration ROM is fixed to 5, thus the offset of root directory is 5. Current implementation to handle device structures has the hard-coded offset. This commit replaces the offset with macro. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 96b0b43da863..315a2fe41643 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -31,6 +31,8 @@ #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 Wed Dec 20 04:18:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 181444 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2409080dyi; Tue, 19 Dec 2023 20:19:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/lk53wx4nWHCmvQFqU+apHV0HHXcYmZmi3yWSizVDE6tlmYihYOU4rcoNOlRWKwY3hwz8 X-Received: by 2002:a05:6214:1c4c:b0:67f:2541:1b6a with SMTP id if12-20020a0562141c4c00b0067f25411b6amr11357058qvb.17.1703045951631; Tue, 19 Dec 2023 20:19:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703045951; cv=none; d=google.com; s=arc-20160816; b=1DLipY6N9fub6fkuAb4x8tYMLbtGnhYvd/WFnPuCpVXe4tz2Qnw2XlFGopSPWWE+xN /EaYByC7flACxlvDpi0VqirCT6ffU2trxv6tUSOHw8K+ovF0jXNHMbgzEfvhBefUgb9n sd9k+FQtQCM7E4ohB6DEZXtAKueKF3qJCp+FdWcCEXLPnNXTc49gyjdf9jX4zfs/BYXS zUEwQwyuHs1LG48mzblj4oPJDRrILxQs7kxkQH1WZ3hb1CytVTvZOCluKNkPtW5x0jB0 uz/RAaonuGH7D6BG6PnGCZrH7uUeeZ7FlPYmGJs+OLIkgdcBnkSN8hZ56+IZnefFwoXX jRTA== 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=ALyVWm7/dGT5KixYxR7NqL6VJqyaNldFMTquZW7hL6k=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=C5vicMDOEmb4T1V0Ol1hbFR55Bw3us83Hwh1DlHMy9Ya57iaAJkAzV7sqf0bbQymzj M07T3hk1vyi0Wfdc3b5AzV1ubl2FtWAKEdB6GHbme054x+F0fPGfGkZpshgxu/D3/++P Hn9c13v0vW2nxx8HmOnfHS3q55Z6bTEqUgmkJ8WMTOD+Rf+518DFXpo5asqJlk83BSWW 5Ukr69ZxIeLzJ5mPnE/1Sq6MGWJIXt5F0B1ngbRT5b0A1akXwgBX9lCT7lEwPRupmNFt 2eyXzsp69JY84+owmNur2m2inceTk72RoTotnVJ3b12XDvDlFvRYzq3MVmVMMuGC0WhG fBlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=tyyrCZ1m; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=eCnm3MzZ; spf=pass (google.com: domain of linux-kernel+bounces-6355-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6355-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. [147.75.199.223]) by mx.google.com with ESMTPS id w13-20020a0c8e4d000000b0067f34c74eb7si7386149qvb.186.2023.12.19.20.19.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 20:19:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6355-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=tyyrCZ1m; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=eCnm3MzZ; spf=pass (google.com: domain of linux-kernel+bounces-6355-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6355-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 5C1821C247B5 for ; Wed, 20 Dec 2023 04:19:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 09AA716412; Wed, 20 Dec 2023 04:18:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="tyyrCZ1m"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="eCnm3MzZ" X-Original-To: linux-kernel@vger.kernel.org Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (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 CF513125A2 for ; Wed, 20 Dec 2023 04:18: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 compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id E41B53200A71; Tue, 19 Dec 2023 23:18:20 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 19 Dec 2023 23:18:21 -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=1703045900; x= 1703132300; bh=ALyVWm7/dGT5KixYxR7NqL6VJqyaNldFMTquZW7hL6k=; b=t yyrCZ1mldw5oxES3sSKlitze9mgR3g5YAr0G6vzD5mIFAXHDlH7vyeGvkRxI5WOi t9axlL3r7m/Kx5hFU6BJ6Z601tcReVXtQm5l8pjsnADfddjGWKPe2ewF054+KlTC YusJ9T6etzA9F7ArVMBv5fUxHv6CVIq29jrQaQ5LvbRLKx8JwPNdSN5uT8wJFU5P WCPFW1gO5PZ+U4u9zx/Y2R2OvQ7dMjMN1AJV7K/F7oVRXSu3d+Ej7KogMzZB5yvY I1HokEdznOyglWn365PQnzUrUcbfhu8YpLGaKgh7UyrIKBOR0hxyzAzbYSq7rFrP zwDODqXVzozUtdvvizAyw== 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=1703045900; x= 1703132300; bh=ALyVWm7/dGT5KixYxR7NqL6VJqyaNldFMTquZW7hL6k=; b=e Cnm3MzZWJiTerFmLesCAfuWaoh7k1VxoJ41Dqoqy8VgSjQJxZTlXn3I9gA4pOqnV 0fpGI0r1GRKiykMPIV4m461q0wx+C9jxZZW+HUoJPlXY7onN6J2l4oK9tcC69kYA OTA5lYkLlhCOT/D8xf0ns5d/yilk5liyrsEILsI7T8GvhLL2XHcK3AvsiSdGJy28 sO36uFvvu400env8d+4khvyEDFAgiDS60tkyer2HrMMqxM3yw+5Ai0aPWYy2fxax h5tLjVO2tzUscL78AdCNidv1I4PQ2xWqiJ4eBEjUzzPkYpwU6uudtXMMXKix6XpM xQv5zxyWh57wIa+61bsmg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduuddgieekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeeugfevtd efhfeffeeuudduhfekhffgveejfeeiiefftdethfduudevjeekveffleenucffohhmrghi nhepthgvshhtrghnhihthhhinhhgrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhi rdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Dec 2023 23:18:18 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH 3/8] firewire: test: add KUnit test for device attributes Date: Wed, 20 Dec 2023 13:18:01 +0900 Message-Id: <20231220041806.39816-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231220041806.39816-1-o-takashi@sakamocchi.jp> References: <20231220041806.39816-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: 1785773111735857189 X-GMAIL-MSGID: 1785773111735857189 The traverse over CSR space results in attributes of node and unit devices. Any test of the traverse is useful. This commit adds a skeleton of KUnit test for the purpose. Signed-off-by: Takashi Sakamoto --- drivers/firewire/.kunitconfig | 1 + drivers/firewire/Kconfig | 16 ++++++++++++++++ drivers/firewire/core-device.c | 4 ++++ drivers/firewire/device-attribute-test.c | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 drivers/firewire/device-attribute-test.c diff --git a/drivers/firewire/.kunitconfig b/drivers/firewire/.kunitconfig index 1599e069395f..76444a2d5e12 100644 --- a/drivers/firewire/.kunitconfig +++ b/drivers/firewire/.kunitconfig @@ -2,3 +2,4 @@ CONFIG_KUNIT=y CONFIG_PCI=y CONFIG_FIREWIRE=y CONFIG_FIREWIRE_KUNIT_UAPI_TEST=y +CONFIG_FIREWIRE_KUNIT_DEVICE_ATTRIBUTE_TEST=y diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig index 0a6596b027db..552a39df8cbd 100644 --- a/drivers/firewire/Kconfig +++ b/drivers/firewire/Kconfig @@ -34,6 +34,22 @@ config FIREWIRE_KUNIT_UAPI_TEST For more information on KUnit and unit tests in general, refer to the KUnit documentation in Documentation/dev-tools/kunit/. +config FIREWIRE_KUNIT_DEVICE_ATTRIBUTE_TEST + tristate "KUnit tests for device attributes" if !KUNIT_ALL_TESTS + depends on FIREWIRE && KUNIT + default KUNIT_ALL_TESTS + help + This builds the KUnit tests for device attribute for node and + unit. + + KUnit tests run during boot and output the results to the debug + log in TAP format (https://testanything.org/). Only useful for + kernel devs running KUnit test harness and are not for inclusion + into a production build. + + For more information on KUnit and unit tests in general, refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + config FIREWIRE_OHCI tristate "OHCI-1394 controllers" depends on PCI && FIREWIRE && MMU diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 315a2fe41643..fe1e64df476c 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -1313,3 +1313,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event) break; } } + +#ifdef CONFIG_FIREWIRE_KUNIT_DEVICE_ATTRIBUTE_TEST +#include "device-attribute-test.c" +#endif diff --git a/drivers/firewire/device-attribute-test.c b/drivers/firewire/device-attribute-test.c new file mode 100644 index 000000000000..87cfdf97c898 --- /dev/null +++ b/drivers/firewire/device-attribute-test.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// device-attribute-test.c - An application of Kunit to test implementation for device attributes. +// +// 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 device_attr_test_cases[] = { + {} +}; + +static struct kunit_suite device_attr_test_suite = { + .name = "firewire-device-attribute", + .test_cases = device_attr_test_cases, +}; +kunit_test_suite(device_attr_test_suite); From patchwork Wed Dec 20 04:18:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 181445 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2409129dyi; Tue, 19 Dec 2023 20:19:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDWYX1JU68V6PbHzg5rRANYYjDMaauBQ0PNGXpEwDBcjE9FTGAuVrrdwdjJGnqzTf+xqCr X-Received: by 2002:a05:600c:292:b0:40c:260e:1bf6 with SMTP id 18-20020a05600c029200b0040c260e1bf6mr8391223wmk.192.1703045967306; Tue, 19 Dec 2023 20:19:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703045967; cv=none; d=google.com; s=arc-20160816; b=RrwdMqbC7eA0hjEFSolSYsS9stuM4XSfqq2ONbeJvPGkscuzMsC2KDwqop9HSmYj0N O7FbYxBu7xuni/scnqlizbT851Yg9lrKu1nREkS9xJQghKz9uPVmMzhP5bJxKAWlaJuy 43k/4E2H/T35WGN2Xwa/eFHiUdNZKMzU4wTDDjA/DNWKrVOH6+TcFOrG2khjslG+TfTl Jgb6UK5uIBr7rzFYJIfsO/ZkwPXTs4CSpfYZZ+gt1iq8XKHBVkRFWDgXZ8/T/nU7ecnh UDZoojLLWwnWgdzOPQ4tAtWqGKYk4d2XSfs8bUXSr317FI+D55vdDnlu12W2bfp1JdD4 scHQ== 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=+JyhqIbPXo2UEHWmNxjsb67UTphTfDWfW8T3FHbJGc8=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=xpCOcCWWWVbq7iVf5nM9JjJLicFiplySQgQ6g0I50QSZeV8mAZj1rpAv+3kmchl8tI 1bE1NX2KQBc+luR31WFLhUu3XJXZYUusCMoRBBMBEa5iFsY1cxiTVl3m/mudOT70tTvB Q+kWCk5fcohw2aKN0wiWRCIi66JFB0AvADeZu/OjABTHq4Xqv16xHi0iw5c0WMdNNhb3 KHs7UvgwPlZJcZe5sWt94RSxxDnZgy6Oc0rK951RBJ9IxcuJ5Ew+GbuZsOGfioOabPNW qAUM+0yrmLIHRy9s+2yHerJIJhSqyP5tbpTbrcffC6aX5CSFbJ7fVnQCpujaFIJ7ef1X 5WYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=DfhZvYrX; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="VYZMzaF/"; spf=pass (google.com: domain of linux-kernel+bounces-6356-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6356-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n4-20020a170906088400b00a2367f97e81si1690368eje.1015.2023.12.19.20.19.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 20:19:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6356-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=DfhZvYrX; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="VYZMzaF/"; spf=pass (google.com: domain of linux-kernel+bounces-6356-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6356-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C00731F26003 for ; Wed, 20 Dec 2023 04:19:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C58BD179BF; Wed, 20 Dec 2023 04:18:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="DfhZvYrX"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VYZMzaF/" X-Original-To: linux-kernel@vger.kernel.org Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (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 BAB4C15484 for ; Wed, 20 Dec 2023 04:18: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.west.internal (Postfix) with ESMTP id ADE493200A30; Tue, 19 Dec 2023 23:18:23 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 19 Dec 2023 23:18:24 -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=1703045903; x= 1703132303; bh=+JyhqIbPXo2UEHWmNxjsb67UTphTfDWfW8T3FHbJGc8=; b=D fhZvYrXgZwNcBoIhcUbxBK/PFjEhqHX95MyKh8RsjUdqaru0PKOXy5byllI9axPx cJ5Yh4ULSX+eo8VizAPtU4FLv+bGfk46MIl16tb0n9Az+SIsPxzS4076fYr2Xn6W HkPCNMM9l+LkhxobvLLfCXNBB+FoSIyNCJK0KjlyavObm/p5/nhPi3lNGCbyceE8 tG1Blffdk6CubLZJlzZ+GnzgHasY2m9WjZ8QSpgbcq9wFE9Gqjrk6555PFaIfwlR 85Q8PaPzW/4LT8cypb4hcoDYjgFfhq8kSpLuNVTeASPlzBKz2mgZx9TrTq6o+9cR ynaOyjLqe/TUc0RZ/1Okw== 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=1703045903; x= 1703132303; bh=+JyhqIbPXo2UEHWmNxjsb67UTphTfDWfW8T3FHbJGc8=; b=V YZMzaF/tFFZ5plIUh1Nu0Hb7CpKLJcI5ZwyFNLdgFwCcOujgTI5lwv1DM/g54Ru8 u2tGG/iHp6ee2giGux95Bkg5yYNAtX1dP43ifsBeay8+KBrTTKKLlh5vgbhYNrLQ jRHdL3SuPu8NCZrIPTuytQe5nyRolF6MV0i5EZ7JX+lpD+TCoBIhl928/XqGmIWr kjqeIZrpB+KlyVAUgS9galWhgYIUnfY7d5VKiIM+cy9QNvem8fwoaO5nm1vB1ucW Zyxe3akWhPll91MknefFM4Ai2YoV6mghT1ETFPGOpaEB1+IZwp4/cQYC63AiOkJx f48vsDFRSY/qY0DtUKsrw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduuddgieekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeffvefhff dugeetkeektdegheejheegteegffeihfevvefggfeuueekvdeffeehfeenucffohhmrghi nhepkhgvrhhnvghlrdhorhhgpdguvghvihgtvgdrughirhgvtghtohhrhienucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhi sehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Dec 2023 23:18:21 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH 4/8] firewire: test: add test of device attributes for simple AV/C device Date: Wed, 20 Dec 2023 13:18:02 +0900 Message-Id: <20231220041806.39816-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231220041806.39816-1-o-takashi@sakamocchi.jp> References: <20231220041806.39816-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: 1785773127912988578 X-GMAIL-MSGID: 1785773127912988578 At present, core function can handle node which has configuration ROM similar to standard AV/C device somehow. The standard layout of configuration ROM is described in the following document. - Configuration ROM for AV/C Devices 1.0 (Dec. 12, 2000, 1394 Trading Association) This commit adds a KUnit test for the above case. The following output is the parse result for the hard-coded data, by config-rom-pretty-printer in linux-firewire-utils (https://git.kernel.org/pub/scm/utils/ieee1394/linux-firewire-utils.git/). $ config-rom-pretty-printer < /tmp/rom.img ROM header and bus information block ----------------------------------------------------------------- 1024 0404eabf bus_info_length 4, crc_length 4, crc 60095 1028 31333934 bus_name "1394" 1032 e0646102 irmc 1, cmc 1, isc 1, bmc 0, cyc_clk_acc 100, max_rec 6 (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/device-attribute-test.c | 119 +++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/drivers/firewire/device-attribute-test.c b/drivers/firewire/device-attribute-test.c index 87cfdf97c898..e2c5587d0757 100644 --- a/drivers/firewire/device-attribute-test.c +++ b/drivers/firewire/device-attribute-test.c @@ -8,7 +8,126 @@ #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_config_rom[] = { + 0x0404eabf, + 0x31333934, + 0xe0646102, + 0xffffffff, + 0xffffffff, + 0x00063287, // root directory. + 0x03ffffff, + 0x8100000a, + 0x17ffffff, + 0x8100000e, + 0x0c0083c0, + 0xd1000001, + 0x0004442d, // unit 0 directory. + 0x1200a02d, + 0x13010001, + 0x17ffffff, + 0x81000007, + 0x0005c915, // leaf for textual descriptor. + 0x00000000, + 0x00000000, + 0x56656e64, + 0x6f72204e, + 0x616d6500, + 0x00057f16, // leaf for textual descriptor. + 0x00000000, + 0x00000000, + 0x4d6f6465, + 0x6c204e61, + 0x6d650000, +}; + +static void device_attr_simple_avc(struct kunit *test) +{ + static const struct fw_device node = { + .device = { + .type = &fw_device_type, + }, + .config_rom = simple_avc_config_rom, + .config_rom_length = sizeof(simple_avc_config_rom), + }; + static const struct fw_unit unit0 = { + .device = { + .type = &fw_unit_type, + .parent = (struct device *)&node.device, + }, + .directory = &simple_avc_config_rom[12], + }; + struct device *node_dev = (struct device *)&node.device; + struct device *unit0_dev = (struct device *)&unit0.device; + static const int unit0_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 found. + KUNIT_EXPECT_GT(test, show_text_leaf(unit0_dev, &config_rom_attributes[6].attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "Model Name\n"); + + // Specifier_ID immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(unit0_dev, &config_rom_attributes[2].attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0x00a02d\n"); + + // Version immediate entry is found. + KUNIT_EXPECT_GT(test, show_immediate(unit0_dev, &config_rom_attributes[3].attr, buf), 0); + KUNIT_EXPECT_STREQ(test, buf, "0x010001\n"); + + kunit_kfree(test, buf); + + get_modalias_ids(&unit0, ids); + KUNIT_EXPECT_MEMEQ(test, ids, unit0_expected_ids, sizeof(ids)); +} + static struct kunit_case device_attr_test_cases[] = { + KUNIT_CASE(device_attr_simple_avc), {} }; From patchwork Wed Dec 20 04:18:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 181446 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2409269dyi; Tue, 19 Dec 2023 20:19:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqPjTc3FRCgm02iq1eXDijS1/p1Y4dYdMzzM7NGWuDy4EzwuAobHaFaMN77mxQYfsSli4x X-Received: by 2002:aa7:93a9:0:b0:6d3:a63b:71eb with SMTP id x9-20020aa793a9000000b006d3a63b71ebmr6578629pff.4.1703045994745; Tue, 19 Dec 2023 20:19:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703045994; cv=none; d=google.com; s=arc-20160816; b=q7YyHHp3ICVco1TNM9N9N60DmAVB/PizTK86Hok9rDMTQPry9de5B4tNFiAgCXF1gO Rin2uaXuxihhOSzNjfsCHah15O5sNBS7d39rgR+2NqULo/PA/aDlDFSES4uoOPG1gY4j X/Rw3Umyw6sBGkjwSPddEgsBlqDBG8zbP5ENjZ1nwgK25TWZGr2SwKn/6Yp4BfsEnb52 EPorvpjRsJkWzLpCcEIqYrRtb5uJEdp3l7vSwUYl96WKoFiDQZtgqzBuMYjnULwz8XTL hni15Kny2F+3iwtHZQ9zvQXoYZmOQOlylOz8FhbpZucWaCUaMuVM/R+O4oXsJ6OfOAgY KngQ== 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=3EzlJFfSkML/ta9lyeEKf9o6eumBFTgrZNdRmkxbQEo=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=dil2CQ14VxP9HhKO8No5ugsf+XLolBIxhziWOFWsuqIfmFkkaJWXwUnxFhIMQmXbG6 gquppTSy0JmixRb7sOidnkawKM4revnJuccV8MQlkiMzepDJOafWvaY3g4AHLb1Tvijr ZfltqQOmopgtB9qlAqvQpEjKgZBYkDcz5UXvyH8WCtCC7tt6+nJNv5sk4HrkREzempBp HuTMzPgYrRlEBuOS47pRHC687gQM8JQp7k6IvqlQUNC4nCrOl+2gY6XwPfbWsKBEZ4++ eUwtgqwY6JCJuX3MajlDXvnhnfs5TcpuEODuHDseLxbEH/nJ9aYbxOb/WgsdvIAKG0+o lNoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=YZGUBHA+; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=2gaFEYIN; spf=pass (google.com: domain of linux-kernel+bounces-6357-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6357-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. [139.178.88.99]) by mx.google.com with ESMTPS id t21-20020a056a00139500b006d63a90cf66si5543491pfg.383.2023.12.19.20.19.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 20:19:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6357-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=YZGUBHA+; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=2gaFEYIN; spf=pass (google.com: domain of linux-kernel+bounces-6357-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6357-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 A5F8328882B for ; Wed, 20 Dec 2023 04:19:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D3921C6B1; Wed, 20 Dec 2023 04:18:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="YZGUBHA+"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="2gaFEYIN" X-Original-To: linux-kernel@vger.kernel.org Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (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 368841640D for ; Wed, 20 Dec 2023 04:18: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 compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 73E503200A42; Tue, 19 Dec 2023 23:18:26 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 19 Dec 2023 23:18: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=1703045905; x= 1703132305; bh=3EzlJFfSkML/ta9lyeEKf9o6eumBFTgrZNdRmkxbQEo=; b=Y ZGUBHA+BS4rceFHcaTt2zTVU1hIf/h2EUr6tdWZJrjxx/4RwiorOEWklm50yx5E+ IkfeiajrfICK3MSkK5zwRzoun8OMRLY+ClQuPGgaQO3o+t6Pm470+/MY+m6pr/FK AoHI+Wzf3MqQrfFL7DHx1fkKWHt9dFTRXnjmTCAUtU7y2jTK/G5oTX0UdPBqwjyS sYM4hlnuqFgQq8O5DMDGp5f214gAzBhGpUgANrXQRdBc5vp9qdbmwoBMY0GBB87F nmgh+EibfpUZF/goCzZNdqwWsO2SClp6AZkQfDXZO2ZufhXTt6cuKdrMbdWa7t67 CXyyEJOeZzDQZdsxsFegg== 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=1703045905; x= 1703132305; bh=3EzlJFfSkML/ta9lyeEKf9o6eumBFTgrZNdRmkxbQEo=; b=2 gaFEYINbMBcPoiMMHdpkAgNz1Y2C4IjALTUUhE30HKao+gAV/VX3ewe1frVi20t7 UpLCjM6/Ms6HkdOffbW7jFFmsYP4Au+oQUVOwgmAKUOoVyw1goE38JYOle3jM3IV OCGdKutYvMNTZiftVOE/efkBjcuwl8SI77RoBo+Nrr1cRj+Bghpx2kcoBpzBJUeL /42qmSPZ7lNCIbP4QMyvvlQYp2glI0iO3HTbSrp7MiY+LnYNODJT2cLzNWNhcsFW +nra8i6KgrmGl8R8RRwp8nER8Z9yi2PIiwfo0KpTeJftVGjHKOn4vC37dswwXR0J OD4x9mviXDdlVe3MydS2w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduuddgieekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeffvefhff dugeetkeektdegheejheegteegffeihfevvefggfeuueekvdeffeehfeenucffohhmrghi nhepkhgvrhhnvghlrdhorhhgpdguvghvihgtvgdrughirhgvtghtohhrhienucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhi sehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Dec 2023 23:18:24 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH 5/8] firewire: test: add test of device attributes for legacy AV/C device Date: Wed, 20 Dec 2023 13:18:03 +0900 Message-Id: <20231220041806.39816-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231220041806.39816-1-o-takashi@sakamocchi.jp> References: <20231220041806.39816-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: 1785773157025962762 X-GMAIL-MSGID: 1785773157025962762 Some legacy devices have configuration ROM against standard AV/C device. They have vendor directory to store model identifier. It is described in annex of the following document. - Configuration ROM for AV/C Devices 1.0 (Dec. 12, 2000, 1394 Trading Association) In the case, current implementation of core function does not detect the model identifier, thus device attributes and modalias of unit have lack of it. Another KUnit test is required for the case, and this commit is for the purpose. The following output is the parse result for the hard-coded data, by config-rom-pretty-printer in linux-firewire-utils (https://git.kernel.org/pub/scm/utils/ieee1394/linux-firewire-utils.git/). The data is written by my hand. $ config-rom-pretty-printer < /tmp/rom.img ROM header and bus information block ----------------------------------------------------------------- 1024 04199fe7 bus_info_length 4, crc_length 25, crc 40935 1028 31333934 bus_name "1394" 1032 e0644000 irmc 1, cmc 1, isc 1, bmc 0, cyc_clk_acc 100, max_rec 4 (32) 1036 00112233 company_id 001122 | 1040 44556677 device_id 220189779575 | EUI-64 4822678189205111 root directory ----------------------------------------------------------------- 1044 0005dace directory_length 5, crc 56014 1048 03012345 vendor 1052 0c0083c0 node capabilities: per IEEE 1394 1056 8d000009 --> eui-64 leaf at 1092 1060 d1000002 --> unit directory at 1068 1064 c3000004 --> vendor directory at 1080 unit directory at 1068 ----------------------------------------------------------------- 1068 0002e107 directory_length 2, crc 57607 1072 12abcdef specifier id 1076 13543210 version vendor directory at 1080 ----------------------------------------------------------------- 1080 0002cb73 directory_length 2, crc 52083 1084 17fedcba model 1088 81000004 --> descriptor leaf at 1104 eui-64 leaf at 1092 ----------------------------------------------------------------- 1092 00026dc1 leaf_length 2, crc 28097 1096 00112233 company_id 001122 | 1100 44556677 device_id 220189779575 | EUI-64 4822678189205111 descriptor leaf at 1104 ----------------------------------------------------------------- 1104 00050e84 leaf_length 5, crc 3716 1108 00000000 textual descriptor 1112 00000000 minimal ASCII 1116 41424344 "ABCD" 1120 45464748 "EFGH" 1124 494a0000 "IJ" Signed-off-by: Takashi Sakamoto --- drivers/firewire/device-attribute-test.c | 111 +++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/drivers/firewire/device-attribute-test.c b/drivers/firewire/device-attribute-test.c index e2c5587d0757..495af65c33b5 100644 --- a/drivers/firewire/device-attribute-test.c +++ b/drivers/firewire/device-attribute-test.c @@ -45,6 +45,40 @@ static const u32 simple_avc_config_rom[] = { 0x6d650000, }; +// Ibid. +// Annex A:Consideration for configuration ROM reader design (informative) +// A.1 Vendor directory +// +// Written by hand. +static const u32 legacy_avc_config_rom[] = { + 0x04199fe7, + 0x31333934, + 0xe0644000, + 0x00112233, + 0x44556677, + 0x0005dace, // root directory. + 0x03012345, + 0x0c0083c0, + 0x8d000009, + 0xd1000002, + 0xc3000004, + 0x0002e107, // unit 0 directory. + 0x12abcdef, + 0x13543210, + 0x0002cb73, // vendor directory. + 0x17fedcba, + 0x81000004, + 0x00026dc1, // leaf for EUI-64. + 0x00112233, + 0x44556677, + 0x00050e84, // leaf for textual descriptor. + 0x00000000, + 0x00000000, + 0x41424344, + 0x45464748, + 0x494a0000, +}; + static void device_attr_simple_avc(struct kunit *test) { static const struct fw_device node = { @@ -126,8 +160,85 @@ static void device_attr_simple_avc(struct kunit *test) KUNIT_EXPECT_MEMEQ(test, ids, unit0_expected_ids, sizeof(ids)); } +static void device_attr_legacy_avc(struct kunit *test) +{ + static const struct fw_device node = { + .device = { + .type = &fw_device_type, + }, + .config_rom = legacy_avc_config_rom, + .config_rom_length = sizeof(legacy_avc_config_rom), + }; + static const struct fw_unit unit0 = { + .device = { + .type = &fw_unit_type, + .parent = (struct device *)&node.device, + }, + .directory = &legacy_avc_config_rom[11], + }; + struct device *node_dev = (struct device *)&node.device; + struct device *unit0_dev = (struct device *)&unit0.device; + static const int unit0_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, unit0_expected_ids, sizeof(ids)); +} + static struct kunit_case device_attr_test_cases[] = { KUNIT_CASE(device_attr_simple_avc), + KUNIT_CASE(device_attr_legacy_avc), {} }; From patchwork Wed Dec 20 04:18: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: 181447 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2409278dyi; Tue, 19 Dec 2023 20:19:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsa+qShwsZ1WQ+SPSCPA7q2XbylnoIDUjAd3YtWQk3kw+Bs4o5aY5wYAeZn5m+fRMk7WuT X-Received: by 2002:a05:6870:a929:b0:203:face:8158 with SMTP id eq41-20020a056870a92900b00203face8158mr1854238oab.6.1703045995624; Tue, 19 Dec 2023 20:19:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703045995; cv=none; d=google.com; s=arc-20160816; b=SU3wT1LLPL8hQ7Chmz95c7Za49bgDU5aZhRb+f9mPWSfnzqTPYR6CNDIrv+nXH49PI a+JNW6WsdG+HdnQP94mLWULtRP8THDfwWnMxov43flLmVaxDkUgc0zprcTqvu1/ikau6 NHfT/3GyXZCYNkxsVoD78fm0zRZplzGv6wmIz3hPNIn73Ms/AHha4M/XEhBCaGrl83z0 dMstx55/Qa0zLKPNjYoZuPrFm0nde9w6UGc3wRz4rv19AR/rDXZNzUpVDdVzH0nJUXKv 7bXKAfce7F3ESeC9mLWomzEmV1irpptAIvDFXKYeA7Vb2N1HT7eKyerqHMFV/H68M3XU fcTw== 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=c3+SGtxjfpRsQL1FjnGhoxDOzKY9TE2Qa/7LRiK0mv4=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=OYQ+QSTHShlYfZAMEsIIKPsZMgq7WNYkMVCUKAufwdlOVGMeQEviOU7MJyZku0jrMr 4yocT1JfyypgX5lNUTjFrrMJIuOQXIESV2IUE4MtUyW5QjQCjI0H/2+MrN/xcosfaKkT 4+rXc/Q/XurJvSE3XBQ+DiPVU7EiPYWnGtNuR/kj/5WkjEm7vPrRwRT6sW3Z7BKDm5rw ksiG/F92Jm/Dt2wJXYYTsMWVWKndWKMYs9i3NdOqHMZGSjBWzyGkJSZzapOIIGPvHzsp njhz0VkSW+2TOyJvSuEOVlUEKahB/377D58BbIFfsK5Zasxo45Ms5Q/QZgUqEZrLoX9z 2XIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=CIOcsm5u; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=XEhUat44; spf=pass (google.com: domain of linux-kernel+bounces-6358-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6358-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 v6-20020a634806000000b005c66e609013si20763776pga.221.2023.12.19.20.19.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 20:19:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6358-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=CIOcsm5u; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=XEhUat44; spf=pass (google.com: domain of linux-kernel+bounces-6358-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6358-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 E5561B23F71 for ; Wed, 20 Dec 2023 04:19:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 694E01DA34; Wed, 20 Dec 2023 04:18:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="CIOcsm5u"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="XEhUat44" X-Original-To: linux-kernel@vger.kernel.org Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (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 4E81F199C6 for ; Wed, 20 Dec 2023 04:18: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.west.internal (Postfix) with ESMTP id 648083200A67; Tue, 19 Dec 2023 23:18:29 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 19 Dec 2023 23:18: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=1703045908; x= 1703132308; bh=c3+SGtxjfpRsQL1FjnGhoxDOzKY9TE2Qa/7LRiK0mv4=; b=C IOcsm5ugynM8OL3LKR1xwwjtPCfU8Q+5MjrUOaNf4M2r80AAfEfsdIMq8kmovzLD ZM44Azii7yw8a53MULbqKbz64vKIFfQKvnOklve0evDGNE5lVy6ABIcK5BOGRYot GFyuZqo5FFvzpclVczbkZ816qSKFRpGPjiefj7Y44My7wOT6F9auJeJqIbhSPxrQ 5DpknCYSoUYmJU/zid6ZjEGVvZzK2U1CZ/QbJduvd78gQnhQZzajaNPpYz+6DfVF mnQerTd9a41HWPnKZE5r5AJ54Cveb50Hknu2wTQBlqKGYdCLg0P3BiyHoTRxjw09 /icjFgRSZdc9fvsetovug== 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=1703045908; x= 1703132308; bh=c3+SGtxjfpRsQL1FjnGhoxDOzKY9TE2Qa/7LRiK0mv4=; b=X EhUat448cPzNYwNNCNU4IKW8CN5zoB0sPbITqj7gIzBppf3RU101axu0eKX2vHtj SYDGbIMnjAvjO3unsGs7g1CBzQ2Vo531b/A06IKgCFumi8Ran2j4yYIXIJ4DZ28t hPhIJ5zkyZRQNAzMmbtBkhyhFmA7JmLAFU3hen6ypfddhc+kqkEAH/KbSER6yTgN OW2GF9e3qjcqQ0qV6aJkKlXAvG8Zj5dCwwSzBukS628h1plyJgQHMv9yGekPxydd Puj02Wo8jHtLeLKZWBGOgMBtFT7X5wc5WecmICgRi3m6ISTRAMZGhT7r0r8dSBk4 zOZxOmApYuxcZlZPmXN3Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduuddgieekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Dec 2023 23:18:27 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH 6/8] firewire: core: detect numeric model identifier for legacy layout of configuration ROM Date: Wed, 20 Dec 2023 13:18:04 +0900 Message-Id: <20231220041806.39816-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231220041806.39816-1-o-takashi@sakamocchi.jp> References: <20231220041806.39816-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: 1785773157946377434 X-GMAIL-MSGID: 1785773157946377434 As the part of support for legacy layout of configuration ROM, this commit traverses vendor directory as well as root directory when showing device attribute for node device. This change expects 'model' attribute appears in node device, however it is probable to see the other types of immediate values if the vendor directory includes. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 59 ++++++++++++++++++------ drivers/firewire/device-attribute-test.c | 5 +- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index fe1e64df476c..d0ce583b93c4 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -49,6 +49,22 @@ int fw_csr_iterator_next(struct fw_csr_iterator *ci, int *key, int *value) } EXPORT_SYMBOL(fw_csr_iterator_next); +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,44 @@ 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; + const u32 *vendor_directory = search_directory(root_directory, CSR_VENDOR); - 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; + if (!vendor_directory) { + directories[0] = root_directory; + } else { + // Legacy layout of configuration ROM described in Annex 1 of + // 'Configuration ROM for AV/C Devices 1.0 (December 12, 2000, 1394 Trading + // Association, TA Document 1999027)'. + directories[0] = vendor_directory; + directories[1] = root_directory; + } + } + + 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; } + } 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/device-attribute-test.c b/drivers/firewire/device-attribute-test.c index 495af65c33b5..689115433425 100644 --- a/drivers/firewire/device-attribute-test.c +++ b/drivers/firewire/device-attribute-test.c @@ -199,8 +199,9 @@ static void device_attr_legacy_avc(struct kunit *test) KUNIT_EXPECT_GT(test, show_immediate(node_dev, &config_rom_attributes[0].attr, buf), 0); KUNIT_EXPECT_STREQ(test, buf, "0x012345\n"); - // 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 Wed Dec 20 04:18: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: 181448 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2409331dyi; Tue, 19 Dec 2023 20:20:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqMT8OtOHuGt532G7dmoDtARE1MEfWvBFVJaWBhTtvIIh4B6Pm6522ebQaJr7AuYiwpz8e X-Received: by 2002:a05:620a:211c:b0:781:ae0:fc03 with SMTP id l28-20020a05620a211c00b007810ae0fc03mr1527772qkl.58.1703046005329; Tue, 19 Dec 2023 20:20:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703046005; cv=none; d=google.com; s=arc-20160816; b=FdCeBVb8JanLe+24VuZA+wImhu+9Si8KQI9r4DOTLQwcbSlIVfaPNv+o+zyppFiC1Q wnLC8R0ejEqB8o2osXcLt2CmOy8qqWnE5FCe6tO/qsHP+QkW6XKs2l+s3u+LNhia/xvN DmFRKF/i7Yp6ggX8WQmTQHWIBKQAWH8vhJ4HdiYh0f7ZyTNjM4OKLgjp1h3WR9oh1iUe tKWWrG+VNTA1xRUqcCwSfC75s5vgF4DEOkOvCiHuJamZvjLIi2tB/p22kFvKlh9QeXwd MUqdCxMuVgXI0Zol2XStG3dY5heZ76WAODDb4OusbKkCtL96QBAZlUiV3r1Cc5y00KEr 26xQ== 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=sjjjefL0YuZeCDEla/9R8UiAeKIsBwn7UqHFh3/lofs=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=PKdwqmMPH/cf+lsqS2skv847uHaQ+vw235eIkPjMEBiZt52nU7Ggl85qiaL+V62mjF 6Gaji0kvt3EdLgf7rRuhLpM8uRpllinLDw6/vZNk1UVDbi5Yf4hdMTdshFCeKKtYXirD GGChcdqxw9bRc7S5lsmE+DwgugxSO7JAwZU9kiVQE2qbq+0qqrBQWqxmrDO4z2T84Kzk EzOVMgZC3WEGN586nfssGXwwAksTp4uZxTPv92lHi+CqjTZDbZVfXa/f2CyKhYG7xlNI 4HyVmDa4pofiEpLy7gzNVgLhzTWeQqnzQyxNaFWjza1s9c+jwGWYHeaSgrpL2hxbuEWj cx8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=W225XQu2; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=jDImt9U6; spf=pass (google.com: domain of linux-kernel+bounces-6359-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6359-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. [147.75.199.223]) by mx.google.com with ESMTPS id i19-20020a05620a405300b007789c2585f0si1126839qko.418.2023.12.19.20.20.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 20:20:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6359-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=W225XQu2; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=jDImt9U6; spf=pass (google.com: domain of linux-kernel+bounces-6359-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6359-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 133E01C20D44 for ; Wed, 20 Dec 2023 04:20:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 616541F5FC; Wed, 20 Dec 2023 04:18:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="W225XQu2"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="jDImt9U6" X-Original-To: linux-kernel@vger.kernel.org Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (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 2493B1CF91 for ; Wed, 20 Dec 2023 04:18:32 +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 compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 2F3D13200A30; Tue, 19 Dec 2023 23:18:32 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 19 Dec 2023 23:18:32 -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=1703045911; x= 1703132311; bh=sjjjefL0YuZeCDEla/9R8UiAeKIsBwn7UqHFh3/lofs=; b=W 225XQu2m6vWAYoKRd4NM++hCM4eASw9S6K3Fx3778pgZM5Ll0utI3UamMcJ/XNcl wrngppSs3+p2T4kD0YEggkwEpmrFWmRXgxD9T3E5HKb6nlBLY3FgDeMrrYKIIZHW anTxlzQzDinS68G7M8+8jwQGGioR28MMormZjIicM+e8dy/4eiekfLAoEbiUd2xT Uj1mGxnjeu02kebSP8bmNNLPnAlBcYMkFM+/iBgzo/2qahn6x8oUUsl8BntYwlwj kj1MfDVFTLOoZ9CTE1RxIJVH4UOHDfv0TIpx+Gr0trQsltbZN7T275+tNmViR1pa p1i5xjHaVsHqG/XQGmcug== 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=1703045911; x= 1703132311; bh=sjjjefL0YuZeCDEla/9R8UiAeKIsBwn7UqHFh3/lofs=; b=j DImt9U64mM2RRxEIRNkLbo9qw7T0r2fGxcz+ZXYAqmu/jvs8YuOGH69RYWjjuEDW 1fu77sdhyx0sukoz5Tco6vWgMd7QFvhjzqf3dkLydFREeIgKcnFlYWx/vFCmEe5S 0BRI/E142dpqMC0m3rPas1W25eIf1ofhHEYrzpCQ0HrqOjlLekiQZupY9OWvzqEn +3UENhDgBrqsS0Y1rdmnI5XqjPg8CkzDp7YdR+c8HM8YUV4Bw1fJ9CkpTB6zrOrl kd3QRd27Cd+eM+ZTKHdEpR2r9ZEnhyANNMYASkGu4U8mMBOqgd4QvSdcpLQuun0Q l9ShV9yHn7RctKmjiowVA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduuddgieelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Dec 2023 23:18:30 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH 7/8] firewire: core: detect model name for legacy layout of configuration ROM Date: Wed, 20 Dec 2023 13:18:05 +0900 Message-Id: <20231220041806.39816-8-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231220041806.39816-1-o-takashi@sakamocchi.jp> References: <20231220041806.39816-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: 1785773168375274049 X-GMAIL-MSGID: 1785773168375274049 As the part of support for legacy layout of configuration ROM, this commit traverses vendor directory as well as root directory when showing device attribute for node device. This change expects 'model_name' attribute appears in node device, however it is probable to see the other types of descriptor leaf if the vendor directory includes. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 31 ++++++++++++++++++------ drivers/firewire/device-attribute-test.c | 5 ++-- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index d0ce583b93c4..2bc6c874e89c 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -317,17 +317,29 @@ static ssize_t show_text_leaf(struct device *dev, { struct config_rom_attribute *attr = 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; + const u32 *vendor_directory = search_directory(root_directory, CSR_VENDOR); + + if (!vendor_directory) { + directories[0] = root_directory; + } else { + // Legacy layout of configuration ROM described in Annex 1 of + // 'Configuration ROM for AV/C Devices 1.0 (December 12, 2000, 1394 + // Trading Association, TA Document 1999027)'. + directories[0] = root_directory; + directories[1] = vendor_directory; + } + } if (buf) { bufsize = PAGE_SIZE - 1; @@ -336,7 +348,12 @@ 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) { + int result = fw_csr_string(directories[i], attr->key, buf, bufsize); + // Detected. + if (result >= 0) + ret = result; + } if (ret >= 0) { /* Strip trailing whitespace and add newline. */ diff --git a/drivers/firewire/device-attribute-test.c b/drivers/firewire/device-attribute-test.c index 689115433425..da2a4a09bf84 100644 --- a/drivers/firewire/device-attribute-test.c +++ b/drivers/firewire/device-attribute-test.c @@ -206,8 +206,9 @@ static void device_attr_legacy_avc(struct kunit *test) // Descriptor leaf entry for vendor is not found. KUNIT_EXPECT_LT(test, show_text_leaf(node_dev, &config_rom_attributes[5].attr, buf), 0); - // 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 Wed Dec 20 04:18: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: 181449 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2409375dyi; Tue, 19 Dec 2023 20:20:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGoIaipxGU1Jnc4K9TUyLodP2ujlYzZO2k3WFj8AqnmtwjiPRrkrj/0C/zMWaqnPZLbAItk X-Received: by 2002:a05:6214:21ad:b0:67f:1324:85e1 with SMTP id t13-20020a05621421ad00b0067f132485e1mr10710806qvc.32.1703046016916; Tue, 19 Dec 2023 20:20:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703046016; cv=none; d=google.com; s=arc-20160816; b=R9qQVHuvjJQmCR8/lrrJrY6qJhKX5WeyayLiOYRRJWmHd76Bv2o6gT1qbF7aAVwaIg NsgFBd6OpYv6iypGMk3uJodmrEnaE9O+jxSBEeyLRwFqY0VVzYl8JtsMXTHh1vIaytNH 0Czc/3MXr3NNwF/uI4cwQYVJldw/hXEL6qRXEe0ZfbCqVnP8ruy0dtZKrLS+sV0demcs QSiwaCZL8/zFCWvGOR4ZOvq6Nev+jOwgJa2O052R70ms/H6LYO0/n/EVWm82Qe+BwojZ yM155yAGS08tPeScUCA+qQWJ4qyI8UyijKJjmAJLsWIHIwPK8/2ywmx1yELC6Q7xmri0 JXxw== 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=MqOifYCucTPnKbf3hkszGvdZNwn7ZENwvdLMF39HtZM=; fh=29+NP+Avo3KW5WAFiPrv+jdOjQZBDMQJMXZlHI+I9m4=; b=m1DG/cTRauchLbJ1lokrjTqGnUUNkvXboFuzykydaT8kq6fI00P5xddhhF6JNjZBkR a0xb2/YBfrgQlhK1YRcx2c42ztz6QudzBOoR96G8tKlq1B8wcnB0nc2e7r1rfmcfh7dx q/tFdfPEXLJT1MU0ZbIKPdK2KOHHpR54mbodOBrbavpzVYoZZK4lNhXM5KBj8GkQ5AX7 WoTjpsJe/p8sFjnc2yRD4h5MZc3FegA04o61QJRaqY6h4byRZUe9LJpexP5nyvi3CJIU rZF98RKC50cDe+JhgQuYWeF7x16KMSlgpddnZim4t0NwVUqORzr9PKXVENpUOLKtMtAd KDrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=v6ohUlE+; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=tUVNVZek; spf=pass (google.com: domain of linux-kernel+bounces-6360-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6360-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. [147.75.199.223]) by mx.google.com with ESMTPS id w13-20020a0c8e4d000000b0067f34c74eb7si7386149qvb.186.2023.12.19.20.20.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 20:20:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6360-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=v6ohUlE+; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=tUVNVZek; spf=pass (google.com: domain of linux-kernel+bounces-6360-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6360-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 9E8CF1C22133 for ; Wed, 20 Dec 2023 04:20:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67965200D8; Wed, 20 Dec 2023 04:18:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="v6ohUlE+"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="tUVNVZek" X-Original-To: linux-kernel@vger.kernel.org Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (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 DA35F1DA4D for ; Wed, 20 Dec 2023 04:18:35 +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.west.internal (Postfix) with ESMTP id E5C0B3200A34; Tue, 19 Dec 2023 23:18:34 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 19 Dec 2023 23:18:35 -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=1703045914; x= 1703132314; bh=MqOifYCucTPnKbf3hkszGvdZNwn7ZENwvdLMF39HtZM=; b=v 6ohUlE+Lfs0BtQd+J/Z313mMYLUgyZwsby8e4D0A90VohPRi8dR4wLE6aO1RlD+4 ppF7X5iGNBrHCE+7vAWvCMnelbMMbSYaBATQOtwcLvGOkXYdWsHcg984M6ulM2dJ KzuF9cLnvydouP8HcdtqftYKJ7k6qJ86fq9ep5oGZGwdwGMHSSFWvTesTg4xtuSJ Gz5fdiUzwMJu4+gmn4+Laezw5G5kLc+f20BvDem2MHupZHJpR0Sp0ENRlKzWpKyk 5/BEj8ZdljsGIYih0RMls+fF2cyAtmWxY2KGBEALE30WNPqV8mGi0Ok7DHYhs64i NlNLDBPiCReuUzsCH7T+w== 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=1703045914; x= 1703132314; bh=MqOifYCucTPnKbf3hkszGvdZNwn7ZENwvdLMF39HtZM=; b=t UVNVZekYdYMrbFmliSodW1ZOQjUVtaJxkaqFT+qeoRCV5hPPBTGjPF1vuKTbZX8s nBfS6rsLEyZVVvVz5+YYF2f1Cvb9W3DyomCrfBJ1BxIRJf8RB63tCRP1V1DDh3aM msuiz1HoXUvYn/UWXZGelfvw2kB/JMFdyDWWS3gd5bbivxihJWEpWIc/e/g5rSEi vNxG+ZW3bRsSgqdldXPaj0KNjZH3MPMfM4aFyASoGzl1xIwPV5Jmh7/vRCE8cVaf lSqwTjYptnm+NozdscOqDawpJ8pPWdOLEHIhBey1c2Fn/9e4WCJ2JM6unh2QrU9t +R4vCOdgx+AaFKvL4Jqgw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduuddgieelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Dec 2023 23:18:32 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: adamg@pobox.com Subject: [PATCH 8/8] firewire: core: change modalias of unit device with backward incompatibility Date: Wed, 20 Dec 2023 13:18:06 +0900 Message-Id: <20231220041806.39816-9-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231220041806.39816-1-o-takashi@sakamocchi.jp> References: <20231220041806.39816-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: 1785773180057085742 X-GMAIL-MSGID: 1785773180057085742 As the last part of support for legacy layout of configuration ROM, this commit traverses vendor directory as well as root directory when constructing modalias for unit device. The change brings loss of backward compatibility since it can fill model field ('mo') which is 0 at current implementation in the case. However, we can be optimistic against regression for unit drivers in kernel, due to some points: 1. ALSA drivers for audio and music units use the model fields to match device, however all of supported devices does not have such legacy layout. 2. the other unit drivers (e.g. sbp2) does not use the model field to match device. The rest of concern is user space application. The most of applications just take care of node device and does not use the modalias of unit device, thus the change does not affect to them. But systemd project is known to get affects from the change since it includes hwdb to take udev to configure fw character device conveniently. I have a plan to work for systemd so that the access permission of character device could be kept across the change. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 21 +++++++++++++++++++-- drivers/firewire/device-attribute-test.c | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 2bc6c874e89c..abcb0f036fcd 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_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/device-attribute-test.c b/drivers/firewire/device-attribute-test.c index da2a4a09bf84..2f123c6b0a16 100644 --- a/drivers/firewire/device-attribute-test.c +++ b/drivers/firewire/device-attribute-test.c @@ -178,7 +178,7 @@ static void device_attr_legacy_avc(struct kunit *test) }; struct device *node_dev = (struct device *)&node.device; struct device *unit0_dev = (struct device *)&unit0.device; - static const int unit0_expected_ids[] = {0x00012345, 0x00000000, 0x00abcdef, 0x00543210}; + static const int unit0_expected_ids[] = {0x00012345, 0x00fedcba, 0x00abcdef, 0x00543210}; char *buf = kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL); int ids[4] = {0, 0, 0, 0};