Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D2ABC433F5 for ; Mon, 27 Sep 2021 15:37:15 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A47B460F6C for ; Mon, 27 Sep 2021 15:37:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A47B460F6C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 55579800AA; Mon, 27 Sep 2021 17:37:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DjMSwiOM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E650680202; Mon, 27 Sep 2021 17:37:10 +0200 (CEST) Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D120780098 for ; Mon, 27 Sep 2021 17:37:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.nuke.me@gmail.com Received: by mail-qv1-xf34.google.com with SMTP id n6so3169577qvp.7 for ; Mon, 27 Sep 2021 08:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=IkwPEVUxGYlmGJzy5TiT7gxRH1/w3h2Oj2GNlXY3z/Q=; b=DjMSwiOMw082TLhaYhYN433Uq7nPGTDM3tvpKgHYS8BH58Ta7MPEp68yTf+qv4FEbB 4k5bKt7/K/su8l4XrvqtrWgiWsbtk9xyw3t2C00m6cj5OrrGGIho9VocjaKE/ty7JRUI hTB2pOb+GbZshA5sj/YKoJyUfhDefJK1lHG2Ezgk7NCFEi48t7Gi9Vhj/u0N2C47b6e7 zAy4HNIr5RCbCcz855pqO/tqnNgmH/9Pp4tdmagMb87RfbsMpKUD1wRxPpGDMpDqFLzq B33UGGAeTUyjlSFGEpyIGtOayRW6T2FTAedSwGnrmubWbtR04h4lFf13o6uYMZMs7vrb RZew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=IkwPEVUxGYlmGJzy5TiT7gxRH1/w3h2Oj2GNlXY3z/Q=; b=h6HyUFDVWaLpaZXiRvkOiJQ9N4Zy0TS6vNwKVKP0XarRBZpd12b/BZLZ02SEJIAA/T 1e/7lqoi3GnjV0Ms7qkX95Z1Zyg2RSy72YjtI3NFrElPlBF+lJ3410gxMitdmVEAwCe1 kZpJQcFHXq3XvLhruMUYILzzeAxlA2LWLtiHgAkdNi46z0YvCmYLjduf1k+lFeczOnE+ L9WNtXJv54Ojmof2VWUSPJDQQ6BG6MZWm7t+IgIr04GnOPVr/5wt8Qvv0hiQQG0tGEJQ F/Zac2+LqRHdhujyNFnRqeJcHonoUorbK2FtiSKJ8kYG2gNJ3SChUnqHbdjFTBiIh3hb d22A== X-Gm-Message-State: AOAM530QnpKZNa9mUaskAl4didtee0eWvvTLupKx30zMLtOb/ttA2KRa SrHNaQ1bKLDcjDA4Z96rAAvlXLvK4ns= X-Google-Smtp-Source: ABdhPJxaE+YfxRi89qh00UjY+cyOI+e2iOoKCz3F7kWDxZwY0Lzf+OqHl9gKl21TlBSBmIh6QJCAHA== X-Received: by 2002:ad4:4824:: with SMTP id h4mr417643qvy.51.1632757025009; Mon, 27 Sep 2021 08:37:05 -0700 (PDT) Received: from nuclearis3.gtech (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id f24sm10998658qtq.25.2021.09.27.08.37.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Sep 2021 08:37:04 -0700 (PDT) Subject: Re: [PATCH 2/4] dm: hash: Add new UCLASS_HASH support To: Simon Glass Cc: Chia-Wei Wang , Tom Rini , U-Boot Mailing List References: <20210730010805.17845-1-chiawei_wang@aspeedtech.com> <20210730010805.17845-3-chiawei_wang@aspeedtech.com> From: "Alex G." Message-ID: <0f23a558-c5cc-6fb5-0a78-1270c0c94053@gmail.com> Date: Mon, 27 Sep 2021 10:37:02 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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.103.2 at phobos.denx.de X-Virus-Status: Clean On 9/23/21 9:49 PM, Simon Glass wrote:> On Thu, 16 Sept 2021 at 09:43, Alex G. wrote: >> On 7/29/21 8:08 PM, Chia-Wei Wang wrote: >>> + >>> +enum HASH_ALGO hash_algo_lookup_by_name(const char *name) >> >> string -> hash_lookup_algo() -> ops struct >> >> Is the current way to do things. hash_algo_lookup_by_name() does the >> roundabout through an enum. That doesn't make sense to me. > > Actually I'd like to see an enum to describe these, since looking up a > string is less efficient in a bootloader. So some way of doing that > seems good to me. > > Of course it means we need a global list of this algos in a header > file and each driver needs to indicate which one(s) it supports. Let's assume strcmp() takes a lot of efforts. For a lot of cases, the algo comes in as a string. Think about FIT and image signature verification. So we have to do the strcmp() anyway, making the enum roundabout.