Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp380096pxk; Thu, 17 Sep 2020 05:45:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkLiaDhyUmZ+lhVSJEa/wEBaxURUZngsVzXEM7MuSr12YVovghowgSN1P84v05mUY9yK+5 X-Received: by 2002:a17:906:4956:: with SMTP id f22mr28940168ejt.62.1600346732914; Thu, 17 Sep 2020 05:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600346732; cv=none; d=google.com; s=arc-20160816; b=Fz6VNQDoJ1QjkwBlqhTIpdOGteqFfFtsTdoCYDeGzkavJJjnpza+kbue0xN5caf1k+ s3sPBEGcO00bWBRdApXIg3hZ1hBL1JLE70lIVqliD+DGgcpljr7a254yz2l+e/Cu7GMB qZJXX+dMQoWI/rYnKuMOf43A79wp1x544JCq5zvZ97hUJj6N1AlqZgNbhXNbiSapaN+A ThBWVvswdB2uRao6CHsx8odmRQKH/AARJl9p1zY4QMQtog1fV/p5kz0AKGzR9njXo39g 6Za7zeUh2tm/A1+IqMi5C8R5QwV0Y0NVu7kj8QirYaBWRNboJCAVPgKhW/+OQiDr50RB sDCw== 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=gfQHeWwIbsC9ZceCjvklj0oWMXF22gg00r6prlYjmZM=; b=yuy0/136wcdbQ6BoTGwykpKB+lYlkYedmZIgwG5BCOD2HyA0GrS4gYuoLIvueMC/fY rq0T+15cHYNV3D5slnwUY4MYgkGwXeOKiK5SK9HOVWYQjvHk9hOhq6OLzSuSXnaZ6qs3 Hnidk7MxveC9b/e+3gjmg5dULRIjrqRCs4iO46tPK4FpR2KomqA6fPKxgIpXYsLCXtYP 4I7rRTzHZPKjQsiTjRoqd9unmxEyuIzS3mW/o08efALVTJWON3ZMgZj/c1xOTAb4u1I6 oYTYL79c2YDY8Tw3b/4hPggUqkLAasALlBuSNUDpNPqj+NgbqIvoXGAAcgL1cqn37suG d2MQ== 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 e14si13795911eds.529.2020.09.17.05.45.09; Thu, 17 Sep 2020 05:45:32 -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 S1727033AbgIQMn4 (ORCPT + 99 others); Thu, 17 Sep 2020 08:43:56 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:49912 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727034AbgIQMkQ (ORCPT ); Thu, 17 Sep 2020 08:40:16 -0400 X-Greylist: delayed 965 seconds by postgrey-1.27 at vger.kernel.org; Thu, 17 Sep 2020 08:40:10 EDT Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 7EAB13B5571B7F534558; Thu, 17 Sep 2020 20:22:55 +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; Thu, 17 Sep 2020 20:22:49 +0800 From: Qinglang Miao To: Coly Li , Kent Overstreet CC: , , "Qinglang Miao" Subject: [PATCH -next v2] bcache: Convert to DEFINE_SHOW_ATTRIBUTE Date: Thu, 17 Sep 2020 20:23:26 +0800 Message-ID: <20200917122326.99080-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. As inode->iprivate equals to third parameter of debugfs_create_file() which is NULL. So it's equivalent to original code logic. Signed-off-by: Qinglang Miao --- v2: based on linux-next(20200917), and can be applied to mainline cleanly now. drivers/md/bcache/closure.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c index 0164a1fe9..d8d9394a6 100644 --- a/drivers/md/bcache/closure.c +++ b/drivers/md/bcache/closure.c @@ -159,7 +159,7 @@ void closure_debug_destroy(struct closure *cl) static struct dentry *closure_debug; -static int debug_seq_show(struct seq_file *f, void *data) +static int debug_show(struct seq_file *f, void *data) { struct closure *cl; @@ -188,17 +188,7 @@ static int debug_seq_show(struct seq_file *f, void *data) return 0; } -static int debug_seq_open(struct inode *inode, struct file *file) -{ - return single_open(file, debug_seq_show, NULL); -} - -static const struct file_operations debug_ops = { - .owner = THIS_MODULE, - .open = debug_seq_open, - .read = seq_read, - .release = single_release -}; +DEFINE_SHOW_ATTRIBUTE(debug); void __init closure_debug_init(void) { @@ -209,7 +199,7 @@ void __init closure_debug_init(void) * about this. */ closure_debug = debugfs_create_file( - "closures", 0400, bcache_debug, NULL, &debug_ops); + "closures", 0400, bcache_debug, NULL, &debug_fops); } #endif -- 2.23.0