From patchwork Thu Jun 3 11:17:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhen Lei X-Patchwork-Id: 453249 Delivered-To: patch@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp179294jao; Thu, 3 Jun 2021 04:17:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT70RHgKhr/fUtfhpUuKNQtlwOBRAZ6diTeAFlNAxw1i6KhoHCF+SIvKKu1A9YQ0INsIq5 X-Received: by 2002:a17:906:8345:: with SMTP id b5mr5282484ejy.14.1622719069269; Thu, 03 Jun 2021 04:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622719069; cv=none; d=google.com; s=arc-20160816; b=jQIS/vXEvbPkHGFkeCw9jh9ZsB5Rqb9C8rs0FWYD1ca+7qEvyRR9w2BlGnKPkTP3Cn EK2gpIYKsBq5pX4UDl4yU61m2EQCHNXd9OS5S93bQavrpFWQEqcAKImUmkIvGiIa3CpN a/R5FxWdJtZgFrz13fli0YBBlSuH6zJEojGBtnQF5DehYQJu+hjlXkCIA0OsvkI5nR2Y n2cGZix1Zeey1btsEJsow2ZUgF2EvHnBnz0DgHeVNcORhTxbu54AbCmfdr+bXk9G1hjR SQv1mZlFX9O1eOHUEmF5FnSIbNnc+5zse796yWSYRhrlF0lw5I3TrOTEv6EcKFNBC6+i 1KkQ== 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=p3GE5ZInIMZ1OcogzTmKhxTWGqu92Ta1ae6g/dE8Lqk=; b=R46KQ1AcCHKUkX3fuOoBCtfnlRKq0Z3GNZeJWwlngaHPeK7ub37lezgBaziXGaB859 Oa7RgrafhFLuKKfFQ2rg0XjyuKK5NWaFzVrWuaK/0hNE5mWvuslrczjF33mTjJMM/vNs ssMTKVN+pptgsWHzCb0nc4cC8O95836lqxhgEXIlkzVFVem5U9yuryeyLJIQ1suGU7S/ 7EQuGvZ0v8TT6pMh9eKp8XNElPIU2Dp2/XBlxuFXDmcoAKSnepxiJz9r8oxw3s0ftob6 Di4dMmIAMiSJlbIXXzvlV5TmZbxuEpxQdPEiFuJpRy570uORZtcF6nIE9pRyPfs6ovL0 97Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e11si2009619ejm.421.2021.06.03.04.17.49; Thu, 03 Jun 2021 04:17:49 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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 netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbhFCLTc (ORCPT + 8 others); Thu, 3 Jun 2021 07:19:32 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:3407 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbhFCLTc (ORCPT ); Thu, 3 Jun 2021 07:19:32 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4FwjvW6z5hz67Sq; Thu, 3 Jun 2021 19:13:59 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 3 Jun 2021 19:17:45 +0800 Received: from thunder-town.china.huawei.com (10.174.177.72) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 3 Jun 2021 19:17:44 +0800 From: Zhen Lei To: Wolfgang Grandegger , Marc Kleine-Budde , "David S . Miller" , "Jakub Kicinski" , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , linux-can , netdev , linux-arm-kernel CC: Zhen Lei Subject: [PATCH 1/1] can: janz-ican3: use DEVICE_ATTR_RO/RW() helper macro Date: Thu, 3 Jun 2021 19:17:39 +0800 Message-ID: <20210603111739.11983-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.177.72] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use DEVICE_ATTR_RO/RW() helper macro instead of plain DEVICE_ATTR(), which makes the code a bit shorter and easier to read. Signed-off-by: Zhen Lei --- drivers/net/can/janz-ican3.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) -- 2.26.0.106.g9fadedd diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c index 2a6c918186c02ed..c68ad56628bd444 100644 --- a/drivers/net/can/janz-ican3.c +++ b/drivers/net/can/janz-ican3.c @@ -1815,9 +1815,9 @@ static int ican3_get_berr_counter(const struct net_device *ndev, * Sysfs Attributes */ -static ssize_t ican3_sysfs_show_term(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t termination_show(struct device *dev, + struct device_attribute *attr, + char *buf) { struct ican3_dev *mod = netdev_priv(to_net_dev(dev)); int ret; @@ -1834,9 +1834,9 @@ static ssize_t ican3_sysfs_show_term(struct device *dev, return snprintf(buf, PAGE_SIZE, "%u\n", mod->termination_enabled); } -static ssize_t ican3_sysfs_set_term(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t termination_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { struct ican3_dev *mod = netdev_priv(to_net_dev(dev)); unsigned long enable; @@ -1852,18 +1852,17 @@ static ssize_t ican3_sysfs_set_term(struct device *dev, return count; } -static ssize_t ican3_sysfs_show_fwinfo(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t fwinfo_show(struct device *dev, + struct device_attribute *attr, + char *buf) { struct ican3_dev *mod = netdev_priv(to_net_dev(dev)); return scnprintf(buf, PAGE_SIZE, "%s\n", mod->fwinfo); } -static DEVICE_ATTR(termination, 0644, ican3_sysfs_show_term, - ican3_sysfs_set_term); -static DEVICE_ATTR(fwinfo, 0444, ican3_sysfs_show_fwinfo, NULL); +static DEVICE_ATTR_RW(termination); +static DEVICE_ATTR_RO(fwinfo); static struct attribute *ican3_sysfs_attrs[] = { &dev_attr_termination.attr,