From patchwork Tue May 22 14:17:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8874 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 638F723F0A for ; Tue, 22 May 2012 14:20:12 +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 3419BA18B68 for ; Tue, 22 May 2012 14:20:12 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so6655450yhp.11 for ; Tue, 22 May 2012 07:20:12 -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:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=JXRmC7DkYO/6DJlZdQ0bE1FO2s8I0Ti99f4nuNZjnWE=; b=RRYzOBMaYeyIE04J4eSfrj+DKtH9OGv7CCYQ4vLGYlUj4UZbl3OWwDvE94o0+UILXM 1w5TFrOnAWIsUrA7LPwA4alIJ4KAGSsyL7J8Qb5sQbgf0xfRn6RwJ0DiuQCN1W/Ipb6I FRAlrtdNUvFbfHt92R1OtLrkCEePAi0OIY3SfEG5lJU7O5o4Mlf3AOjN+O8o/+rdM2lN iVe0YWV9OZc/FeMEqWb8fYopNiUv+qLHPKIfEG8MXAqba9IVteYK0bgnqtsgQ3w55Blq bLRNBKFhpuS3MwPbTL0sF6WcVXbE/R0BQSPD2RmSvu57wyVmyIUVAzKqp8LCtHbvcHTa faDw== Received: by 10.50.185.233 with SMTP id ff9mr9625729igc.57.1337696411774; Tue, 22 May 2012 07:20:11 -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.35.72 with SMTP id o8csp369496ibd; Tue, 22 May 2012 07:20:11 -0700 (PDT) Received: by 10.68.213.104 with SMTP id nr8mr80879106pbc.26.1337696410076; Tue, 22 May 2012 07:20:10 -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 t9si31658112pbj.42.2012.05.22.07.20.09 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 May 2012 07:20:10 -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 h15so9932212dan.37 for ; Tue, 22 May 2012 07:20:09 -0700 (PDT) Received: by 10.68.204.227 with SMTP id lb3mr80510314pbc.92.1337696409432; Tue, 22 May 2012 07:20:09 -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 gq5sm25063766pbc.65.2012.05.22.07.20.07 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 May 2012 07:20:08 -0700 (PDT) From: Anton Vorontsov To: Greg Kroah-Hartman , Kees Cook , Colin Cross , Tony Luck Cc: Arnd Bergmann , John Stultz , Shuah Khan , 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/16] pstore/ram_core: Factor persistent_ram_zap() out of post_init() Date: Tue, 22 May 2012 07:17:47 -0700 Message-Id: <1337696279-8994-4-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <20120522141717.GA31574@lizard> References: <20120522141717.GA31574@lizard> X-Gm-Message-State: ALoCoQn+wWnKYa0REerOfm2BuPZd0kwGa1+4QJQ8zp85WwllYdi0x+sOBaXU7fsaskyopr+xWY3v A handy function that we will use outside of ram_core soon. But so far just factor it out and start using it in post_init(). Signed-off-by: Anton Vorontsov Acked-by: Kees Cook --- fs/pstore/ram_core.c | 11 ++++++++--- include/linux/pstore_ram.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index f6650d1..c5fbdbb 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c @@ -320,6 +320,13 @@ void persistent_ram_free_old(struct persistent_ram_zone *prz) prz->old_log_size = 0; } +void persistent_ram_zap(struct persistent_ram_zone *prz) +{ + atomic_set(&prz->buffer->start, 0); + atomic_set(&prz->buffer->size, 0); + persistent_ram_update_header_ecc(prz); +} + static void *persistent_ram_vmap(phys_addr_t start, size_t size) { struct page **pages; @@ -414,8 +421,7 @@ static int __init persistent_ram_post_init(struct persistent_ram_zone *prz, bool } prz->buffer->sig = PERSISTENT_RAM_SIG; - atomic_set(&prz->buffer->start, 0); - atomic_set(&prz->buffer->size, 0); + persistent_ram_zap(prz); return 0; } @@ -450,7 +456,6 @@ struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start, goto err; persistent_ram_post_init(prz, ecc); - persistent_ram_update_header_ecc(prz); return prz; err: diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h index 4491e8f..3b823d4 100644 --- a/include/linux/pstore_ram.h +++ b/include/linux/pstore_ram.h @@ -69,6 +69,7 @@ struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start, size_t size, bool ecc); void persistent_ram_free(struct persistent_ram_zone *prz); +void persistent_ram_zap(struct persistent_ram_zone *prz); struct persistent_ram_zone *persistent_ram_init_ringbuffer(struct device *dev, bool ecc);