Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp420842lqs; Thu, 13 Jun 2024 14:10:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVeKyi/L1KVyBU62wtgSPYDczhzK2D6+M5qRNFHRENOQuHylJNr8fIMR6ZMznPSyztbXfyRVq7E4G9aKXYBLheeHhFn+VrWDYL+cmhgLQ== X-Google-Smtp-Source: AGHT+IEPGSf14KB4DKi8zNO31NE37Lu9Wa5TSWL70uSYo7YtiYNm0R9QQkq+PrHefYZtwLlTW2qG X-Received: by 2002:a05:620a:4091:b0:796:1e34:a0a with SMTP id af79cd13be357-798d24226b5mr73677185a.23.1718313028481; Thu, 13 Jun 2024 14:10:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718313028; cv=pass; d=google.com; s=arc-20160816; b=bkkGfaFfgHLxeL4Of+8ayt7FaRZWg4YnefZCVY/Rys/nXQ63fDDKt5aq3m7wChjx2i ITH60zK8xNvE+X8JD3FOh6l2bA/AKksiWKFP/zj0nlTU16RhaNphs8bsGSGVIqeNfADX QUSm8lt6BH+aYi9bxwrPsMTmIt0hkwMQZhUlzu20A14LLHNZobQ67+PS5R4O9PTLOdjs 5yD6/V3W1k49imxtk9GtM7wGJhBKrcRLCc1pIfi6cX4Jxxy4zTHr5Od+DUzW3ujGb0ip /FgE/9CnMScUvuhfQtKp0bCVW1E1Lvd+C6zh3OnTL+IkoaMgiUcYTCu0YY9CbhCJ+7Lv F3tA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:date:message-id:dkim-signature; bh=Zf/D0AMDmsG7+mRQtcpHFjZ6BvLst9hXH1WNYtGV8o0=; fh=6YPxqK3ssdvcxPBEATrew2xqJUisGWQEZZnmSUzizEY=; b=sKT2QDz1Z0LRlC9ecdcc/R2Ogrig7Vm2tQ/LMtffNXLMZ18LR+Am9CvJKrRBgVJb8/ I5PstvYJp69vjPrahSNwu4WSvkCM9ByYyuQgnRDly/RAwZT9IEp0QpqNZ+CHoLTOTqG/ 70xl+c9CIN77sachN4MczrmOkHvwfutIe8QG2D4jOUe6U5UTaCzE8csL2Iu2FKrBvta4 uwBOJdBQQwpdsZy8/I2PhM27hGxCN7x31iLnfPAY1YN76Ct+ydPV2rx//oOJ0EfOCdUn VI+7clfztmcwP1gGlXp5Kvfk118dumsFBzuPw2HD3eikLyBkdvIeho8xDVrtCoZTUCIE zvGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@hauke-m.de header.s=MBO0001 header.b=sivM0bTx; arc=pass (i=1 spf=pass spfdomain=hauke-m.de dkim=pass dkdomain=hauke-m.de); spf=pass (google.com: domain of linux-kernel+bounces-214012-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214012-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-798aac9bad4si245167685a.25.2024.06.13.14.10.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 14:10:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214012-linux.lists.archive=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=@hauke-m.de header.s=MBO0001 header.b=sivM0bTx; arc=pass (i=1 spf=pass spfdomain=hauke-m.de dkim=pass dkdomain=hauke-m.de); spf=pass (google.com: domain of linux-kernel+bounces-214012-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214012-linux.lists.archive=gmail.com@vger.kernel.org" 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 258181C225B7 for ; Thu, 13 Jun 2024 21:10:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9FF1313CFB6; Thu, 13 Jun 2024 21:10:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hauke-m.de header.i=@hauke-m.de header.b="sivM0bTx" Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) (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 35A1D139CE2; Thu, 13 Jun 2024 21:10:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718313016; cv=none; b=R+LgeZeAZeRwqKc6K+P6kZsu/LOY36KsD+hNyJXpcbOhe84sNAIiUz/MrOsrmX8NO3jgY53kBrlLgQhSI6aql9aEghcSlvrLM0aAz43GItNz7X7Y0JvH26qlzstBIZCPeo/6Qa+kjeDOgQrNhvHB9D5M6eavHfWzTZQ6127voO4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718313016; c=relaxed/simple; bh=1J4WLBtZ95L8XtXYwCU1lBJTRVbRe4D591TuQlCYEHM=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=HnrjlAuleO0nRK4dPAt1Y3F5lKR8qMtYWsNK2Q6HRogDTwDnJay4YN8Lwg9hTlt8xthdTgv9i2nA4eoArFTntde5zGGiFi4o/hf2MuA7Dg6LVCIbNuLLFT7b37xsHs1Uy4iiyXXc+dmqupQlDjEhDQGYAOOthEkzMaZ5c18amuM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hauke-m.de; spf=pass smtp.mailfrom=hauke-m.de; dkim=pass (2048-bit key) header.d=hauke-m.de header.i=@hauke-m.de header.b=sivM0bTx; arc=none smtp.client-ip=80.241.56.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hauke-m.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hauke-m.de Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4W0Zmy33WLz9sPq; Thu, 13 Jun 2024 23:10:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hauke-m.de; s=MBO0001; t=1718313010; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zf/D0AMDmsG7+mRQtcpHFjZ6BvLst9hXH1WNYtGV8o0=; b=sivM0bTxsqdxmFANQaTA5jst3UhQRRoBhxKaU4DCdHIjOp5u+0tVO/l4/8oPPdfXBuy0su q+0bDukQL6xZ7573zc92yW924ivLssKZ/Q8gC3PFvj28t3GYmeC8IMJGYwB4MoH4LEUsNL l9OC6FT83P2hXD0KbUyBkf3gETKgGWi2HWrwOtOII/lpj250pXPiKG+4xjzlaZ4xTwPSQI 0paINADGZDr8vTYHVc6eFPgXFa8L5N1mNNeL8MI7oBI9UE2negABMB8ecTyrhtuM2UYUX3 DnxZvp8BhZvWQCqLDhPup9ze6paM7fLaxfvKXM+6k7zHTas63jgmI63sCx6XiA== Message-ID: <93428cdd-301a-46d7-84ef-e5c8ad42f495@hauke-m.de> Date: Thu, 13 Jun 2024 23:09:55 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v2 2/9] block: partitions: populate fwnode To: Daniel Golle , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Ulf Hansson , Jens Axboe , Srinivas Kandagatla , Dave Chinner , Jan Kara , Christian Brauner , =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= , Al Viro , Li Lingfeng , Christian Heusel , Min Li , Avri Altman , Adrian Hunter , Hannes Reinecke , Mikko Rapeli , Yeqi Fu , Victor Shih , Christophe JAILLET , Li Zhijian , "Ricardo B. Marliere" , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, linux-block@vger.kernel.org References: <3329bf2fa25695934b392944ff977ae95dc8c02d.1717031992.git.daniel@makrotopia.org> Content-Language: en-US From: Hauke Mehrtens In-Reply-To: <3329bf2fa25695934b392944ff977ae95dc8c02d.1717031992.git.daniel@makrotopia.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4W0Zmy33WLz9sPq Hi Daniel, On 5/30/24 04:13, Daniel Golle wrote: > Let block partitions to be represented by a firmware node and hence > allow them to being referenced e.g. for use with blk-nvmem. > > Signed-off-by: Daniel Golle > --- > block/partitions/core.c | 41 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) > > diff --git a/block/partitions/core.c b/block/partitions/core.c > index ab76e64f0f6c..93d109409905 100644 > --- a/block/partitions/core.c > +++ b/block/partitions/core.c > @@ -10,6 +10,8 @@ > #include > #include > #include > +#include > + > #include "check.h" > > static int (*const check_part[])(struct parsed_partitions *) = { > @@ -281,6 +283,43 @@ static ssize_t whole_disk_show(struct device *dev, > } > static const DEVICE_ATTR(whole_disk, 0444, whole_disk_show, NULL); > > +static struct fwnode_handle *find_partition_fwnode(struct block_device *bdev) > +{ > + struct fwnode_handle *fw_parts, *fw_part; > + struct device *ddev = disk_to_dev(bdev->bd_disk); > + const char *partname, *uuid; > + u32 partno; > + > + fw_parts = device_get_named_child_node(ddev, "partitions"); > + if (!fw_parts) > + fw_parts = device_get_named_child_node(ddev->parent, "partitions"); Could you please explain why you try to get the node from the device and the parent when it is not available? I think this should go into the commit description. > + > + if (!fw_parts) > + return NULL; > + > + fwnode_for_each_child_node(fw_parts, fw_part) { > + if (!fwnode_property_read_string(fw_part, "uuid", &uuid) && > + (!bdev->bd_meta_info || strncmp(uuid, > + bdev->bd_meta_info->uuid, > + PARTITION_META_INFO_UUIDLTH))) I think you should check that the uuid provided in the device tree is not longer than PARTITION_META_INFO_UUIDLTH. Same for the volume name. > + continue; > + > + if (!fwnode_property_read_string(fw_part, "partname", &partname) && > + (!bdev->bd_meta_info || strncmp(partname, > + bdev->bd_meta_info->volname, > + PARTITION_META_INFO_VOLNAMELTH))) > + continue; > + > + if (!fwnode_property_read_u32(fw_part, "partno", &partno) && > + bdev_partno(bdev) != partno) > + continue; > + > + return fw_part; > + } > + > + return NULL; > +} > + > /* > * Must be called either with open_mutex held, before a disk can be opened or > * after all disk users are gone. > @@ -355,6 +394,8 @@ static struct block_device *add_partition(struct gendisk *disk, int partno, > goto out_put; > } > > + device_set_node(pdev, find_partition_fwnode(bdev)); > + > /* delay uevent until 'holders' subdir is created */ > dev_set_uevent_suppress(pdev, 1); > err = device_add(pdev); Hauke