From patchwork Sat May 26 13:07:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8987 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 BC7A523E37 for ; Sat, 26 May 2012 13:10:27 +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 85B48A18848 for ; Sat, 26 May 2012 13:10:27 +0000 (UTC) Received: by ggnf1 with SMTP id f1so1684386ggn.11 for ; Sat, 26 May 2012 06:10:27 -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=4yC2qCbP6eGDIu3jwJMZqiWG6/m+aPbGhJSTJhme7Fs=; b=HVe2R3mhDRdIQk++zRSvrohOELjQWQcZRQ+4A8z2ZBb4FY8AV+riTRAXGxzdngteLn cWY3LuJH38HBvmauBpI4YU6fvHADAzwWjlwtV4XQkYf76tMCEtJB7hjFBnuLoUUkGMD0 Jpx9bCdpPh0Tk6HSsVSnKMTN9wJs0dGBzMoKo0tCdZfyDzhhG8Nozm4RoHCo6WDtckJF FrtoYmDUo2b2182LPVX9FpukIyUTceYERjv7ziSHKsd2M5U6yN/ivS5/ZFPBhZekAQwy Tu9MjpAuFaZUhwhMZrL3DZMpLtVvTF7rgl5n+UP/q1VBt+jlQF21bnQqX7/2fRGJO4Xp U/CQ== Received: by 10.50.87.227 with SMTP id bb3mr920266igb.57.1338037826813; Sat, 26 May 2012 06:10:26 -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.24.148 with SMTP id v20csp85855ibb; Sat, 26 May 2012 06:10:26 -0700 (PDT) Received: by 10.68.241.8 with SMTP id we8mr7009451pbc.130.1338037826185; Sat, 26 May 2012 06:10:26 -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 jq5si9852641pbc.78.2012.05.26.06.10.26 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 May 2012 06:10:26 -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 rr4so3284454pbb.37 for ; Sat, 26 May 2012 06:10:26 -0700 (PDT) Received: by 10.68.224.103 with SMTP id rb7mr8062766pbc.23.1338037825689; Sat, 26 May 2012 06:10:25 -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 rt4sm12527969pbc.3.2012.05.26.06.10.23 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 May 2012 06:10:24 -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 3/5] pstore/ram_core: Factor persistent_ram_zap() out of post_init() Date: Sat, 26 May 2012 06:07:51 -0700 Message-Id: <1338037673-19909-3-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <20120526130650.GA6242@lizard> References: <20120526130650.GA6242@lizard> X-Gm-Message-State: ALoCoQnmpybz9La4nqBp2AM5riIbPtVCm4N7eiei+lm5HOjWN/1/pQsEaOIOsI1qUisip3irEpGw 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);