From patchwork Tue Jun 9 13:14:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Praveen Madhavan X-Patchwork-Id: 6572591 Return-Path: X-Original-To: patchwork-linux-scsi@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 69AC59F2F4 for ; Tue, 9 Jun 2015 13:15:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B28D204DF for ; Tue, 9 Jun 2015 13:15:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B58E203DA for ; Tue, 9 Jun 2015 13:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932326AbbFINPU (ORCPT ); Tue, 9 Jun 2015 09:15:20 -0400 Received: from stargate.chelsio.com ([67.207.112.58]:31943 "EHLO stargate3.asicdesigners.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752483AbbFINPT (ORCPT ); Tue, 9 Jun 2015 09:15:19 -0400 Received: from fcoe-test11.localdomain (fcoe-test11.blr.asicdesigners.com [10.193.185.180]) by stargate3.asicdesigners.com (8.13.8/8.13.8) with ESMTP id t59DEoJU004002; Tue, 9 Jun 2015 06:15:00 -0700 From: Praveen Madhavan To: netdev@vger.kernel.org, linux-scsi@vger.kernel.org Cc: davem@davemloft.net, JBottomley@parallels.com, hariprasad@chelsio.com, praveenm@chelsio.com, varun@chelsio.com, rajesh.kumar@chelsio.com Subject: [PATCH 2/3] csiostor:Cleanup debugfs. Date: Tue, 9 Jun 2015 18:44:45 +0530 Message-Id: <1433855686-15768-3-git-send-email-praveenm@chelsio.com> X-Mailer: git-send-email 2.0.2 In-Reply-To: <1433855686-15768-1-git-send-email-praveenm@chelsio.com> References: <1433855686-15768-1-git-send-email-praveenm@chelsio.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 This patch cleanup existing debugfs. Debugfs support is moved into to new file in next patch of this series. Signed-off-by: Praveen Madhavan --- drivers/scsi/csiostor/csio_init.c | 132 -------------------------------------- drivers/scsi/csiostor/csio_init.h | 4 ++ 2 files changed, 4 insertions(+), 132 deletions(-) diff --git a/drivers/scsi/csiostor/csio_init.c b/drivers/scsi/csiostor/csio_init.c index dbe416f..48e0159 100644 --- a/drivers/scsi/csiostor/csio_init.c +++ b/drivers/scsi/csiostor/csio_init.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include @@ -52,141 +51,10 @@ #define CSIO_MIN_MEMPOOL_SZ 64 -static struct dentry *csio_debugfs_root; - static struct scsi_transport_template *csio_fcoe_transport; static struct scsi_transport_template *csio_fcoe_transport_vport; /* - * debugfs support - */ -static ssize_t -csio_mem_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) -{ - loff_t pos = *ppos; - loff_t avail = file_inode(file)->i_size; - unsigned int mem = (uintptr_t)file->private_data & 3; - struct csio_hw *hw = file->private_data - mem; - - if (pos < 0) - return -EINVAL; - if (pos >= avail) - return 0; - if (count > avail - pos) - count = avail - pos; - - while (count) { - size_t len; - int ret, ofst; - __be32 data[16]; - - if (mem == MEM_MC) - ret = hw->chip_ops->chip_mc_read(hw, 0, pos, - data, NULL); - else - ret = hw->chip_ops->chip_edc_read(hw, mem, pos, - data, NULL); - if (ret) - return ret; - - ofst = pos % sizeof(data); - len = min(count, sizeof(data) - ofst); - if (copy_to_user(buf, (u8 *)data + ofst, len)) - return -EFAULT; - - buf += len; - pos += len; - count -= len; - } - count = pos - *ppos; - *ppos = pos; - return count; -} - -static const struct file_operations csio_mem_debugfs_fops = { - .owner = THIS_MODULE, - .open = simple_open, - .read = csio_mem_read, - .llseek = default_llseek, -}; - -void csio_add_debugfs_mem(struct csio_hw *hw, const char *name, - unsigned int idx, unsigned int size_mb) -{ - debugfs_create_file_size(name, S_IRUSR, hw->debugfs_root, - (void *)hw + idx, &csio_mem_debugfs_fops, - size_mb << 20); -} - -static int csio_setup_debugfs(struct csio_hw *hw) -{ - int i; - - if (IS_ERR_OR_NULL(hw->debugfs_root)) - return -1; - - i = csio_rd_reg32(hw, MA_TARGET_MEM_ENABLE_A); - if (i & EDRAM0_ENABLE_F) - csio_add_debugfs_mem(hw, "edc0", MEM_EDC0, 5); - if (i & EDRAM1_ENABLE_F) - csio_add_debugfs_mem(hw, "edc1", MEM_EDC1, 5); - - hw->chip_ops->chip_dfs_create_ext_mem(hw); - return 0; -} - -/* - * csio_dfs_create - Creates and sets up per-hw debugfs. - * - */ -static int -csio_dfs_create(struct csio_hw *hw) -{ - if (csio_debugfs_root) { - hw->debugfs_root = debugfs_create_dir(pci_name(hw->pdev), - csio_debugfs_root); - csio_setup_debugfs(hw); - } - - return 0; -} - -/* - * csio_dfs_destroy - Destroys per-hw debugfs. - */ -static int -csio_dfs_destroy(struct csio_hw *hw) -{ - if (hw->debugfs_root) - debugfs_remove_recursive(hw->debugfs_root); - - return 0; -} - -/* - * csio_dfs_init - Debug filesystem initialization for the module. - * - */ -static int -csio_dfs_init(void) -{ - csio_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL); - if (!csio_debugfs_root) - pr_warn("Could not create debugfs entry, continuing\n"); - - return 0; -} - -/* - * csio_dfs_exit - debugfs cleanup for the module. - */ -static void -csio_dfs_exit(void) -{ - debugfs_remove(csio_debugfs_root); -} - -/* * csio_pci_init - PCI initialization. * @pdev: PCI device. * @bars: Bitmask of bars to be requested. diff --git a/drivers/scsi/csiostor/csio_init.h b/drivers/scsi/csiostor/csio_init.h index 5cc5d31..5de485f 100644 --- a/drivers/scsi/csiostor/csio_init.h +++ b/drivers/scsi/csiostor/csio_init.h @@ -78,6 +78,10 @@ void csio_lnodes_exit(struct csio_hw *, bool); /* DebugFS helper routines */ void csio_add_debugfs_mem(struct csio_hw *, const char *, unsigned int, unsigned int); +int csio_dfs_create(struct csio_hw *); +int csio_dfs_destroy(struct csio_hw *); +int csio_dfs_init(void); +void csio_dfs_exit(void); static inline struct Scsi_Host * csio_ln_to_shost(struct csio_lnode *ln)