From patchwork Tue May 22 14:17:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8877 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 4FA5723F0A for ; Tue, 22 May 2012 14:20:32 +0000 (UTC) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by fiordland.canonical.com (Postfix) with ESMTP id F36ADA18B74 for ; Tue, 22 May 2012 14:20:31 +0000 (UTC) Received: by vcbfk26 with SMTP id fk26so789733vcb.11 for ; Tue, 22 May 2012 07:20:31 -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=FKYaRf1Cm6Mfa3tqLm0Zy5XRCW1tmtgTSZ8d0DrnbNQ=; b=T4qucvg6SdegzXs0jgb4UUgetpBlf6iVzkekmTGCmJUoCxsU1WFw2h9UENSP8p7PzY o8iBzXzYAdXLxDnIWM+Axs269qrv+iGS9Bdcz/VqBkgGypHMhemee4NLqmb5Yv9Gk8MV grbPz0JdL4uedvDr4WHqhmgNKDrasNgj6ty7xUJSKT7stMax1nhEzkKQa6jfzXe4TTRG Ystu1huMerVtC+kGK/r4/KD9wB1Ca4lFZ6LZ+U/chZSBSR0xJuA+CGusknWc72qCZpuo FcNpuS+tGdtXE84y7ensIlf3Fs3ZDwJPKdGJn0IG7JwdzrETaU7SATLU0i1qx+gvFxWe y8gw== Received: by 10.50.222.202 with SMTP id qo10mr9880784igc.0.1337696431245; Tue, 22 May 2012 07:20:31 -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 o8csp369527ibd; Tue, 22 May 2012 07:20:30 -0700 (PDT) Received: by 10.68.138.161 with SMTP id qr1mr52363349pbb.37.1337696430226; Tue, 22 May 2012 07:20:30 -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.30 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 May 2012 07:20:30 -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 mail-pz0-f50.google.com with SMTP id h15so9932212dan.37 for ; Tue, 22 May 2012 07:20:30 -0700 (PDT) Received: by 10.68.229.65 with SMTP id so1mr80729588pbc.2.1337696429978; Tue, 22 May 2012 07:20:29 -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 pj5sm26855812pbb.51.2012.05.22.07.20.27 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 May 2012 07:20:29 -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 07/16] pstore/ram: Introduce ramoops_context.max_dump_count Date: Tue, 22 May 2012 07:17:50 -0700 Message-Id: <1337696279-8994-7-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: ALoCoQkiNwd8aGkegrCaZjihAGTBp61/NSzjbqd6MJBUAd1YlF55xa2vKojK0zGcsDlYb67Hgu94 So far it is the same as max_count, but this will change when we'll add support for other message types (e.g. console, mce, tracing). Signed-off-by: Anton Vorontsov Acked-by: Kees Cook --- fs/pstore/ram.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 453030f..cdaeda9 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -70,6 +70,7 @@ struct ramoops_context { bool ecc; unsigned int count; unsigned int max_count; + unsigned int max_dump_count; unsigned int read_count; struct pstore_info pstore; }; @@ -94,7 +95,7 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, struct ramoops_context *cxt = psi->data; struct persistent_ram_zone *prz; - if (cxt->read_count >= cxt->max_count) + if (cxt->read_count >= cxt->max_dump_count) return -EINVAL; *id = cxt->read_count++; @@ -172,7 +173,7 @@ static int ramoops_pstore_write(enum pstore_type_id type, size = prz->buffer_size - hlen; persistent_ram_write(prz, cxt->pstore.buf, size); - cxt->count = (cxt->count + 1) % cxt->max_count; + cxt->count = (cxt->count + 1) % cxt->max_dump_count; return 0; } @@ -182,7 +183,7 @@ static int ramoops_pstore_erase(enum pstore_type_id type, u64 id, { struct ramoops_context *cxt = psi->data; - if (id >= cxt->max_count) + if (id >= cxt->max_dump_count) return -EINVAL; persistent_ram_free_old(cxt->przs[id]); @@ -213,7 +214,7 @@ static int __init ramoops_probe(struct platform_device *pdev) /* Only a single ramoops area allowed at a time, so fail extra * probes. */ - if (cxt->max_count) + if (cxt->max_dump_count) goto fail_out; if (!pdata->mem_size || !pdata->record_size) { @@ -240,6 +241,7 @@ static int __init ramoops_probe(struct platform_device *pdev) } cxt->max_count = pdata->mem_size / pdata->record_size; + cxt->max_dump_count = cxt->max_count; cxt->count = 0; cxt->size = pdata->mem_size; cxt->phys_addr = pdata->mem_address; @@ -247,14 +249,14 @@ static int __init ramoops_probe(struct platform_device *pdev) cxt->dump_oops = pdata->dump_oops; cxt->ecc = pdata->ecc; - cxt->przs = kzalloc(sizeof(*cxt->przs) * cxt->max_count, GFP_KERNEL); + cxt->przs = kzalloc(sizeof(*cxt->przs) * cxt->max_dump_count, GFP_KERNEL); if (!cxt->przs) { err = -ENOMEM; dev_err(dev, "failed to initialize a prz array\n"); goto fail_out; } - for (i = 0; i < cxt->max_count; i++) { + for (i = 0; i < cxt->max_dump_count; i++) { size_t sz = cxt->record_size; phys_addr_t start = cxt->phys_addr + sz * i; @@ -303,6 +305,7 @@ fail_buf: fail_clear: cxt->pstore.bufsize = 0; cxt->max_count = 0; + cxt->max_dump_count = 0; fail_przs: for (i = 0; cxt->przs[i]; i++) persistent_ram_free(cxt->przs[i]);