From patchwork Sat May 12 00:17:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8537 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 ABCA923E20 for ; Sat, 12 May 2012 00:18:54 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 7C6BFA18C2A for ; Sat, 12 May 2012 00:18:54 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so4054664yhp.11 for ; Fri, 11 May 2012 17:18:54 -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=aNO+xAcSYBnhUYu9KSr7KEAF8wpVhpFRuGXjyKRlpnY=; b=FK+WREAEgWSc/sGsWB/FfCGORhR/WrxesJtqFRqjN6nzA1G25Zb6HsMw5YQXO5d2eh /08QJ1Z+mP+2r5YG/inbwsqdQ2XN6Zd3feYHm9THD4M4PkBFcvTUREtcIxB6DdMaqfbn y1b7eoiqY6N9Q6CyxvRVAO7u3vxV3Eez9oJVQ8EkreM82Cdc83W90+ogV0baZ8ifuG36 yiw3ImxGmmafRiRg1nzxe4VAXEb4tEFxSWdJMCvUkRkdCaSQi4iWT8F3Y285TfTBuFla lJdAzVqq7rfTHMvpqNP3/GNdk9S6sMAX7AsteFVw1zl31eei7JFdmfdha8fx93CrDOTl yrlQ== Received: by 10.50.89.168 with SMTP id bp8mr43436igb.3.1336781934026; Fri, 11 May 2012 17:18:54 -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 q19csp211483ibj; Fri, 11 May 2012 17:18:53 -0700 (PDT) Received: by 10.68.226.99 with SMTP id rr3mr300078pbc.48.1336781933282; Fri, 11 May 2012 17:18:53 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id wh10si6556498pbc.131.2012.05.11.17.18.53 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 May 2012 17:18:53 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.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 danh15 with SMTP id h15so4584779dan.37 for ; Fri, 11 May 2012 17:18:53 -0700 (PDT) Received: by 10.68.229.100 with SMTP id sp4mr297296pbc.47.1336781933000; Fri, 11 May 2012 17:18:53 -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 py6sm14250928pbc.13.2012.05.11.17.18.50 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 May 2012 17:18:52 -0700 (PDT) Date: Fri, 11 May 2012 17:17:25 -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 03/11] persistent_ram: Introduce persistent_ram_post_init() Message-ID: <20120512001725.GC14782@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: ALoCoQnsin/XN7BBDCTZYk8zWezroyQuvxjYWg+wpuY+YQg7OcOFQL9Dm2cUmzsiXko3zwWHtemG Factor post init logic out of __persistent_ram_init(), we'll need it for the new persistent_ram_new() routine. Signed-off-by: Anton Vorontsov --- drivers/staging/android/persistent_ram.c | 44 ++++++++++++++++++------------ 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/drivers/staging/android/persistent_ram.c b/drivers/staging/android/persistent_ram.c index 13a12bc..ec23822 100644 --- a/drivers/staging/android/persistent_ram.c +++ b/drivers/staging/android/persistent_ram.c @@ -378,28 +378,15 @@ static int __init persistent_ram_buffer_init(const char *name, return -EINVAL; } -static __init -struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc) +static int __init persistent_ram_post_init(struct persistent_ram_zone *prz, 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_init(dev_name(dev), prz); - if (ret) { - pr_err("persistent_ram: failed to initialize buffer\n"); - goto err; - } + int ret; prz->ecc = ecc; + ret = persistent_ram_init_ecc(prz, prz->buffer_size); if (ret) - goto err; + return ret; if (prz->buffer->sig == PERSISTENT_RAM_SIG) { if (buffer_size(prz) > prz->buffer_size || @@ -422,6 +409,29 @@ struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc) atomic_set(&prz->buffer->start, 0); atomic_set(&prz->buffer->size, 0); + return 0; +} + +static __init +struct persistent_ram_zone *__persistent_ram_init(struct device *dev, 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_init(dev_name(dev), prz); + if (ret) { + pr_err("persistent_ram: failed to initialize buffer\n"); + goto err; + } + + persistent_ram_post_init(prz, ecc); + return prz; err: kfree(prz);