From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Mon, 24 Jan 2022 12:21:58 +0100 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nBxQ6-00Bopd-K5 for lore@lore.pengutronix.de; Mon, 24 Jan 2022 12:21:58 +0100 Received: from localhost ([127.0.0.1] helo=metis.ext.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1nBxQ5-0002ac-4k; Mon, 24 Jan 2022 12:21:57 +0100 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nBxQ3-0002Xe-7d; Mon, 24 Jan 2022 12:21:55 +0100 Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1nBxQ2-00C6vy-F1; Mon, 24 Jan 2022 12:21:53 +0100 Received: from mol by dude03.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1nBxQ0-00CemO-Np; Mon, 24 Jan 2022 12:21:52 +0100 From: Michael Olbrich To: oss-tools@pengutronix.de Date: Mon, 24 Jan 2022 12:21:42 +0100 Message-Id: <20220124112143.3016473-4-m.olbrich@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220124112143.3016473-1-m.olbrich@pengutronix.de> References: <20220124112143.3016473-1-m.olbrich@pengutronix.de> MIME-Version: 1.0 Subject: [OSS-Tools] [PATCH 3/4] state: support backend-diskuuid / backend-offset X-BeenThere: oss-tools@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: Pengutronix Public Open-Source-Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Olbrich Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "OSS-Tools" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: oss-tools-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false On some platforms (e.g. EFI on x86_64) the state backend can only be selected by a partiton UUID. On existing devices with a DOS partition table, there may be no spare partition available for state. This makes it possible to select the disk via UUID. The exact position is defined by an explicitly specified offset. The same patch was submittet to barebox: https://lore.barebox.org/barebox/20220124100458.2924679-4-m.olbrich@pengutronix.de/ Signed-off-by: Michael Olbrich --- src/barebox-state/state.c | 55 ++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/src/barebox-state/state.c b/src/barebox-state/state.c index 363ac8a5d485..f825ee6f1303 100644 --- a/src/barebox-state/state.c +++ b/src/barebox-state/state.c @@ -593,6 +593,7 @@ struct state *state_new_from_node(struct device_node *node, bool readonly) const char *backend_type; const char *storage_type = NULL; const char *alias; + const char *diskuuid; uint32_t stridesize; struct device_node *partition_node; off_t offset = 0; @@ -608,30 +609,48 @@ struct state *state_new_from_node(struct device_node *node, bool readonly) if (IS_ERR(state)) return state; - partition_node = of_parse_phandle(node, "backend", 0); - if (!partition_node) { - dev_err(&state->dev, "Cannot resolve \"backend\" phandle\n"); - ret = -EINVAL; - goto out_release_state; - } + ret = of_property_read_string(node, "backend-diskuuid", &diskuuid); + if (ret == 0) { + u64 off; + + ret = devpath_from_diskuuid(diskuuid, &state->backend_path); + if (ret) { + dev_err(&state->dev, "state failed find backend device for diskuuid='%s'\n", + diskuuid); + goto out_release_state; + } + ret = of_property_read_u64(node, "backend-offset", &off); + if (ret) { + dev_err(&state->dev, "'backend-offset' property undefined\n"); + goto out_release_state; + } + offset = off; + } else { + partition_node = of_parse_phandle(node, "backend", 0); + if (!partition_node) { + dev_err(&state->dev, "Cannot resolve \"backend\" phandle\n"); + ret = -EINVAL; + goto out_release_state; + } #ifdef __BAREBOX__ - ret = of_partition_ensure_probed(partition_node); - if (ret) - goto out_release_state; + ret = of_partition_ensure_probed(partition_node); + if (ret) + goto out_release_state; - ret = of_find_path_by_node(partition_node, &state->backend_path, 0); + ret = of_find_path_by_node(partition_node, &state->backend_path, 0); #else - ret = of_get_devicepath(partition_node, &state->backend_path, &offset, &size); + ret = of_get_devicepath(partition_node, &state->backend_path, &offset, &size); #endif - if (ret) { - if (ret != -EPROBE_DEFER) - dev_err(&state->dev, "state failed to parse path to backend: %s\n", - strerror(-ret)); - goto out_release_state; - } + if (ret) { + if (ret != -EPROBE_DEFER) + dev_err(&state->dev, "state failed to parse path to backend: %s\n", + strerror(-ret)); + goto out_release_state; + } - state->backend_reproducible_name = of_get_reproducible_name(partition_node); + state->backend_reproducible_name = of_get_reproducible_name(partition_node); + } ret = of_property_read_string(node, "backend-type", &backend_type); if (ret) { -- 2.30.2 _______________________________________________ OSS-Tools mailing list OSS-Tools@pengutronix.de