Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2347741pxj; Sat, 22 May 2021 20:21:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDagaCHadWVUUxBtZEFx68H4DMM3cGsGlVHrlGDFV6dCh9XbNVOIayA0C+3IclZdoHuZmY X-Received: by 2002:a02:cac6:: with SMTP id f6mr15480064jap.142.1621740077108; Sat, 22 May 2021 20:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621740077; cv=none; d=google.com; s=arc-20160816; b=fio9WhG8Rtu/LRIa8kzwErKUnClb/FgzEss9N0BP6dTUi8eW/kntknBeys+6lRHHa1 7D8mLiuL1vMHXQ+s4Cw62zfJib1lBUbbhHL3P7/um0SQOkbj823d3DB6pL0zIXjKh8d0 o+H2IRP4K2Hxhs8BPPSZo8a/F68GEa6kpoRxZQZzR3G4C81F2U2cFuei01iJGR+/zd2e uBlMjGmae/hCfb1+5JFoD8kaAcirwzmLzCvQRN8dUegubJ58XoW76t2KtwkbWpF/yCzG 9pSanXxtFnS2dJWJHLNdx7tLAvkB6ViKnlo5G6IKXIdJiY117A6KG7pps9PrNvC/4uO4 5S5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=eNLU3GbWN+9finj2FwuMwfIWsS7zZGeGC20o5A1oCHo=; b=qY37kWb2KqT+Y+sg0Rf3U5FLFV9fXpUhrQZfFJfGOGmPmNh3hiuvGPb1HcPB7kDzHi pyk8UuuoSuECmVHx5rR4AqhVRsaTDivLLHUoF9mfGkR3UvN6/d3XTlfaajXRYyi/7Vd0 kUq0SeetHvN/MxWEE9JubaLIDvn3WcGyOSe56M3HmPpgjX6q5J1jRZZ6SoqvGTxvEVF/ +ECnM7O+WECxUmv8peXfwBMDv1+BgciEzhoktK7eGiA7UI3VLORIeNBBSg4q/KSPcveo SHcomGx2HBe9a244BS8PKk6+7eCZ8hrZQgj8gv1gQOvqF8e7HwFVUVld306JVkhGAnX6 ii3A== 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; 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 w14si9914164iom.23.2021.05.22.20.21.04; Sat, 22 May 2021 20:21:17 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231540AbhEWDWD (ORCPT + 99 others); Sat, 22 May 2021 23:22:03 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3636 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231508AbhEWDWC (ORCPT ); Sat, 22 May 2021 23:22:02 -0400 Received: from dggems703-chm.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FnlrD2YxszQnhy; Sun, 23 May 2021 11:17:00 +0800 (CST) Received: from dggema769-chm.china.huawei.com (10.1.198.211) by dggems703-chm.china.huawei.com (10.3.19.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Sun, 23 May 2021 11:20:34 +0800 Received: from localhost (10.174.179.215) by dggema769-chm.china.huawei.com (10.1.198.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Sun, 23 May 2021 11:20:33 +0800 From: YueHaibing To: , , , CC: , , YueHaibing Subject: [PATCH net-next] sfc: use DEVICE_ATTR_*() macro Date: Sun, 23 May 2021 11:20:30 +0800 Message-ID: <20210523032030.42052-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggema769-chm.china.huawei.com (10.1.198.211) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use DEVICE_ATTR_*() helper instead of plain DEVICE_ATTR, which makes the code a bit shorter and easier to read. Signed-off-by: YueHaibing --- drivers/net/ethernet/sfc/ef10.c | 17 ++++++++--------- drivers/net/ethernet/sfc/efx.c | 6 +++--- drivers/net/ethernet/sfc/efx_common.c | 12 +++++++----- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index c3f35da1b82a..d597c89f00ed 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c @@ -370,9 +370,9 @@ static int efx_ef10_get_mac_address_vf(struct efx_nic *efx, u8 *mac_address) return 0; } -static ssize_t efx_ef10_show_link_control_flag(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t link_control_flag_show(struct device *dev, + struct device_attribute *attr, + char *buf) { struct efx_nic *efx = dev_get_drvdata(dev); @@ -382,9 +382,9 @@ static ssize_t efx_ef10_show_link_control_flag(struct device *dev, ? 1 : 0); } -static ssize_t efx_ef10_show_primary_flag(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t primary_flag_show(struct device *dev, + struct device_attribute *attr, + char *buf) { struct efx_nic *efx = dev_get_drvdata(dev); @@ -519,9 +519,8 @@ static void efx_ef10_cleanup_vlans(struct efx_nic *efx) mutex_unlock(&nic_data->vlan_lock); } -static DEVICE_ATTR(link_control_flag, 0444, efx_ef10_show_link_control_flag, - NULL); -static DEVICE_ATTR(primary_flag, 0444, efx_ef10_show_primary_flag, NULL); +static DEVICE_ATTR_RO(link_control_flag); +static DEVICE_ATTR_RO(primary_flag); static int efx_ef10_probe(struct efx_nic *efx) { diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 4fd9903ffe98..37fcf2eb0741 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -689,13 +689,13 @@ static struct notifier_block efx_netdev_notifier = { .notifier_call = efx_netdev_event, }; -static ssize_t -show_phy_type(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t phy_type_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct efx_nic *efx = dev_get_drvdata(dev); return sprintf(buf, "%d\n", efx->phy_type); } -static DEVICE_ATTR(phy_type, 0444, show_phy_type, NULL); +static DEVICE_ATTR_RO(phy_type); static int efx_register_netdev(struct efx_nic *efx) { diff --git a/drivers/net/ethernet/sfc/efx_common.c b/drivers/net/ethernet/sfc/efx_common.c index de797e1ac5a9..896b59253197 100644 --- a/drivers/net/ethernet/sfc/efx_common.c +++ b/drivers/net/ethernet/sfc/efx_common.c @@ -1160,8 +1160,9 @@ void efx_fini_io(struct efx_nic *efx) } #ifdef CONFIG_SFC_MCDI_LOGGING -static ssize_t show_mcdi_log(struct device *dev, struct device_attribute *attr, - char *buf) +static ssize_t mcdi_logging_show(struct device *dev, + struct device_attribute *attr, + char *buf) { struct efx_nic *efx = dev_get_drvdata(dev); struct efx_mcdi_iface *mcdi = efx_mcdi(efx); @@ -1169,8 +1170,9 @@ static ssize_t show_mcdi_log(struct device *dev, struct device_attribute *attr, return scnprintf(buf, PAGE_SIZE, "%d\n", mcdi->logging_enabled); } -static ssize_t set_mcdi_log(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t mcdi_logging_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { struct efx_nic *efx = dev_get_drvdata(dev); struct efx_mcdi_iface *mcdi = efx_mcdi(efx); @@ -1180,7 +1182,7 @@ static ssize_t set_mcdi_log(struct device *dev, struct device_attribute *attr, return count; } -static DEVICE_ATTR(mcdi_logging, 0644, show_mcdi_log, set_mcdi_log); +static DEVICE_ATTR_RW(mcdi_logging); void efx_init_mcdi_logging(struct efx_nic *efx) { -- 2.17.1