From patchwork Tue Sep 22 16:37:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 7241091 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F1A119F443 for ; Tue, 22 Sep 2015 16:41:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F3627208CA for ; Tue, 22 Sep 2015 16:41:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB644208C4 for ; Tue, 22 Sep 2015 16:41:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZeQZb-0007QA-VE; Tue, 22 Sep 2015 16:37:44 +0000 Received: from mail.skyhub.de ([2a01:4f8:120:8448::d00d]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZeQZO-000764-Uz for linux-arm-kernel@lists.infradead.org; Tue, 22 Sep 2015 16:37:32 +0000 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alien8.de; s=alien8; t=1442939828; bh=qw20OHeE1bx4mRRW1QQ5KT6NbJbO4QLEhJzSpGgFZ7w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=bu8d t92snmFPU6u8Zbr4Rugc2q+HPKZntN3GEzMdRqONf/h4a6qvdH+s/qt/Wc+HF5HFHDi 34fQNy3mzUNOUQNmifeN/1t60TIybIK4eVk7UQ1QR47f4hRSKXAk7XV2XwJkolsVC4M 2yPNtTtHIPwdpX46VQoXfFr9nxEUiopwg= Received: from mail.skyhub.de ([127.0.0.1]) by localhost (door.skyhub.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id nfUiLwFb6Rxs; Tue, 22 Sep 2015 18:37:08 +0200 (CEST) Received: from pd.tnic (p5DDC5D8E.dip0.t-ipconnect.de [93.220.93.142]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 61F6E1DA283; Tue, 22 Sep 2015 18:37:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alien8.de; s=alien8; t=1442939828; bh=qw20OHeE1bx4mRRW1QQ5KT6NbJbO4QLEhJzSpGgFZ7w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=bu8d t92snmFPU6u8Zbr4Rugc2q+HPKZntN3GEzMdRqONf/h4a6qvdH+s/qt/Wc+HF5HFHDi 34fQNy3mzUNOUQNmifeN/1t60TIybIK4eVk7UQ1QR47f4hRSKXAk7XV2XwJkolsVC4M 2yPNtTtHIPwdpX46VQoXfFr9nxEUiopwg= Received: by pd.tnic (Postfix, from userid 1000) id C11E616050E; Tue, 22 Sep 2015 18:37:05 +0200 (CEST) From: Borislav Petkov To: linux-edac Subject: [PATCH 2/5] EDAC: Add debugfs wrappers Date: Tue, 22 Sep 2015 18:37:02 +0200 Message-Id: <1442939825-13455-2-git-send-email-bp@alien8.de> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1442939825-13455-1-git-send-email-bp@alien8.de> References: <20150922163405.GC3437@pd.tnic> <1442939825-13455-1-git-send-email-bp@alien8.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150922_093731_419372_0523A9E3 X-CRM114-Status: GOOD ( 12.12 ) X-Spam-Score: -2.0 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Loc Ho , arnd@arndb.de, Thor Thayer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Borislav Petkov Later patches will convert EDAC users to those. Signed-off-by: Borislav Petkov --- drivers/edac/debugfs.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/edac/edac_module.h | 34 +++++++++++++++++++++----- 2 files changed, 88 insertions(+), 6 deletions(-) diff --git a/drivers/edac/debugfs.c b/drivers/edac/debugfs.c index bcd558d5cb48..4864703115cc 100644 --- a/drivers/edac/debugfs.c +++ b/drivers/edac/debugfs.c @@ -101,3 +101,63 @@ nomem: debugfs_remove(mci->debugfs); return -ENOMEM; } + +/* Create a toplevel dir under EDAC's debugfs hierarchy */ +struct dentry *edac_debugfs_create_dir(const char *dirname) +{ + if (!edac_debugfs) + return NULL; + + return debugfs_create_dir(dirname, edac_debugfs); +} +EXPORT_SYMBOL_GPL(edac_debugfs_create_dir); + +/* Create a toplevel dir under EDAC's debugfs hierarchy with parent @parent */ +struct dentry * +edac_debugfs_create_dir_at(const char *dirname, struct dentry *parent) +{ + return debugfs_create_dir(dirname, parent); +} +EXPORT_SYMBOL_GPL(edac_debugfs_create_dir_at); + +/* + * Create a file under EDAC's hierarchy or a sub-hierarchy: + * + * @name: file name + * @mode: file permissions + * @parent: parent dentry. If NULL, it becomes the toplevel EDAC dir + * @data: private data of caller + * @fops: file operations of this file + */ +struct dentry * +edac_debugfs_create_file(const char *name, umode_t mode, struct dentry *parent, + void *data, const struct file_operations *fops) +{ + if (!parent) + parent = edac_debugfs; + + return debugfs_create_file(name, mode, parent, data, fops); +} +EXPORT_SYMBOL_GPL(edac_debugfs_create_file); + +/* Wrapper for debugfs_create_x8() */ +struct dentry *edac_debugfs_create_x8(const char *name, umode_t mode, + struct dentry *parent, u8 *value) +{ + if (!parent) + parent = edac_debugfs; + + return debugfs_create_x8(name, mode, parent, value); +} +EXPORT_SYMBOL_GPL(edac_debugfs_create_x8); + +/* Wrapper for debugfs_create_x16() */ +struct dentry *edac_debugfs_create_x16(const char *name, umode_t mode, + struct dentry *parent, u16 *value) +{ + if (!parent) + parent = edac_debugfs; + + return debugfs_create_x16(name, mode, parent, value); +} +EXPORT_SYMBOL_GPL(edac_debugfs_create_x16); diff --git a/drivers/edac/edac_module.h b/drivers/edac/edac_module.h index 79a6c6e20819..b95a48fc723d 100644 --- a/drivers/edac/edac_module.h +++ b/drivers/edac/edac_module.h @@ -60,17 +60,39 @@ extern void *edac_align_ptr(void **p, unsigned size, int n_elems); /* * EDAC debugfs functions */ + +#define edac_debugfs_remove_recursive debugfs_remove_recursive +#define edac_debugfs_remove debugfs_remove #ifdef CONFIG_EDAC_DEBUG int edac_debugfs_init(void); void edac_debugfs_exit(void); int edac_create_debugfs_nodes(struct mem_ctl_info *mci); +struct dentry *edac_debugfs_create_dir(const char *dirname); +struct dentry * +edac_debugfs_create_dir_at(const char *dirname, struct dentry *parent); +struct dentry * +edac_debugfs_create_file(const char *name, umode_t mode, struct dentry *parent, + void *data, const struct file_operations *fops); +struct dentry * +edac_debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, u8 *value); +struct dentry * +edac_debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, u16 *value); #else -static inline int edac_debugfs_init(void) -{ - return -ENODEV; -} -static inline void edac_debugfs_exit(void) {} -static inline int edac_create_debugfs_nodes(struct mem_ctl_info *mci) { return 0; } +static inline int edac_debugfs_init(void) { return -ENODEV; } +static inline void edac_debugfs_exit(void) { } +static inline int edac_create_debugfs_nodes(struct mem_ctl_info *mci) { return 0; } +static inline struct dentry *edac_debugfs_create_dir(const char *dirname) { return NULL; } +static inline struct dentry * +edac_debugfs_create_dir_at(const char *dirname, struct dentry *parent) { return NULL; } +static inline struct dentry * +edac_debugfs_create_file(const char *name, umode_t mode, struct dentry *parent, + void *data, const struct file_operations *fops) { return NULL; } +static inline struct dentry * +edac_debugfs_create_x8(const char *name, umode_t mode, + struct dentry *parent, u8 *value) { return NULL; } +static inline struct dentry * +edac_debugfs_create_x16(const char *name, umode_t mode, + struct dentry *parent, u16 *value) { return NULL; } #endif /*