From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0670EC433F5 for ; Wed, 9 Feb 2022 16:38:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0766E83EAF; Wed, 9 Feb 2022 17:38:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.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=konsulko.com header.i=@konsulko.com header.b="ELaYN4VS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C07983D3A; Wed, 9 Feb 2022 17:38:07 +0100 (CET) Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) (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 57D0B83EA2 for ; Wed, 9 Feb 2022 17:37:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x82e.google.com with SMTP id o3so2242136qtm.12 for ; Wed, 09 Feb 2022 08:37:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8qc2+wpVrOaddZTQVYKXiZQQVuIoQ24qEo/FtQtl2Pk=; b=ELaYN4VSV7Ypj3srAIGUWZ1MkBxgABgxuxQ33ffW92U0rF9FRt3hSp65SuetQ3u9n0 44OYZvRUPNKzaVwWU9a3bTEFNalbylql+R5q91Wkhatt7tS7vuJXC8248tiwdgkUxFHL eeajXWwP9Grui3kFk66V5ca8oG0n6X371C/AE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8qc2+wpVrOaddZTQVYKXiZQQVuIoQ24qEo/FtQtl2Pk=; b=liCwSUKeoZJ9sTteOGNd+gTerkQdDi0iypOcEz9d5wRFvWGyDkOODKx2cF8+p1jVCm SZRd53pBU1peY1JDXXqmLtqu1WlHDmO/hAX/V+isd3nA92UU26GfFQGhvTUSNa3Vg/K5 +yeVZmFMVmJodp00O7AXM7faO7rBt3QWz3SCSEvOYnt7xlKB9DEyDq4xe0pkfYm3N7ua 95fZfWEkS7OSmDUo3nhkr7Q9zh+XV94FiP8GYBeDUHn1iQaz02rb0GuXSxzjpSVi2t+o a+BjZ1D4+rmOi+33NVcu4zoEqd7JbwaVnYjMZgDNHlLqN2CaRLGcw8TphQ0hpyxVwfLD VaqQ== X-Gm-Message-State: AOAM533/gkWy/XByZzwqj9erg7G197KmYgd/kYQUai6aDysYd1EnGmP2 Xrg5E7tmlnsGQt08VMeWMz7VqA== X-Google-Smtp-Source: ABdhPJyFvuVnmoqCRnVbLP+dUl53ztOdC6GeTD6ICo1vB8Imk0KA1HjFcJDS7Rm0hOjAhIkayvgeVA== X-Received: by 2002:ac8:7a8a:: with SMTP id x10mr1965062qtr.500.1644424676106; Wed, 09 Feb 2022 08:37:56 -0800 (PST) Received: from bill-the-cat (2603-6081-7b01-cbda-2ef0-5dff-fedb-a8ba.res6.spectrum.com. [2603:6081:7b01:cbda:2ef0:5dff:fedb:a8ba]) by smtp.gmail.com with ESMTPSA id u11sm8778309qkp.21.2022.02.09.08.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 08:37:55 -0800 (PST) Date: Wed, 9 Feb 2022 11:37:53 -0500 From: Tom Rini To: Simon Glass Cc: U-Boot Mailing List , Rasmus Villemoes , Masahiro Yamada Subject: Re: [PATCH v5 05/13] kconfig: Add support for conditional values Message-ID: <20220209163753.GG7515@bill-the-cat> References: <20220122120734.2828739-1-sjg@chromium.org> <20220122050728.v5.5.I623f0db3bbfe77d70eafaa8b80da052623aa364c@changeid> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="uNJFlvTGIAMG9JN+" Content-Disposition: inline In-Reply-To: <20220122050728.v5.5.I623f0db3bbfe77d70eafaa8b80da052623aa364c@changeid> X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.5 at phobos.denx.de X-Virus-Status: Clean --uNJFlvTGIAMG9JN+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jan 22, 2022 at 05:07:26AM -0700, Simon Glass wrote: > At present if an optional Kconfig value needs to be used it must be > bracketed by #ifdef. For example, with this Kconfig setup: >=20 > config WIBBLE > bool "Support wibbles, the world needs more wibbles" >=20 > config WIBBLE_ADDR > hex "Address of the wibble" > depends on WIBBLE >=20 > then the following code must be used: >=20 > #ifdef CONFIG_WIBBLE > static void handle_wibble(void) > { > int val =3D CONFIG_WIBBLE_ADDR; >=20 > ... > } > #endif >=20 > static void init_machine() > { > ... > #ifdef CONFIG_WIBBLE > handle_wibble(); > #endif > } >=20 > Add a new IF_ENABLED_INT() to help with this. So now it is possible to > write, without #ifdefs: >=20 > static void handle_wibble(void) > { > int val =3D IF_ENABLED_INT(CONFIG_WIBBLE, CONFIG_WIBBLE_ADDR); >=20 > ... > } >=20 > static void init_machine() > { > ... > if (IS_ENABLED(CONFIG_WIBBLE)) > handle_wibble(); > } >=20 > The value will be CONFIG_WIBBLE_ADDR if CONFIG_WIBBLE is defined and will > produce a build error if not.. This allows us to reduce the use of #ifdef > in the code, ensuring that the compiler still checks the code even if it > is not ultimately used for a particular build. >=20 > Add a CONFIG_IF_ENABLED_INT() version as well. >=20 > If an attempt is made to use a value that does not exist (i.e. when the > conditional is not enabled), an error about a non-existing function is > generated, e.g.: >=20 > common/bloblist.c:447: undefined reference to `invalid_use_of_IF_ENABLED_= INT' >=20 > Signed-off-by: Simon Glass Applied to u-boot/master, thanks! --=20 Tom --uNJFlvTGIAMG9JN+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmID7eEACgkQFHw5/5Y0 tyypxwwAsc5BxnE0ugAJXMbMuDGJ+wqG1V5gccsbOHmfYCypfk0TQAFlbMZkBH72 yRInOvr/FkVviJviaVVjWc4JlGbksK1SXEO75jsc6wAnwYnDuCn/zaJj2sOT72Bj ArieZnJ+HO6ZhXn0s9SUXZtDUFIdNSUTygZ5c4/C4bVjZV8O8mJO1ygXm9IqfJu3 E9yljQrbwqIyqf0wobqIXfpxbYVwCqLKUs2NVtzrM7rnHBwK2fEkFAa/dQWtlV6t /mjX3jd2sutEz3iyH5x1z8mRDV+HCHP6sEqsdyDHL1P7qJo1XJ/brF7vRY48PENQ 7LK6IFoNuUs+eiAWejFBkj0nTE+GSjHQQHHh2douTltyqWMKlkN+2Bg1T8y5zOlx ZI6vtGsEx1tmBJJ0HAZB73hAq62CwqU3iws6t9WOYYaPdxdLGjr0cKAZRhtZYbqH mXhJMM8bkvckRjElIT7pvHs7uHi3+hPohMobYgS9ibXKW6MgxBa+iVpEk2ImJA/A ZIlmqoz6 =tYlu -----END PGP SIGNATURE----- --uNJFlvTGIAMG9JN+--