Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp555396ybv; Fri, 7 Feb 2020 04:28:07 -0800 (PST) X-Google-Smtp-Source: APXvYqxSY3qDEmdi29XUsetTqNz0bOFNmGsMifrLZNlUXvQh33d5VGQhjZc9k7qPyjYIq24X4Zfu X-Received: by 2002:a9d:7e99:: with SMTP id m25mr2457154otp.212.1581078487406; Fri, 07 Feb 2020 04:28:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581078487; cv=none; d=google.com; s=arc-20160816; b=UyjA6mrjrOpK1+aIvCT5z1pZRyiTiktvza6wSlvgv8OsqdEtPUtGhjnrHE6JLOQskO N18UOEQAtA+Y1hs0hDHqbtLJwoPcfcVEofx2eKit6YClMFKGwkvjRadVqx9AySF4tHdS XmTOEJniDIUlSgm/QW8QX4JqBZwhj8amuSnt2T2MQfHhJLSKg4s6Snoz6ghRyfflbZis iaitzjm/uRiocjCE7Lsz3uZ+rb1fC9DIczTxF+B/0VDiHjINIulNIyJyPqliL/cSXl09 ZTnKJYlQtG6O+geBMOO0BwwReWwSMIO41oqj8ph1C+/Cdu7+pM1H7LzhCDIBWOYMb45L ieuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=iM2RUlu38Myyeu80J0gojhw2HHMhTXgjLQCwcO1ehX8=; b=Klcu5CFoSs/wPdzC2lp6z5AwNUVWol9PFiuaFPJiaZaqdgAxDraJQfEQ9uupNYIt/l n19M99H9uc1swgWu1Z0tpHvrzRucK+aYDjYbACSKoeIpY3zu6SG8agLZxyDLQxeyT9BW 61jsq4pCsm/IUEaBTFdTHVtNN6qyTrE7lWU4pDGDm7pHxmxJwDZnHkiNa0BclenKRb6b ZgbS2B0CO7IvD9r7bEimqrUOsm+3OsFLi4qQ0Nz6secq8wspuEFpH8uGbSs8edt/y9QU 5GPYzU5ks/IZlarUd8/9XfCZGUGjZ/6jiQ7FHGUhn81P54BoL6SpogZq+kUTvbq6xZju E4xA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l5si1547473otn.35.2020.02.07.04.27.55; Fri, 07 Feb 2020 04:28:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727563AbgBGM0h (ORCPT + 99 others); Fri, 7 Feb 2020 07:26:37 -0500 Received: from smtp2207-205.mail.aliyun.com ([121.197.207.205]:47513 "EHLO smtp2207-205.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727458AbgBGM0T (ORCPT ); Fri, 7 Feb 2020 07:26:19 -0500 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.06718217|-1;CH=green;DM=CONTINUE|CONTINUE|true|0.275125-0.0157719-0.709104;DS=CONTINUE|ham_system_inform|0.0526277-0.000678506-0.946694;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03300;MF=liaoweixiong@allwinnertech.com;NM=1;PH=DS;RN=17;RT=17;SR=0;TI=SMTPD_---.GlaQplc_1581078351; Received: from PC-liaoweixiong.allwinnertech.com(mailfrom:liaoweixiong@allwinnertech.com fp:SMTPD_---.GlaQplc_1581078351) by smtp.aliyun-inc.com(10.147.41.137); Fri, 07 Feb 2020 20:26:08 +0800 From: WeiXiong Liao To: Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck , Jonathan Corbet , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Mauro Carvalho Chehab , "David S. Miller" , Rob Herring , Greg Kroah-Hartman , Jonathan Cameron , WeiXiong Liao Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH v2 10/11] blkoops: add interface for dirver to get information of blkoops Date: Fri, 7 Feb 2020 20:25:54 +0800 Message-Id: <1581078355-19647-11-git-send-email-liaoweixiong@allwinnertech.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1581078355-19647-1-git-send-email-liaoweixiong@allwinnertech.com> References: <1581078355-19647-1-git-send-email-liaoweixiong@allwinnertech.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's one of a series of patches for adaptive to MTD device. MTD device need to check size of recorder and get mtddev index to verify which mtd device to use. All it needs is defined in blkoops. So, there should be a interface for MTD driver to get all information it need. Signed-off-by: WeiXiong Liao --- fs/pstore/blkoops.c | 47 ++++++++++++++++++++++++++++++++++++----------- include/linux/blkoops.h | 10 ++++++++++ 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/fs/pstore/blkoops.c b/fs/pstore/blkoops.c index 7cf4731e52f7..4fc6ac4c69c5 100644 --- a/fs/pstore/blkoops.c +++ b/fs/pstore/blkoops.c @@ -102,6 +102,20 @@ #define DEFAULT_BLKDEV "" #endif +#define check_size(name, defsize, alignsize) ({ \ + long _##name_ = (name); \ + if ((name) < 0) \ + _##name_ = (defsize); \ + _##name_ = _##name_ <= 0 ? 0 : (_##name_ * 1024); \ + if (_##name_ & ((alignsize) - 1)) { \ + pr_info(#name " must align to %d\n", \ + (alignsize)); \ + _##name_ = ALIGN(name, (alignsize)); \ + } \ + _##name_; \ +}) + + /** * register device to blkoops * @@ -133,18 +147,10 @@ int blkoops_register_device(struct blkoops_device *bo_dev) bo_dev->flags = BLKOOPS_DEV_SUPPORT_ALL; #define verify_size(name, defsize, alignsize, enable) { \ long _##name_; \ - if (!(enable)) \ - _##name_ = 0; \ - else if ((name) >= 0) \ - _##name_ = (name); \ + if (enable) \ + _##name_ = check_size(name, defsize, alignsize);\ else \ - _##name_ = (defsize); \ - _##name_ = _##name_ <= 0 ? 0 : (_##name_ * 1024); \ - if (_##name_ & ((alignsize) - 1)) { \ - pr_info(#name " must align to %d\n", \ - (alignsize)); \ - _##name_ = ALIGN(name, (alignsize)); \ - } \ + _##name_ = 0; \ name = _##name_ / 1024; \ bzinfo->name = _##name_; \ } @@ -445,6 +451,25 @@ int blkoops_blkdev_info(dev_t *devt, sector_t *nr_sects, sector_t *start_sect) } EXPORT_SYMBOL_GPL(blkoops_blkdev_info); +/* get information of blkoops */ +int blkoops_info(struct blkoops_info *info) +{ + if (!blkdev[0] && strlen(DEFAULT_BLKDEV)) + snprintf(blkdev, 80, "%s", DEFAULT_BLKDEV); + + memcpy(info->device, blkdev, 80); + info->dump_oops = !!(dump_oops < 0 ? DEFAULT_DUMP_OOPS : dump_oops); + + info->dmesg_size = check_size(dmesg_size, DEFAULT_DMESG_SIZE, 4096); + info->pmsg_size = check_size(pmsg_size, DEFAULT_PMSG_SIZE, 4096); + info->ftrace_size = check_size(ftrace_size, DEFAULT_FTRACE_SIZE, 4096); + info->console_size = check_size(console_size, DEFAULT_CONSOLE_SIZE, + 4096); + + return 0; +} +EXPORT_SYMBOL_GPL(blkoops_info); + MODULE_LICENSE("GPL"); MODULE_AUTHOR("WeiXiong Liao "); MODULE_DESCRIPTION("Wrapper for Pstore BLK with Oops logger"); diff --git a/include/linux/blkoops.h b/include/linux/blkoops.h index 11cb3036ad5f..ea56f3f92360 100644 --- a/include/linux/blkoops.h +++ b/include/linux/blkoops.h @@ -81,4 +81,14 @@ int blkoops_register_blkdev(unsigned int major, unsigned int flags, void blkoops_unregister_blkdev(unsigned int major); int blkoops_blkdev_info(dev_t *devt, sector_t *nr_sects, sector_t *start_sect); +struct blkoops_info { + int dump_oops; + char device[80]; + unsigned long dmesg_size; + unsigned long pmsg_size; + unsigned long console_size; + unsigned long ftrace_size; +}; +int blkoops_info(struct blkoops_info *info); + #endif -- 1.9.1