Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp468117pxb; Tue, 3 Nov 2020 04:33:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJweFT0dtCAce42Nj47xSVbjQTg1P4cz+ySvA9SqCauuny6TxlDDLbGHfSbs20O7mpzDc03Y X-Received: by 2002:a17:906:f296:: with SMTP id gu22mr14408406ejb.475.1604406801406; Tue, 03 Nov 2020 04:33:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604406801; cv=none; d=google.com; s=arc-20160816; b=LMLnj0MP7tK7M8xVWSzjSN/Dv7eS+cg5KFwy17C3H5F7Fa/FAON91PuRjDsLkus99F MOAK37uCA2ZK/qavahS2MKibKa/QAUlEPYqU+sJ+prNoVdNre4iwiajNgEzimEh6ITO9 RA3QZp/YhrfFHWysa5fd2SWnEPz/CJGjXtuaeF0zCVSuqAjsvpyhzK2NqQgq2bKGj0U5 TaRz4xZt0w9XFQB+fADxmeSOaOmrzCE1b+hfhlCQGXJqLwO/x7U6bm4b7svvMFYdzTE4 /VIHa9GIn0LrrUhXy3Yc9ANEWMCrp/NsTHh4i804yRzV3G9J1+EliZoVQKHtFYnWOZiq tLSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=jwudu3ZYyDRy97uc/aIh9LVDIXCiarTsOYlk+B1UYGw=; b=RA/9QYcnYBvCdTHIXloyAxoWiFwXkXymT+IbMwjebb/7oiuZyZFYbdUqxMyiGT/rNZ K/Vd1mXK2V33l9822I/R5RhCM0awCNaLivSqP6SCSaEywhW85zHkivxSIBFpSVb3JFTE mzHwCRT1dxAVUMGG/zyDAPeXpfevlZn1GN+aNUmKp88JDU0+GQMcLrtG9u4uwZuNscQM Lzf+qDk+B6dFCPSl/ui/XgHow0fbno8AeJivj1phxysF8Hzqprx0QkyfbH+7js4rzDrT vtmUqqnNFy362xYg2aOHwf3lHntWb1OPP4VjAg5ypmCG+muwGhCCF+W25L/L+U78+BnO W0bQ== 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 lw7si12446409ejb.149.2020.11.03.04.32.59; Tue, 03 Nov 2020 04:33:21 -0800 (PST) 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 S1729078AbgKCM3a (ORCPT + 99 others); Tue, 3 Nov 2020 07:29:30 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:7588 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729042AbgKCM30 (ORCPT ); Tue, 3 Nov 2020 07:29:26 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CQTcB1YvVzLt6L; Tue, 3 Nov 2020 20:29:14 +0800 (CST) Received: from huawei.com (10.69.192.56) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Tue, 3 Nov 2020 20:29:10 +0800 From: Luo Jiaxing To: , , CC: , , , , , , , , , , , Subject: [PATCH v3 4/5] usb: dwc3: debugfs: Introduce DEFINE_SHOW_STORE_ATTRIBUTE Date: Tue, 3 Nov 2020 20:29:43 +0800 Message-ID: <1604406584-53926-5-git-send-email-luojiaxing@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604406584-53926-1-git-send-email-luojiaxing@huawei.com> References: <1604406584-53926-1-git-send-email-luojiaxing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Seq introduce a new helper macro DEFINE_SHOW_STORE_ATTRIBUTE for Read-Write file, so we apply it at dwc3 debugfs to reduce some duplicated code. While at that, also use DEFINE_SHOW_ATTRIBUTE() where possible. Signed-off-by: Luo Jiaxing Acked-by: Felipe Balbi --- drivers/usb/dwc3/debugfs.c | 52 ++++------------------------------------------ 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index 5da4f60..2b5de8d 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c @@ -348,11 +348,6 @@ static int dwc3_lsp_show(struct seq_file *s, void *unused) return 0; } -static int dwc3_lsp_open(struct inode *inode, struct file *file) -{ - return single_open(file, dwc3_lsp_show, inode->i_private); -} - static ssize_t dwc3_lsp_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { @@ -377,13 +372,7 @@ static ssize_t dwc3_lsp_write(struct file *file, const char __user *ubuf, return count; } -static const struct file_operations dwc3_lsp_fops = { - .open = dwc3_lsp_open, - .write = dwc3_lsp_write, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_STORE_ATTRIBUTE(dwc3_lsp); static int dwc3_mode_show(struct seq_file *s, void *unused) { @@ -412,11 +401,6 @@ static int dwc3_mode_show(struct seq_file *s, void *unused) return 0; } -static int dwc3_mode_open(struct inode *inode, struct file *file) -{ - return single_open(file, dwc3_mode_show, inode->i_private); -} - static ssize_t dwc3_mode_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { @@ -445,13 +429,7 @@ static ssize_t dwc3_mode_write(struct file *file, return count; } -static const struct file_operations dwc3_mode_fops = { - .open = dwc3_mode_open, - .write = dwc3_mode_write, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_STORE_ATTRIBUTE(dwc3_mode); static int dwc3_testmode_show(struct seq_file *s, void *unused) { @@ -491,11 +469,6 @@ static int dwc3_testmode_show(struct seq_file *s, void *unused) return 0; } -static int dwc3_testmode_open(struct inode *inode, struct file *file) -{ - return single_open(file, dwc3_testmode_show, inode->i_private); -} - static ssize_t dwc3_testmode_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { @@ -528,13 +501,7 @@ static ssize_t dwc3_testmode_write(struct file *file, return count; } -static const struct file_operations dwc3_testmode_fops = { - .open = dwc3_testmode_open, - .write = dwc3_testmode_write, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_STORE_ATTRIBUTE(dwc3_testmode); static int dwc3_link_state_show(struct seq_file *s, void *unused) { @@ -564,11 +531,6 @@ static int dwc3_link_state_show(struct seq_file *s, void *unused) return 0; } -static int dwc3_link_state_open(struct inode *inode, struct file *file) -{ - return single_open(file, dwc3_link_state_show, inode->i_private); -} - static ssize_t dwc3_link_state_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { @@ -620,13 +582,7 @@ static ssize_t dwc3_link_state_write(struct file *file, return count; } -static const struct file_operations dwc3_link_state_fops = { - .open = dwc3_link_state_open, - .write = dwc3_link_state_write, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_STORE_ATTRIBUTE(dwc3_link_state); struct dwc3_ep_file_map { const char name[25]; -- 2.7.4