From patchwork Wed Dec 6 08:50:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 845069 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LqIe+8y/"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=de.bosch.com header.i=@de.bosch.com header.b="fhgeZTIy"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ysCH228Vyz9s4s for ; Wed, 6 Dec 2017 19:59:42 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iRSljclu7Nr5L1yT3LExdEkx8XXGFLPbOfyutMqBvKo=; b=LqIe+8y/l97+f9 oUXTMlbcarg14mUPGkNWJNeM202gj9K/V5moJTwrgzfBfkMQEzPlPPhflw5J5kyxbCN6w1OoD6EX4 aZqG7mrMSxvWwSv0A123A7BCM0N3YYceVEshik2J6Ajk2/lHZFovD3iox0UaOYifjQQQhRqI3/y9+ TrTBLU6sJaMDYMgbU7Zi4KCn7ut9KKDeh42uCy7AHIwIe6oTp3sY65IdNFYBjP1dkMLHpYZL7VU2E bWlQ9DEoVI8gOhB2HqunUFVCuYLVJXZeHziVEOkoiUZ/ll2jdMLfXJaEU8EIGrm+ci4oGU3eO+pwc lzdq7rkN3MTdH1TElRdA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eMVYG-0006fm-0R; Wed, 06 Dec 2017 08:59:36 +0000 Received: from imta21.fe.bosch.de ([139.15.243.226]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eMVXr-00068n-Ou for linux-mtd@lists.infradead.org; Wed, 06 Dec 2017 08:59:16 +0000 Received: from smtp6-v.fe.bosch.de (imta23.fe.bosch.de [139.15.243.227]) by imta21.fe.bosch.de (Postfix) with ESMTP id D93ABC09B0 for ; Wed, 6 Dec 2017 09:49:18 +0100 (CET) Received: from vsmta12.fe.internet.bosch.com (unknown [10.4.98.52]) by imta23.fe.bosch.de (Postfix) with ESMTP id 7D95C15801B4; Wed, 6 Dec 2017 09:48:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1512550089; bh=eQksyDOgK9eUOo6EfpSEeZh5Z0StvM2J6rFWqp5v52Y=; l=10; h=From:From:Reply-To:Sender; b=fhgeZTIy9O3GGRlkDnve4T2ckoDQYWtB2DUUY/9VPVKe3YseFbZYKdTuB9LRRsQGv aVqG4HHhibcpQTFU/0ZGMGgSXl2qMWNkgVpCw9zNfV3mSUV9dx6UvEdPqBDGrM2RL5 ylv0k+JHe/RgKozmnGI0UuPA1L6XZWIVe67n3e4w= Received: from SI-HUB1001.de.bosch.com (vsgw23.fe.internet.bosch.com [10.4.98.23]) by vsmta12.fe.internet.bosch.com (Postfix) with ESMTP id 7E6051B80759; Wed, 6 Dec 2017 09:50:42 +0100 (CET) Received: from HI-Z0EVG.hi.de.bosch.com (10.34.218.219) by SI-HUB1001.de.bosch.com (10.4.103.108) with Microsoft SMTP Server id 14.3.319.2; Wed, 6 Dec 2017 09:50:41 +0100 From: Dirk Behme To: , Richard Weinberger Subject: [PATCH 3/5] mtdram: Allow to enable/disable flight recorder mode at runtime. Date: Wed, 6 Dec 2017 09:50:37 +0100 Message-ID: <20171206085039.27164-4-dirk.behme@de.bosch.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171206085039.27164-1-dirk.behme@de.bosch.com> References: <20171206085039.27164-1-dirk.behme@de.bosch.com> MIME-Version: 1.0 X-Originating-IP: [10.34.218.219] X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-23510.005 X-TMASE-MatchedRID: X5ozMMNqzDoPv5/+N9RjEu7KTDtx8Cggvgj97y8eilZWLCpfN4pF7PlY oV6p/cSxpROtlYgxy5XyyB+gEfX5m5sYdIGP6PlZ4RtSDjG+z7BvAd/85EsfAZsoi2XrUn/Jn6K dMrRsL14qtq5d3cxkNcN9MitkD6wjtWL1UM/odDxoTfjRiF/ZKxqlt4UjlrCz+bnD0Oc/ch3sux 7mbEyXnWtxR75auxrM2Ynv9lyyjZVRvGoEv97UyztF7iEBca7BXyZ6pl/oDQ1+Az0rNWZh1oK3x HwHujePLauJU5NC5kJDDKa3G4nrLQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171206_005912_339134_FD80C750 X-CRM114-Status: UNSURE ( 9.23 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -7.0 (-------) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-7.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [139.15.243.226 listed in wl.mailspike.net] -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [139.15.243.226 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dirk.behme@de.bosch.com, manfred@colorfullife.com, Manfred Spraul Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Manfred Spraul The patch allows to enable/disable the flight recorder mode by writing to the debugfs file. Signed-off-by: Manfred Spraul Cc: Manfred Spraul --- drivers/mtd/devices/mtdram.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c index 1dc0a5ce0f07..a6f5a656eb94 100644 --- a/drivers/mtd/devices/mtdram.c +++ b/drivers/mtd/devices/mtdram.c @@ -87,8 +87,45 @@ static ssize_t nandrec_read_file(struct file *file, char __user *user_buf, return r; } +static ssize_t nandrec_write_file(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + ssize_t r; + char kbuf[8]; + + mutex_lock(&fr_mutex); + + *ppos = 0; + memset(kbuf, 0, sizeof(kbuf)); + + r = debugfs_file_get(fr_dentry); + if (likely(!r)) { + r = simple_write_to_buffer(kbuf, sizeof(kbuf) - 1, + ppos, buf, count); + debugfs_file_put(fr_dentry); + } + + if (r > 0) { + unsigned long newval; + int ret; + + ret = kstrtoul(kbuf, 0, &newval); + if (ret == 0) + fr_enabled = newval; + else + r = ret; + } + if (fr_enabled) + pr_info("MTDRAM flight recorder enabled.\n"); + else + pr_info("MTDRAM flight recorder disabled.\n"); + mutex_unlock(&fr_mutex); + return r; +} + static const struct file_operations fr_fops = { .read = nandrec_read_file, + .write = nandrec_write_file, .open = simple_open, };