From patchwork Mon Mar 1 20:46:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1445753 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-secospa-onmicrosoft-com header.b=zozqbqPt; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DqC4N6GNZz9sS8 for ; Tue, 2 Mar 2021 07:47:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4662F82016; Mon, 1 Mar 2021 21:46:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.b="zozqbqPt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0DB3281FB9; Mon, 1 Mar 2021 21:46:35 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2060b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::60b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4F3BB81C7C for ; Mon, 1 Mar 2021 21:46:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EdkuAOUFjmM6DBw2T+ut6OUkTLjsVLjtm493/sIgBubjf6AXg1jsXYJXCBZ9dh9PI1WV5GUdnmOvmpWKQYAkhVeoSCIwJq8pxTrPdo5iM0HY1qAtuXia9jHWW0kIa1+jXtBrQXWU5vjgIXt6Oba2EPPZkSVo9JTBdzQyU+CHlpnLrYThTNoI7HbJLxJxMO1TY+NYeFW1oStVxzCf26qtkuOt+VIFEJ6u9Gx2hABgDOS8OqMyjBb7SxIBecQkleWLhX2XcVo/1l/URCEnb/Clj2GZGLi+DcMoqRi8Gs5xHLFVRmdqSrW3zrxi/Ez06HAikl1GL1t3prQnf3ERRoVACg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BD2JK5RBkIskOV8KAoPYLFEQlob+qKni2k/MrfQ17l8=; b=fDbe1xYWyie2ZlwoqFHXdAlzXLH6aU7ck1mh2J3f/eTQa3JjXEE9w1n7ap0DAE40zjkdI7tjETY0foUiYwP2ZDrPn92WG5mi5GQRL5HD0P5w63z3rfq6FzoH9ESdIyUFexEI/PqfxCCnzK3tCuyDisQ5zvM2fHTzY5POOmc6bEZcYGnt4DHBorSTPdD6ijzH5zzKAKVN9ayuj5M6QjihKK8GvsogqCGYT01y188pmlEQEr/S38SVLHzEMVmqE1yr6s4z/Wzrpy4ra/QR/8EWFqW+TK0impY9w9v4lcXzRN87s1ebMwPghskPJuF3A/d58vwKKq5io7Gzm5YFeyDJSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BD2JK5RBkIskOV8KAoPYLFEQlob+qKni2k/MrfQ17l8=; b=zozqbqPtcaUuHiO5NIdDrVD7eJNZohfWRJNookIHXDNWQP350j5C14FsNDVtaCYOvaPp5L4Bsh6OzHFpe6Mlqp+OghR3tUnZ6U9AezbPMPrXbJKmqJ/1Fd5RHMtLzaY9hCCdohDUtjipwidj6MhCZaM8mujoa/iu1SyxxpDt69s= Authentication-Results: chromium.org; dkim=none (message not signed) header.d=none;chromium.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DBAPR03MB6408.eurprd03.prod.outlook.com (2603:10a6:10:194::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.23; Mon, 1 Mar 2021 20:46:30 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::941:c90c:b9da:2290]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::941:c90c:b9da:2290%4]) with mapi id 15.20.3890.028; Mon, 1 Mar 2021 20:46:30 +0000 From: Sean Anderson To: Simon Glass , u-boot@lists.denx.de Cc: Sean Anderson , Alexandru Gagniuc , Bin Meng , Dario Binacchi , Marek Vasut , Michal Simek , Philippe Reynes , Samuel Holland , Ye Li Subject: [PATCH 3/5] sysinfo: Require that sysinfo_detect be called before other methods Date: Mon, 1 Mar 2021 15:46:01 -0500 Message-Id: <20210301204603.2730666-4-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210301204603.2730666-1-sean.anderson@seco.com> References: <20210301204603.2730666-1-sean.anderson@seco.com> X-Originating-IP: [50.195.82.171] X-ClientProxiedBy: BL1PR13CA0207.namprd13.prod.outlook.com (2603:10b6:208:2be::32) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from plantagenet.inhand.com (50.195.82.171) by BL1PR13CA0207.namprd13.prod.outlook.com (2603:10b6:208:2be::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.11 via Frontend Transport; Mon, 1 Mar 2021 20:46:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 59dfac90-d898-46fb-a677-08d8dcf316f4 X-MS-TrafficTypeDiagnostic: DBAPR03MB6408: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T/PAGiabLyXUve4XooDqjZaEdDmvbgy/Uif8HNKjeukObj52TZjP0pO68Mm3q3WRhbbGmgxG8J915QDqymQWgzYlYpQCoSCkUuYHCjPWl3FP6BIk0E/bbXD3kGEnEhq/1GFP84JHUuRmDgFPiCNtqE28MnZ4N98tEMRkKgA3kZswu2556IuWL0KNM6s2dzYb+6OLLVGd2Jcab0WkyTXJOrORDRjpIZQF7CqMeLFvVgk36oSpopHcnGYze+DmJFCYXoDWZZyjJkWsEj4Nuj7Mueyh0HYXBMlTnnYerFSENW7o32hBwMlufKStFV2PWp4AL5l3z+J2Ufm6F/fnmrqT5u0Bi3EDOF502PIkddQez6H5Ak9+ukXqi0PUa+4BILGEEUfvQEB9XEtWlvqfhrtod1aj+3JVt0cvrbcyTHFOsA3UaVcnJ1t5Tp+PjkXa1f01lwzPp08w3oFCBRrAro/Bg2/g93bMYa40LcZtkqJ4tWY5TGSjl1JrP/+/+tE7C0/AxV1vrLPvHQgECEYouANNeQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4523.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(39840400004)(376002)(136003)(366004)(396003)(346002)(316002)(86362001)(478600001)(186003)(6512007)(6486002)(36756003)(7416002)(26005)(1076003)(54906003)(16526019)(52116002)(83380400001)(6666004)(6506007)(956004)(66476007)(2616005)(66946007)(66556008)(5660300002)(2906002)(8676002)(4326008)(8936002)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: oPYlscUQGLMZRRZ687yWQ5JavmntueJeKFvflKDSNdmW86bb+OSnvvXdOutXIMyi1extxOf87ZxQSom/6ms6RxeCCyJwwcC7FJ8+cqR2fuFNi67fFaeOYLdUKy9zkCFF7yHjztDWadGKJAEaAsE6hkiTze2m+3QLcgly7RzL0pihBqD6nxldnwPnKj2ZeROZOCoTsMSjP3EOspXqF2xTjZwAbKBnj6SEudvIcVdXNh34w+OvG3oyllLEVaDb0y+3al3rDd11KiB53nTw3/yjev4QYulE7lOYuR7Z4jENnKY47IpZUHmWPBI0mSfae4A0vNNwpZyfH1BC8YJgz2vSKYemWubAxqiO2G+/1QP+CZNj+EYj+caGONm4Hlgw/TZgCzTEGbC1biML3ImNDMS9sXVbY14oDTEVwDfHvOYMAqj7rMlpW18eaKddcApDEVLEVqpaNXQLKtC2S3ecu28OM/D1l3MFYXeHupGX/ef7Zp2/XdS1mTX11H2//79v7FIpvU2s/Aya0C5PqkQyLE2H1KoGR6ftfsjEQp22fxmoavfHvVmvD+ybHAVTEUibhO6ddG/KTtmTfwjbOHcr+2MKQdCxq6DGQ1WLgOIyU85Kx/fUiQ0vDQQI5zqf+eqSoi45lZURpTCuVJam8yXwD4Pa7r0m8Ga5+sHqAFmm1Lrlx8Pn1v1KRUhQyJXjxFTWOR7d+KbsNSEoWIKp7bpCpysL0JeUjo5CCaJs7q5N5fP+32rfUBx9gkNVT6Vmpcww5CPtmtf6Fd+7zG/kiZN46woDXHo9wOJ241bvH0ERL1l50uc/wb5ZEeTYs3zb2K4o9fDCNrNyBpSTYt2zmyyvutzAAvym34nXNer+dlENP1g9aMDYLt17S6NjNMhkS/Is9TsPyNIPJoEW4z5WwOvuMuAYyHnHWrCn+zjk2Nf07OkShMJMMgEZnAWeHeB7ezys8YpTnBdaP4OE96WAYcukkdbGYnjaoFlkTW1XlS2EELkff6GWuAWPI6eFhrtsI3x/qjtYuhEHjCzndrpMnjEuhah1rQRKkEqI3SkXs2lDCsKBDTO9Jarpj+q5/ZABycCKzpe3JvrzwM2mrX3imx502c23UCfHFNfa3z6BanJvU6WKDjhTltMEAGF27VPW8BDhfhSNFWLRVKJ1vZJxc134LtrVwPR1z8mrKn0JSxJPXiRCsPZ08jCcnciXN3YNIS+pU0OaRvwS/h3/z5IJqObSuiiJago6+P1+b3yf8aIdg1DkwxkVssr+aEPEfz9itdM80Ggy/yXLr7SfLneprgWdsp7CHHUuE/a2i0Ve6y7x64yr/rlQURohKEprkrjLMA2lZJFb X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59dfac90-d898-46fb-a677-08d8dcf316f4 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2021 20:46:30.2485 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Qm8F4n0BG8CRM7KJwWoJjY/dKE+HSLeaiS21j0WOe/4FrF+6orJZnC7Qu3JftUW7bx4fOVclfwkC0MHGlqOOXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR03MB6408 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean This updates sysinfo documentation to document that detect() must be called first. This allows drivers to cache information in detect() and perform (cheaper) retrieval in the other accessors. This also modifies the only instance where this sequencing was not followed. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- common/spl/spl_fit.c | 4 ++++ include/sysinfo.h | 29 ++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index a6ad094e91..4d17582af5 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -116,6 +116,10 @@ static int spl_fit_get_image_name(const void *fit, int images, * no string in the property for this index. Check if the * sysinfo-level code can supply one. */ + rc = sysinfo_detect(sysinfo); + if (rc) + return rc; + rc = sysinfo_get_fit_loadable(sysinfo, index - i - 1, type, &str); if (rc && rc != -ENOENT) diff --git a/include/sysinfo.h b/include/sysinfo.h index 9386bdf49a..14c25fa15c 100644 --- a/include/sysinfo.h +++ b/include/sysinfo.h @@ -54,7 +54,8 @@ struct sysinfo_ops { * This operation might take a long time (e.g. read from EEPROM, * check the presence of a device on a bus etc.), hence this is not * done in the probe() method, but later during operation in this - * dedicated method. + * dedicated method. This method must be called before any other + * methods. * * Return: 0 if OK, -ve on error. */ @@ -67,7 +68,8 @@ struct sysinfo_ops { * @id: A unique identifier for the bool value to be read. * @val: Pointer to a buffer that receives the value read. * - * Return: 0 if OK, -ve on error. + * Return: 0 if OK, -ENOENT if called before @detect, else -ve on + * error. */ int (*get_bool)(struct udevice *dev, int id, bool *val); @@ -78,7 +80,8 @@ struct sysinfo_ops { * @id: A unique identifier for the int value to be read. * @val: Pointer to a buffer that receives the value read. * - * Return: 0 if OK, -ve on error. + * Return: 0 if OK, -ENOENT if called before @detect, else -ve on + * error. */ int (*get_int)(struct udevice *dev, int id, int *val); @@ -90,7 +93,8 @@ struct sysinfo_ops { * @size: The size of the buffer to receive the string data. * @val: Pointer to a buffer that receives the value read. * - * Return: 0 if OK, -ve on error. + * Return: 0 if OK, -ENOENT if called before @detect, else -ve on + * error. */ int (*get_str)(struct udevice *dev, int id, size_t size, char *val); @@ -98,7 +102,7 @@ struct sysinfo_ops { * get_fit_loadable - Get the name of an image to load from FIT * This function can be used to provide the image names based on runtime * detection. A classic use-case would when DTBOs are used to describe - * additionnal daughter cards. + * additional daughter cards. * * @dev: The sysinfo instance to gather the data. * @index: Index of the image. Starts at 0 and gets incremented @@ -120,6 +124,9 @@ struct sysinfo_ops { * * @dev: The device containing the information * + * This function must be called before any other accessor function for this + * device. + * * Return: 0 if OK, -ve on error. */ int sysinfo_detect(struct udevice *dev); @@ -131,7 +138,8 @@ int sysinfo_detect(struct udevice *dev); * @id: A unique identifier for the bool value to be read. * @val: Pointer to a buffer that receives the value read. * - * Return: 0 if OK, -ve on error. + * Return: 0 if OK, -ENOENT if called before sysinfo_detect(), else -ve on + * error. */ int sysinfo_get_bool(struct udevice *dev, int id, bool *val); @@ -142,7 +150,8 @@ int sysinfo_get_bool(struct udevice *dev, int id, bool *val); * @id: A unique identifier for the int value to be read. * @val: Pointer to a buffer that receives the value read. * - * Return: 0 if OK, -ve on error. + * Return: 0 if OK, -ENOENT if called before sysinfo_detect(), else -ve on + * error. */ int sysinfo_get_int(struct udevice *dev, int id, int *val); @@ -154,7 +163,8 @@ int sysinfo_get_int(struct udevice *dev, int id, int *val); * @size: The size of the buffer to receive the string data. * @val: Pointer to a buffer that receives the value read. * - * Return: 0 if OK, -ve on error. + * Return: 0 if OK, -ENOENT if called before sysinfo_detect(), else -ve on + * error. */ int sysinfo_get_str(struct udevice *dev, int id, size_t size, char *val); @@ -166,7 +176,8 @@ int sysinfo_get_str(struct udevice *dev, int id, size_t size, char *val); * function that returns the unique device. This is especially useful for use * in sysinfo files. * - * Return: 0 if OK, -ve on error. + * Return: 0 if OK, -ENOENT if called before sysinfo_detect(), else -ve on + * error. */ int sysinfo_get(struct udevice **devp);