From patchwork Sat May 12 00:17:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8538 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E208123E20 for ; Sat, 12 May 2012 00:19:04 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id B22DEA18C2E for ; Sat, 12 May 2012 00:19:04 +0000 (UTC) Received: by mail-gg0-f180.google.com with SMTP id f1so2209445ggn.11 for ; Fri, 11 May 2012 17:19:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:x-gm-message-state; bh=btZVUo54D/GXDKkXco2qOoGljg6K61oNlqZFiIdR8dE=; b=lRphqmCUbLjkyCRps0Oh4cuqmlQyWGo45GzoPBLxZiOB0gLyCVRm06K3a3H8vrw9Vv 8GX+SHqoYHJMoFJviO+6BQYw1/uyuMWb/e/C8TE98PJE5/eh0RoOW5UFVMyL7ebZZF/L gcag6/DDr+BcAcDgE8fiTJnQD5ww+1oxJdDU7KuZ1wqQbcLHcmSbcZBFYMRVF8XzqjNk Dtb4VaEsUv/ne1rdntHTRlcQzQ/enQSgNo3G8oyMHCmOuX47cVIjwxskVc+Y5vCcNslL 7HnbCcj+RDWNx3n72eyGvYOGW8on6+nkFj5ECUXgA+nhsrpTuWzgjo0bxUexU4AWt9Eh 8R2Q== Received: by 10.50.160.225 with SMTP id xn1mr8921igb.3.1336781944250; Fri, 11 May 2012 17:19:04 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.73.147 with SMTP id q19csp211495ibj; Fri, 11 May 2012 17:19:03 -0700 (PDT) Received: by 10.68.216.225 with SMTP id ot1mr305877pbc.46.1336781943290; Fri, 11 May 2012 17:19:03 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id p7si16168274pbk.254.2012.05.11.17.19.03 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 May 2012 17:19:03 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by pbbrr4 with SMTP id rr4so4860541pbb.37 for ; Fri, 11 May 2012 17:19:03 -0700 (PDT) Received: by 10.68.226.163 with SMTP id rt3mr316526pbc.41.1336781943036; Fri, 11 May 2012 17:19:03 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id i1sm14223429pbv.49.2012.05.11.17.19.00 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 May 2012 17:19:02 -0700 (PDT) Date: Fri, 11 May 2012 17:17:34 -0700 From: Anton Vorontsov To: Greg Kroah-Hartman , Kees Cook , Colin Cross Cc: Arnd Bergmann , John Stultz , arve@android.com, Rebecca Schultz Zavin , Jesper Juhl , Randy Dunlap , Stephen Boyd , Thomas Meyer , Andrew Morton , Marco Stornelli , WANG Cong , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com Subject: [PATCH 04/11] persistent_ram: Introduce persistent_ram_new() Message-ID: <20120512001734.GD14782@lizard> References: <20120512001506.GA8653@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120512001506.GA8653@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQkeCuJ758D8OVegYiqDpurAluiWW6Wa6nD2on5DBL7OCE5IPNf/77yLVqAh+qCtRNYthcuR The routine just creates a persistent ram zone at a specified address. For persistent_ram_init_ringbuffer() we'd need to add a 'struct persistent_ram' to the global list, and associate it with a device. We don't need all this complexity in pstore_ram, so we introduce the simple function. Signed-off-by: Anton Vorontsov --- drivers/staging/android/persistent_ram.c | 26 ++++++++++++++++++++++++++ drivers/staging/android/persistent_ram.h | 4 ++++ 2 files changed, 30 insertions(+) diff --git a/drivers/staging/android/persistent_ram.c b/drivers/staging/android/persistent_ram.c index ec23822..c0c3d32 100644 --- a/drivers/staging/android/persistent_ram.c +++ b/drivers/staging/android/persistent_ram.c @@ -412,6 +412,32 @@ static int __init persistent_ram_post_init(struct persistent_ram_zone *prz, bool return 0; } +struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start, + size_t size, + bool ecc) +{ + struct persistent_ram_zone *prz; + int ret = -ENOMEM; + + prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL); + if (!prz) { + pr_err("persistent_ram: failed to allocate persistent ram zone\n"); + goto err; + } + + ret = persistent_ram_buffer_map(start, size, prz); + if (ret) + goto err; + + persistent_ram_post_init(prz, ecc); + persistent_ram_update_header_ecc(prz); + + return prz; +err: + kfree(prz); + return ERR_PTR(ret); +} + static __init struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc) { diff --git a/drivers/staging/android/persistent_ram.h b/drivers/staging/android/persistent_ram.h index 5635355..8154d15 100644 --- a/drivers/staging/android/persistent_ram.h +++ b/drivers/staging/android/persistent_ram.h @@ -19,6 +19,7 @@ #include #include #include +#include struct persistent_ram_buffer; @@ -62,6 +63,9 @@ struct persistent_ram_zone { int persistent_ram_early_init(struct persistent_ram *ram); +struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start, + size_t size, + bool ecc); struct persistent_ram_zone *persistent_ram_init_ringbuffer(struct device *dev, bool ecc);