Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1099836pxx; Fri, 30 Oct 2020 01:53:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5Q/9rruWjHtqlBkDUDKhXIOK+d7O+FOCZdtL/RAS5eEgIiGWV3sKuzhWJecYg9E1PcNlF X-Received: by 2002:a17:907:9604:: with SMTP id gb4mr1423318ejc.336.1604048035349; Fri, 30 Oct 2020 01:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604048035; cv=none; d=google.com; s=arc-20160816; b=G6r1fxhPqkL+Q8Yl49P2aUE4yJ/4EY+ZZs8+nWk5QLm5JXSFjG/+j0J+NCJCOQC++x uYZU3GM5LUt9+couf2DZTCSNhqN/yh/Ye8J8rQj0n35K5LFWJWr3NkhGIbhUmd2ykzEK t2y+L4d4Sz9Z7WLwl/pg2aJ9lXwVJcfpigetwMJFTMJbq3q+KQ6FT6c0cBcaUSPP8koK 8hbpwNWsmhDqf41XyZs1j2RkY9nMTdFbJ3VHcxvt0YTbWfP72g6C1ZofL9tF4jTbWJqz f1kRi1UbTnCwG5Rg/ugpB0h+HTGhypHtK0GlJh7UupnVN1OxY9tSaaNFpRB77NTmCOwn xZQQ== 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=y5YB99WSsiGKdBNJ/HVU9V6LmtDMk/htT+35d3tDP9E=; b=iGYxuiur4aFojMhOfQ7aoRWG98Dj9QInSLhs0edMGOZFEdK7UKfyuOYrGbzh9ueXKA ubxkUGcPsoJO0gXAZPz3cHWOho7XX6NXf9fj5BDAfMT70KvIaXldsL5jPLF2MKPPeA7P Mb4NXIMMqmUUezKP9UYbPmEVZmLoiuDICYhrRLhMa006OA4HlggmOH/+MQLzI4xtgLnJ OM0clc13TIa+6GqIFmd5jBfrY6LbM9DHH4ODQuNXa5EheIHhBv2w7mh8E5iE6zsEHn+z sWerS/jS4MTZT1OYNcBzOoRHtrEexQg81aKRTOk0Cja5f7A3ubaNY+yAbjlC0Pqna3Rh Bx+g== 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 v9si2954843ede.143.2020.10.30.01.53.33; Fri, 30 Oct 2020 01:53:55 -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 S1726110AbgJ3IuY (ORCPT + 99 others); Fri, 30 Oct 2020 04:50:24 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:6944 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbgJ3IuY (ORCPT ); Fri, 30 Oct 2020 04:50:24 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CMwWp1C68z70SB; Fri, 30 Oct 2020 16:31:34 +0800 (CST) Received: from huawei.com (10.69.192.56) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 30 Oct 2020 16:31:25 +0800 From: Luo Jiaxing To: , , CC: , , , , , , , , , , , Subject: [PATCH v2 4/5] usb: dwc3: debugfs: Introduce DEFINE_SHOW_STORE_ATTRIBUTE Date: Fri, 30 Oct 2020 16:32:01 +0800 Message-ID: <1604046722-15531-5-git-send-email-luojiaxing@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604046722-15531-1-git-send-email-luojiaxing@huawei.com> References: <1604046722-15531-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 instroduce a new helper marco DEFINE_SHOW_STORE_ATTRIBUTE for Read-Write file, So we apply it at dwc3 debugfs to reduce some duplicate code. Signed-off-by: Luo Jiaxing --- 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