From patchwork Wed Jul 15 21:14:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sostalle X-Patchwork-Id: 6800721 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C91C9C05AD for ; Wed, 15 Jul 2015 21:18:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0431E204EB for ; Wed, 15 Jul 2015 21:18:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 092D6205B4 for ; Wed, 15 Jul 2015 21:18:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753752AbbGOVSE (ORCPT ); Wed, 15 Jul 2015 17:18:04 -0400 Received: from mga02.intel.com ([134.134.136.20]:56353 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753347AbbGOVRA (ORCPT ); Wed, 15 Jul 2015 17:17:00 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 15 Jul 2015 14:16:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,482,1432623600"; d="scan'208";a="763318913" Received: from dev.jf.intel.com ([134.134.147.11]) by fmsmga002.fm.intel.com with ESMTP; 15 Jul 2015 14:16:47 -0700 From: "Sean O. Stalley" To: corbet@lwn.net, vinod.koul@intel.com, bhelgaas@google.com, Julia.Lawall@lip6.fr, Gilles.Muller@lip6.fr, nicolas.palix@imag.fr, mmarek@suse.cz Cc: sean.stalley@intel.com, akpm@linux-foundation.org, bigeasy@linutronix.de, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, cocci@systeme.lip6.fr Subject: [PATCH 2/4] mm: Add dma_pool_zalloc() call to DMA API Date: Wed, 15 Jul 2015 14:14:41 -0700 Message-Id: <1436994883-16563-3-git-send-email-sean.stalley@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436994883-16563-1-git-send-email-sean.stalley@intel.com> References: <1436994883-16563-1-git-send-email-sean.stalley@intel.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a wrapper function for dma_pool_alloc() to get zeroed memory. Signed-off-by: Sean O. Stalley --- Documentation/DMA-API.txt | 7 +++++++ include/linux/dmapool.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt index 5208840..988f757 100644 --- a/Documentation/DMA-API.txt +++ b/Documentation/DMA-API.txt @@ -104,6 +104,13 @@ crossing restrictions, pass 0 for alloc; passing 4096 says memory allocated from this pool must not cross 4KByte boundaries. + void *dma_pool_zalloc(struct dma_pool *pool, gfp_t mem_flags, + dma_addr_t *handle) + +Wraps dma_pool_alloc() and also zeroes the returned memory if the +allocation attempt succeeded. + + void *dma_pool_alloc(struct dma_pool *pool, gfp_t gfp_flags, dma_addr_t *dma_handle); diff --git a/include/linux/dmapool.h b/include/linux/dmapool.h index 022e34f..6d8079b 100644 --- a/include/linux/dmapool.h +++ b/include/linux/dmapool.h @@ -22,6 +22,12 @@ void dma_pool_destroy(struct dma_pool *pool); void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, dma_addr_t *handle); +static inline void *dma_pool_zalloc(struct dma_pool *pool, gfp_t mem_flags, + dma_addr_t *handle) +{ + return dma_pool_alloc(pool, mem_flags | __GFP_ZERO, handle); +} + void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr); /*