From patchwork Sat Sep 19 02:15:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qinglang Miao X-Patchwork-Id: 11786569 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C68E1112E for ; Sat, 19 Sep 2020 02:15:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B75D520758 for ; Sat, 19 Sep 2020 02:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726222AbgISCPd (ORCPT ); Fri, 18 Sep 2020 22:15:33 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:44392 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726009AbgISCPd (ORCPT ); Fri, 18 Sep 2020 22:15:33 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id A10CE5A7B70B5E082F60; Sat, 19 Sep 2020 10:15:31 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Sat, 19 Sep 2020 10:15:21 +0800 From: Qinglang Miao To: Joshua Morris , Philip Kelleher , Jens Axboe CC: , , "Qinglang Miao" Subject: [PATCH -next v2] rsxx: Convert to DEFINE_SHOW_ATTRIBUTE Date: Sat, 19 Sep 2020 10:15:52 +0800 Message-ID: <20200919021552.189712-1-miaoqinglang@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Qinglang Miao --- v2: based on linux-next(20200917), and can be applied to mainline cleanly now. drivers/block/rsxx/core.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c index 8799e3bab..7d580965f 100644 --- a/drivers/block/rsxx/core.c +++ b/drivers/block/rsxx/core.c @@ -150,16 +150,6 @@ static int rsxx_attr_stats_show(struct seq_file *m, void *p) return 0; } -static int rsxx_attr_stats_open(struct inode *inode, struct file *file) -{ - return single_open(file, rsxx_attr_stats_show, inode->i_private); -} - -static int rsxx_attr_pci_regs_open(struct inode *inode, struct file *file) -{ - return single_open(file, rsxx_attr_pci_regs_show, inode->i_private); -} - static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf, size_t cnt, loff_t *ppos) { @@ -206,21 +196,8 @@ static const struct file_operations debugfs_cram_fops = { .write = rsxx_cram_write, }; -static const struct file_operations debugfs_stats_fops = { - .owner = THIS_MODULE, - .open = rsxx_attr_stats_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations debugfs_pci_regs_fops = { - .owner = THIS_MODULE, - .open = rsxx_attr_pci_regs_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(rsxx_attr_stats); +DEFINE_SHOW_ATTRIBUTE(rsxx_attr_pci_regs); static void rsxx_debugfs_dev_new(struct rsxx_cardinfo *card) { @@ -234,13 +211,13 @@ static void rsxx_debugfs_dev_new(struct rsxx_cardinfo *card) debugfs_stats = debugfs_create_file("stats", 0444, card->debugfs_dir, card, - &debugfs_stats_fops); + &rsxx_attr_stats_fops); if (IS_ERR_OR_NULL(debugfs_stats)) goto failed_debugfs_stats; debugfs_pci_regs = debugfs_create_file("pci_regs", 0444, card->debugfs_dir, card, - &debugfs_pci_regs_fops); + &rsxx_attr_pci_regs_fops); if (IS_ERR_OR_NULL(debugfs_pci_regs)) goto failed_debugfs_pci_regs;