From patchwork Wed Sep 2 23:24:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 513690 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 6B678140285 for ; Thu, 3 Sep 2015 09:25:17 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=BKNkFZsn; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EDF3D4B72B; Thu, 3 Sep 2015 01:25:13 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kVxfiXpTx_yK; Thu, 3 Sep 2015 01:25:13 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4839A4B6F5; Thu, 3 Sep 2015 01:25:13 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8DA2E4B667 for ; Thu, 3 Sep 2015 01:25:09 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XPhjfQQgzgY5 for ; Thu, 3 Sep 2015 01:25:09 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-io0-f175.google.com (mail-io0-f175.google.com [209.85.223.175]) by theia.denx.de (Postfix) with ESMTPS id 049694B662 for ; Thu, 3 Sep 2015 01:25:05 +0200 (CEST) Received: by ioii196 with SMTP id i196so38801072ioi.3 for ; Wed, 02 Sep 2015 16:25:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=leyI+/itY34MtyrOYn8dDYiuQEYr7FsQ7+WRBuGyrmU=; b=BKNkFZsnkUY8n9dOaHuD0GjTiwYPu5nhdFO5zHxaMA2gj5HRgo2AL7QDdFrvXnfAdD Vh1AT30HyKIrAsL80MVdcSOzOcnj5cxQufb8omuvS9UovQwMvSNBRvpiWC3JK1SCwWuB X66FYQHiBbWKziEMJ37iX/GD+SvNAtify/yJ9+UNMeBkKfoMj3EntTc6/uYaON4yHUf/ 3Tb18AEPJylMbrXNMZGeUNTovOpcLDYGDL5+fbEoFb0hHcQ5p1+UVNtlFI/ySgjqnt33 sDyxXjVxBL/WyOqcqO1jVR95LRYR1F1OZkNC29cqpfYZQIrgusWRM7N2OygArZV3R28k g6jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=leyI+/itY34MtyrOYn8dDYiuQEYr7FsQ7+WRBuGyrmU=; b=AAvFE9svBPCloHx+UxCI3V1MAuc/1EiMwmvkARHnN4AnYWlKrYwXo22Ywy+7tbdR3/ FKc7hhOY+Q8lfNJAU7LOxxD/WQcF5goyCEcIhFSH5hVBvXN+9A+wUpighBcpgPUkoDjz O5KXioJx2eeEtPymw3DK4uzvanrwCxQM44UmoLbd5LPScE6gKND+x9jKOVZJ2mj+TStN RZ1Ng8r/1TRl1YgWh8HpzLgXTrspMHkSNIYBKHJLCuGY4ZS+VhZRB6etozUDGMbboUUF p4Y2rvk6lm3917FKlVjzIIOJnxYt6zanIV63XAuh46Sar8gSYXWFwMR5SrjaqzUc5tkG 5kPQ== X-Gm-Message-State: ALoCoQk1gE10OfLlWgVp7+dR34vAsAS7mxYh77+/lZGuTaCxcRQzqMhqokMdqeYGX2H8Nv6EbMJC X-Received: by 10.107.130.84 with SMTP id e81mr12680872iod.77.1441236303712; Wed, 02 Sep 2015 16:25:03 -0700 (PDT) Received: from kaki.bld.corp.google.com ([2620:0:1005:1100:25de:a12c:6da4:a4c8]) by smtp.gmail.com with ESMTPSA id hh9sm3257235igb.18.2015.09.02.16.25.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Sep 2015 16:25:03 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 1FEF92207B9; Wed, 2 Sep 2015 17:25:01 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Wed, 2 Sep 2015 17:24:57 -0600 Message-Id: <1441236298-24506-1-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.5.0.457.gab17608 Cc: Marek Vasut , Tom Rini , Joe Hershberger , Marcel Ziswiler , Eric Nelson , Masahiro Yamada , Anton Habegger , Scott Wood , York Sun Subject: [U-Boot] [PATCH v2 1/2] Move malloc_cache_aligned() to its own header X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present malloc.h is included everywhere since it recently was added to common.h in this commit: 4519668 mtd/nand/ubi: assortment of alignment fixes This seems wasteful and unnecessary. We have been trying to trim down common.h and put separate functions into separate header files and that change goes in the opposite direction. Move malloc_cache_aligned() to a new header so that this can be avoided. The header would perhaps be better named as alignmem.h but it needs to be included after common.h and people might be confused by this. With the name memalign.h it fits nicely after malloc() in most cases. Signed-off-by: Simon Glass Acked-by: Marcel Ziswiler --- Changes in v2: None common/cmd_ubi.c | 2 +- drivers/mtd/nand/nand_util.c | 1 + fs/ubifs/super.c | 3 +++ fs/ubifs/ubifs.c | 2 ++ include/common.h | 9 --------- include/memalign.h | 25 +++++++++++++++++++++++++ lib/gzip.c | 1 + lib/zlib/zutil.c | 4 +++- 8 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 include/memalign.h diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index 10eea65..0460b4c 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -14,7 +14,7 @@ #include #include #include - +#include #include #include #include diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c index 21b4a61..71285b6 100644 --- a/drivers/mtd/nand/nand_util.c +++ b/drivers/mtd/nand/nand_util.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 0bf52db..41763a1 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -28,6 +28,9 @@ #include #else +#include +#include +#include #include #include #include diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index 4daa7fa..f7a0847 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -23,6 +23,8 @@ * Adrian Hunter */ +#include +#include #include "ubifs.h" #include diff --git a/include/common.h b/include/common.h index c12f402..c48e5bc 100644 --- a/include/common.h +++ b/include/common.h @@ -1060,15 +1060,6 @@ int cpu_release(int nr, int argc, char * const argv[]); #define DEFINE_CACHE_ALIGN_BUFFER(type, name, size) \ DEFINE_ALIGN_BUFFER(type, name, size, ARCH_DMA_MINALIGN) -#ifndef __ASSEMBLY__ -#include - -static inline void *malloc_cache_aligned(size_t size) -{ - return memalign(ARCH_DMA_MINALIGN, ALIGN(size, ARCH_DMA_MINALIGN)); -} -#endif - /* * check_member() - Check the offset of a structure member * diff --git a/include/memalign.h b/include/memalign.h new file mode 100644 index 0000000..f78b9dd --- /dev/null +++ b/include/memalign.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2015 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __ALIGNMEM_H +#define __ALIGNMEM_H + +/* + * ARCH_DMA_MINALIGN is defined in asm/cache.h for each architecture. It + * is used to align DMA buffers. + */ +#ifndef __ASSEMBLY__ +#include + +#include + +static inline void *malloc_cache_aligned(size_t size) +{ + return memalign(ARCH_DMA_MINALIGN, ALIGN(size, ARCH_DMA_MINALIGN)); +} +#endif + +#endif /* __ALIGNMEM_H */ diff --git a/lib/gzip.c b/lib/gzip.c index cd8e9fe..2c49e4e 100644 --- a/lib/gzip.c +++ b/lib/gzip.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "zlib/zutil.h" diff --git a/lib/zlib/zutil.c b/lib/zlib/zutil.c index 173a81d..227343e 100644 --- a/lib/zlib/zutil.c +++ b/lib/zlib/zutil.c @@ -43,7 +43,9 @@ void z_error (m) */ #ifndef MY_ZCALLOC /* Any system without a special alloc function */ -#ifndef __UBOOT__ +#ifdef __UBOOT__ +#include +#else #ifndef STDC extern voidp malloc OF((uInt size)); extern voidp calloc OF((uInt items, uInt size));