Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1631012pxk; Fri, 18 Sep 2020 19:17:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyna2qkB01xR82gvDrPTbdMXyV/N1wGTpQGtIWCyWYgjF8cn9lzcZaf0rpkLogunHqUtUN2 X-Received: by 2002:a05:6402:b72:: with SMTP id cb18mr40658143edb.299.1600481845596; Fri, 18 Sep 2020 19:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600481845; cv=none; d=google.com; s=arc-20160816; b=rYpR65vc9SehpzzyxsiG7daIPSKjRbCK4tiWHeIDLpwdj881fF3oevITajcUFSYnc5 aY2JWWQhId503kJ6imYZx+EZL28XA7MK0jOcTGgkj58GdUjzIKCezKMWA0VPLWkbTITU TL0AW7PAi2N5/ppk5NrqcZASV8x4t5CNjj8IzKPbmcbDuf7Qh2TLhRy2XO5QSUmHWB7X li9CV+haMgUlWaLAJ0YqBed1yPJiv4jpr4DXPp/6gRZyOSwhQa9DVLjikmC6OaW+P2Y7 rCAKZpx9RC7queI5mQaMyd0Q1GUNGSo/f642KWDCCJ4F/JXWqlJXmT0pdVRpwXnlH/GW Ku8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=QsoyWC63+lYi0eki7YN25LE65+CYDlcgJlVK5lPMOGw=; b=kfSmjIAnrrDnTZVo8u36t47KualJX6RhZ0012d9FuXGxacTzz8j+hRNNTMz+ehefd6 w7tlgSy3XbH6376BFoZ5th6JBCfbUMhp9KHpz4H/p69kKLnXjDy8kHDf575iSelezg5O ks508fqvDGP7TRnmiOOYrjA92KUDKpXL744vP50nKtiTG2FWwPQVGqEL+3h2ggiyCp5J tIsrK6aPaaDhECjDq+zIaNPjBLkkQqAvHxAexDNGrx6qlZMMKEH8Gq8Ta1wAgeMSvZnL ZDMAVCbtL1nbd3lTLsmGngC1WmnoagvyHb5DxGG+IdaHc7hCpZmmclxpdD9bX187jwJR FUbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i24si3428012edr.73.2020.09.18.19.17.02; Fri, 18 Sep 2020 19:17:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726250AbgISCPd (ORCPT + 99 others); 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; -- 2.23.0