From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::341; helo=mail-wm1-x341.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AFFDC2119FF57 for ; Thu, 13 Dec 2018 02:55:24 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id n190so1879660wmd.0 for ; Thu, 13 Dec 2018 02:55:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dJy2YzUj32MzZp4EoKFTScDooUFfQEHNCdov5H7K7po=; b=PpY0s3gSm1eKlQSvCN3+xAYnC6Br01xK4knpRVu5WtMevmnD01Xqc2andssHX1Sg+1 TNcTKtfESVkqqDixng4jtPbqnYUSfhnRmMgWCM7valwUNxIWj/BGbjtgn5LuhS6EfNEn 5kOJhX+6wNUiM2gzE3GdbrXMK89kqbN0ld0Tg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dJy2YzUj32MzZp4EoKFTScDooUFfQEHNCdov5H7K7po=; b=gNGutT78BlRtzZ2v0Py1VIr5H9alPGhduawqqk8WUkPJolElRWXzCu2wqZCR87vrcV 5GmKHFgCS499dSQR1TpvPmSZ+ucLs3dzrFk3ms8cSP96qlWS1N6u51rn7ycqDilshPfG 3LCqz5A17q2IV1oHifs9beAEtX+K9l2u/6KLKNy2rM5GrMFxsNiviuoJHYriiGuIJV2g B4hMwbTM+SbL7wqAPn+Exgn18+3wTMdKqCZCfu3/WT+9M3VxXFL7Kw1gx29r0PQxyT0a X43AE/HPPboomav5YfYJp4DpKW8N4kSSUCn9f2d3zVOiaKErirIMKU5cjR2kBPf4Ia6/ 5p5A== X-Gm-Message-State: AA+aEWYxXVgPwC3FKuiQgRsqiJrJGOwMbxwdGR6JzK89G6LIkC/zigwM 13bbulYuTbnrkYYtzRWoG1v9fw== X-Google-Smtp-Source: AFSGD/XnCxN9gxu1Fmt4beFRqIgpB872ada4cqTwzAEeRXQpSj3oszmPRms8ktdwlkPkSa1bj4IDcA== X-Received: by 2002:a7b:c0c5:: with SMTP id s5mr10098563wmh.40.1544698522717; Thu, 13 Dec 2018 02:55:22 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id w16sm2234769wrp.1.2018.12.13.02.55.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 02:55:21 -0800 (PST) Date: Thu, 13 Dec 2018 10:55:20 +0000 From: Leif Lindholm To: Pete Batard Cc: Ard Biesheuvel , "edk2-devel@lists.01.org" Message-ID: <20181213105520.kgvssgdmdtk3i6tr@bivouac.eciton.net> References: <20181210123853.4864-1-pete@akeo.ie> <20181210123853.4864-4-pete@akeo.ie> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH v2 edk2-platforms 03/20] Platform/Broadcom/RPi3: Add GPIO and RTC libraries X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Dec 2018 10:55:25 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Dec 13, 2018 at 10:49:05AM +0000, Pete Batard wrote: > > > diff --git a/Platform/Broadcom/Bcm283x/Include/Utils.h b/Platform/Broadcom/Bcm283x/Include/Utils.h > > > new file mode 100644 > > > index 000000000000..47713275de3f > > > --- /dev/null > > > +++ b/Platform/Broadcom/Bcm283x/Include/Utils.h > > > @@ -0,0 +1,33 @@ > > > +/** @file > > > + * > > > + * Copyright (c) 2018, Andrei Warkentin > > > + * > > > + * This program and the accompanying materials > > > + * are licensed and made available under the terms and conditions of the BSD License > > > + * which accompanies this distribution. The full text of the license may be found at > > > + * http://opensource.org/licenses/bsd-license.php > > > + * > > > + * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > > > + * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > > > + * > > > + **/ > > > + > > > +#ifndef UTILS_H > > > +#define UTILS_H > > > + > > > +#define _IX_BITS(sm, bg) ((bg) - (sm) + 1) > > > +#define _IX_MASK(sm, bg) ((1ul << _IX_BITS((sm), (bg))) - 1) > > > +#define _X(val, sm, bg) ((val) >> (sm)) & _IX_MASK((sm), (bg)) > > > +#define X(val, ix1, ix2) (((ix1) < (ix2)) ? _X((val), (ix1), (ix2)) : \ > > > + _X((val), (ix2), (ix1))) > > > + > > > +#define _I(val, sm, bg) (((val) & _IX_MASK((sm), (bg))) << (sm)) > > > +#define I(val, ix1, ix2) (((ix1) < (ix2)) ? _I((val), (ix1), (ix2)) : \ > > > + _I((val), (ix2), (ix1))) > > > +#define _M(val, sm, bg) ((val) & (_IX_MASK((sm), (bg)) << (sm))) > > > +#define M(val, ix1, ix2) (((ix1) < (ix2)) ? _M((val), (ix1), (ix2)) : \ > > > + _M((val), (ix2), (ix1))) > > > + > > > +#define ELES(x) (sizeof((x)) / sizeof((x)[0])) > > > + > > > > The name of the file suggests that these are generic utility macros, > > and they use single letter identifiers. Not great for grep, so please > > improve the names (assuming that they are actually used anywhere) > > These macros are used. But I agree their naming should be better. > > Also, I'll double check if these macros are actually used in more than one > source, or if we can remove utils.h altogether and just move these macros > into the driver/library that requires them. ELES (if used) can be replaced with ARRAY_SIZE from Base.h. / Leif