Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5438396pxu; Thu, 22 Oct 2020 02:14:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZEDZUGqnMYk6EMJbXXdKsTaxRp9Ii8Uf4nyY4RDiceuXwM5iLqx/6jRSjbniaoswcONgH X-Received: by 2002:a17:906:5618:: with SMTP id f24mr1306473ejq.86.1603358063252; Thu, 22 Oct 2020 02:14:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603358063; cv=none; d=google.com; s=arc-20160816; b=SUd7irUdQPGP7Jo/yVROnfTM0pjiK5I/eplgfAQvMQUATtF9j7Jez9yKdkUVPlFWNF yJdOdxKHe5EvoukeGwiBUt1HM7p3R1kACma8O5RglcioYJeg1UG37Ick3HHCWUel5svx OrnkfgoCh+05jfmcvhzdqOfPnrVaR/QX1EARzNwQPIvQium1rPpOp2fadPDfbiowif/f U7nXvT1EQAlfc0M6Z1mTh4VwolQ+b9FG1bjhYTjXm6JV7dygAjuwMAo2YUdt7ZDrRc2B xGwzQVYvEneWNn8qvyiFb1U63j5FVxhyokLZpUjKmLXwnLpUA0AOcJxftj1gXQ68RDTj Z+Dg== 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=nenRj1ao2JfyOxGqwpQqKF9B5XYCbCnKVe/ZKXITILo=; b=0jcypPC+saQhVx49a+bj9K4m0kZ+VLzbTU1ihFZGyV99/KuhO+weGwEGgr/prnZaMz uiPKQIzB2Gkp2A+oCGfWG1c+g9d5KD6Uz2CJjgCoE6zrRIClzZxoL26xP43DaIjYdR83 jW1xoW/kDaeHuFSpXkWXXGnW/arBdbT44X8WKi2lAU6Y/rRb/vfGr/iAIpv/sJBgm91D fpVGtFHvrE/FzVhOoD4+JWMwpwd753w3SltzQ/Odx+RWqoV/X3c86Of9Qu3Y6PF7XAPS snX7cKk/VLzrU7K5ItglSJZajm/E70emxNklrXP3vw0gzNa0pMpRJV6F1FaY7y8EZhwe A5rQ== 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 a1si529464edr.199.2020.10.22.02.14.01; Thu, 22 Oct 2020 02:14:23 -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 S2508313AbgJVIkD (ORCPT + 99 others); Thu, 22 Oct 2020 04:40:03 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:15761 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2509380AbgJVIj2 (ORCPT ); Thu, 22 Oct 2020 04:39:28 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 5D42AE071DE8DAE113D7; Thu, 22 Oct 2020 16:39:24 +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; Thu, 22 Oct 2020 16:39:16 +0800 From: Luo Jiaxing To: , , CC: , , , , , , , , , , , Subject: [PATCH v1 4/5] usb: dwc3: debugfs: Introduce DEFINE_STORE_ATTRIBUTE Date: Thu, 22 Oct 2020 16:39:56 +0800 Message-ID: <1603355997-32350-5-git-send-email-luojiaxing@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1603355997-32350-1-git-send-email-luojiaxing@huawei.com> References: <1603355997-32350-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_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..27074cb 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_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_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_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_STORE_ATTRIBUTE(dwc3_link_state); struct dwc3_ep_file_map { const char name[25]; -- 2.7.4